Re: Identification of controls of another application
- From: "Javier Jiménez Rodríguez" <desarrollo(arroba)catinformacion(punto)es>
- Date: Wed, 9 Nov 2005 17:31:00 +0100
Thank you Tom but me does not serve because what I need is an identifier
that remain invariable in any execution of the external application and
GetFocusHwnd returns a different value in each execution of the external
application. I try to know in which data of another application is the
cursor. In the code, the name, the date,...
Thanks,
Javier Jiménez
"Tom Esh" <tjeshGibberish@xxxxxxxxxx> escribió en el mensaje
news:be24n159ojn9n5jf4k3cu0voihhvonc57u@xxxxxxxxxx
> On Wed, 9 Nov 2005 13:27:04 +0100, "Javier Jiménez Rodríguez"
> <desarrollo(arroba)catinformacion(punto)es> wrote:
>
> >I am trying to be able to know in which control of another application is
> >the focus. Is this possible? What I want is to be able to obtain an
> >identifier of the control that indicate me that control treats and that
vary
> >not in each execution.
>
> This will return the hwnd of the contol with focus in the current
> foreground / active app.
>
>
> Public Declare Function AttachThreadInput Lib "user32" _
> (ByVal idAttach As Long, ByVal idAttachTo As Long, _
> ByVal fAttach As Long) As Long
> Public Declare Function GetFocus Lib "user32" () As Long
> Public Declare Function GetActiveWindow Lib "user32" () As Long
> Public Declare Function GetForegroundWindow Lib "user32" () As Long
> Public Declare Function GetWindowThreadProcessId Lib "user32" _
> (ByVal hWnd As Long, lpdwProcessId As Any) As Long
>
>
> Public Function GetFocusHwnd() As Long
> 'Returns hwnd of window with KB focus, or 0 if none.
> Dim hFG As Long, TID As Long
>
> hFG = GetForegroundWindow()
> If hFG <> 0 Then
> TID = GetWindowThreadProcessId(hFG, ByVal 0&)
> If TID <> App.ThreadID Then 'not this thread
> AttachThreadInput App.ThreadID, TID, 1
> GetFocusHwnd = GetFocus()
> AttachThreadInput App.ThreadID, TID, 0
> Else 'it's us
> GetFocusHwnd = GetFocus()
> End If
> End If
> End Function
>
>
> -Tom
> MVP - Visual Basic
> (please post replies to the newsgroup)
.
- Follow-Ups:
- Re: Identification of controls of another application
- From: Tom Esh
- Re: Identification of controls of another application
- References:
- Identification of controls of another application
- From: Javier Jiménez Rodríguez
- Re: Identification of controls of another application
- From: Tom Esh
- Identification of controls of another application
- Prev by Date: Re: Identification of controls of another application
- Next by Date: Re: Identification of controls of another application
- Previous by thread: Re: Identification of controls of another application
- Next by thread: Re: Identification of controls of another application
- Index(es):