Results 1 to 10 of 570

Thread: Tests Copying, Pasting, API Cliipboard issues. and Rough notes on Advanced API stuff

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    The last post inspired me a bit to take another look at this snippet.
    Code:
    Let hwndClip = FindWindowEx(Application.hWnd, 0, "EXCEL2", vbNullString)
    Let hwndClip = FindWindowEx(hwndClip, 0, "MsoCommandBar", CommandBars(MyPain).NameLocal)
    Let hwndClip = GetNextWindow(hwndClip, GW_CHILD)
    Let hwndScrollBar = GetNextWindow(GetNextWindow(hwndClip, GW_CHILD), GW_CHILD)
        
        If hwndClip And hwndScrollBar Then
         GetWindowRect hwndClip, tRect1
         GetWindowRect hwndScrollBar, tRect2
         BringWindowToTop Application.hWnd
            For i = 0 To tRect1.Right - tRect1.Left Step 50
             tPt.x = tRect1.Left + i: tPt.Y = tRect1.Top - 10 + (tRect2.Top - tRect1.Top) / 2
                #If VBA7 And Win64 Then
                 CopyMemory lngPtr, tPt, LenB(tPt)
                 Let lResult = AccessibleObjectFromPoint(lngPtr, oIA, vKid)
                #Else
                 Let lResult = AccessibleObjectFromPoint(tPt.x, tPt.Y, oIA, vKid)
                #End If ' 
                If InStr("Clear All Borrar todo Effacer tout Alle löschen La légende du bouton", oIA.accName(vKid)) Then
                Call oIA.accDoDefaultAction(vKid) ' This does the clearing,  and
                     CommandBars(MyPain).Visible = Not bHidden ' 
                     Let bHidden = False
                      Exit Sub
                End If
             DoEvents
            Next i
        End If 
    I did some modifications to help take a closer look
    (The modifications are
    _ 1) a small change to prevent the code erroring if finds a button or something without any caption
    _2) some Debug.Print lines )

    Here is the modified version
    Code:
    '                                1180958
    Let hwndClip = FindWindowEx(Application.hwnd, 0, "EXCEL2", vbNullString):                 Debug.Print "hwndClip      " & hwndClip
    Let hwndClip = FindWindowEx(hwndClip, 0, "MsoCommandBar", CommandBars(MyPain).NameLocal): Debug.Print "hwndClip      " & hwndClip ' 591464
    Let hwndClip = GetNextWindow(hwndClip, GW_CHILD):                                         Debug.Print "hwndClip       " & hwndClip '   721906
    Let hwndScrollBar = GetNextWindow(GetNextWindow(hwndClip, GW_CHILD), GW_CHILD):           Debug.Print "hwndScrollBar " & hwndScrollBar  ' 787440
                                                                                              Debug.Print
        If hwndClip And hwndScrollBar Then
         GetWindowRect hwndClip, tRect1
         GetWindowRect hwndScrollBar, tRect2
         BringWindowToTop Application.hwnd
                                                                                              Debug.Print "  tRect1.Top   =  " & tRect1.Top & "   tRect2.Top  =  " & tRect2.Top
                                                                                              Debug.Print "( tRect1.Bottom = " & tRect1.Bottom & "   tRect2.Bottom = " & tRect2.Bottom & " )"
                                                                                              Debug.Print "Loop i from   0  To  (" & tRect1.Right & "-" & tRect1.Left & ")=" & tRect1.Right - tRect1.Left & "   Step 50"
            For i = 0 To tRect1.Right - tRect1.Left Step 50
             Let tPt.x = tRect1.Left + i
             Let tPt.Y = tRect1.Top - 10 + (tRect2.Top - tRect1.Top) / 2:                     Debug.Print "i=" & Format(i, "000") & "   tPt.x = " & tPt.x & "   tPt.Y = " & tPt.Y
                #If VBA7 And Win64 Then
                 CopyMemory lngPtr, tPt, LenB(tPt)
                 Let lResult = AccessibleObjectFromPoint(lngPtr, oIA, vKid)
                #Else
                 Let lResult = AccessibleObjectFromPoint(tPt.x, tPt.Y, oIA, vKid)
                #End If ' 
                                                                                              Debug.Print "lResult " & lResult & "   vKid " & vKid & "   oIA.accName(vKid) """ & oIA.accName(vKid) & """"
                If oIA.accName(vKid) <> "" And InStr("Clear All Borrar todo Effacer tout Alle löschen La légende du bouton", oIA.accName(vKid)) > 0 Then
                Call oIA.accDoDefaultAction(vKid) ' This does the clearing,  and
                     CommandBars(MyPain).Visible = Not bHidden ' 
                     Let bHidden = False
                                                                            Debug.Print "Worked,   :-)"
                     Stop: Exit Sub
                End If
             DoEvents
            Next i
        End If
    Let CommandBars(MyPain).Visible = Not bHidden
     Debug.Print "Unable to clear the Office Clipboard, didn't work,   :-("
    Stop
    End Sub
    

    Results in the next two posts
    https://www.excelfox.com/forum/showt...ll=1#post18042
    https://www.excelfox.com/forum/showt...ll=1#post18043
    Last edited by DocAElstein; 11-07-2024 at 07:05 PM.

Similar Threads

  1. Some Date Notes and Tests
    By DocAElstein in forum Test Area
    Replies: 5
    Last Post: 03-26-2025, 02:56 AM
  2. Replies: 116
    Last Post: 02-23-2025, 12:13 AM
  3. Replies: 21
    Last Post: 12-15-2024, 07:13 PM
  4. Replies: 42
    Last Post: 05-29-2023, 01:19 PM
  5. Replies: 11
    Last Post: 10-13-2013, 10:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •