Get the window which has got focus using GetFocus API
Get the window which has got focus using GetFocus API
API Declarations
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Rate Get the window which has got focus using GetFocus API
(1(1 Vote))
Private Sub Timer1_Timer()
Dim wnd As Long, wntxt As String, txtlen As Long
wnd = GetFocus()
txtlen = GetWindowTextLength(wnd) + 1
wntxt = Space(txtlen)
txtlen = GetWindowText(wnd, wntxt, txtlen)
Label1.Caption = Left(wntxt, txtlen) & " has the focus now."
End Sub
'Visit my Homepage at
'http://www.geocities.com/marskarthik
'http://marskarthik.virtualave.net
'Email: [email protected]
Get the window which has got focus using GetFocus API Comments
No comments yet — be the first to post one!
Post a Comment