Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15772

How to find the handle of the first 5 controls on and external application?

$
0
0
Hi, I have need finf the handles of the first few controls on an external application. All I have is the Window handle. Several discussions I've read have suggested use of the AttachThreadInput API. I tried this code. The Debug.print statement prints h_wnd (the Window handle) all 5 times. Any ideas on how to improve this? Thanks, Bob.

Code:

        Dim lngFocusFormThreadID As Long

        SetForegroundWindow h_wnd
        lngFocusFormThreadID = GetWindowThreadProcessId(h_wnd, ByVal 0&)
        Set wshShell = CreateObject("WScript.Shell")
        For i = 1 To 5
            AttachThreadInput App.ThreadID, lngFocusFormThreadID, True
            Debug.Print GetFocus
            AttachThreadInput App.ThreadID, lngFocusFormThreadID, False
            wshShell.SendKeys "{TAB 1}"
        Next
        Set wshShell = Nothing


Viewing all articles
Browse latest Browse all 15772

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>