Hi,
I have a code (below) which can extract the name of the window which is currently active on my desktop:-
Code:
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
sub Macro1
Dim hforewnd As Long
Dim slength As Long
Dim wintext As String
Dim retval As Long
hforewnd = GetForegroundWindow()
slength = GetWindowTextLength(hforewnd) + 1
wintext = Space(slength)
retval = GetWindowText(hforewnd, wintext, slength)
wintext = Left(wintext, slength - 1)
msgbox wintext
end sub
code:
Can anyone please suggest me how can i get the name of the parent application of the active window. As of now it's only giving the name of the active window.
Please help me with this..... many thanks in advance.
Regards,
Premanshu.
I have a code (below) which can extract the name of the window which is currently active on my desktop:-
Code:
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
sub Macro1
Dim hforewnd As Long
Dim slength As Long
Dim wintext As String
Dim retval As Long
hforewnd = GetForegroundWindow()
slength = GetWindowTextLength(hforewnd) + 1
wintext = Space(slength)
retval = GetWindowText(hforewnd, wintext, slength)
wintext = Left(wintext, slength - 1)
msgbox wintext
end sub
code:
Can anyone please suggest me how can i get the name of the parent application of the active window. As of now it's only giving the name of the active window.
Please help me with this..... many thanks in advance.
Regards,
Premanshu.