topdeveloper1
asked on
Get the Info about last application activated
Hello all,
When my application gets activated then I want to know that which was the last activated window.
I’ve a module that helps me to find out when my application get active or deactive. Now I want to know the API or any method, which will be able to tell me about the last activated window (myapp or notepad or IE….)
After googling I found "The GetGUIThreadInfo function retrieves information about the active window, or a specified graphical user interface (GUI) thread” On http://vbnet.mvps.org/index.html?code/system/getguithreadinfo.htm.
But still I’m not getting the accurate solution. Please help me.
Thanks
When my application gets activated then I want to know that which was the last activated window.
I’ve a module that helps me to find out when my application get active or deactive. Now I want to know the API or any method, which will be able to tell me about the last activated window (myapp or notepad or IE….)
After googling I found "The GetGUIThreadInfo function retrieves information about the active window, or a specified graphical user interface (GUI) thread” On http://vbnet.mvps.org/index.html?code/system/getguithreadinfo.htm.
But still I’m not getting the accurate solution. Please help me.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for reply; this new project is working fine.
But there is a problem.
Ex- I create the exe of this project. Now I opened two instances of that exe.
Say app1 and app2.
Now suppose app1 is in active state and app2 is in deactivating state. When I switching from app1 to app2, then I want to know that which event occur first, de-active of app1 or active of app2.
Plz help me.
Regards
But there is a problem.
Ex- I create the exe of this project. Now I opened two instances of that exe.
Say app1 and app2.
Now suppose app1 is in active state and app2 is in deactivating state. When I switching from app1 to app2, then I want to know that which event occur first, de-active of app1 or active of app2.
Plz help me.
Regards
ASKER
please close the issue
Thanks
Thanks
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Function GetTaskName(ByVal wnd As Long) As String
Dim procid As Long
Dim bjWMIService, objprocess, colProcesses
On Error Resume Next
GetWindowThreadProcessId wnd, procid
Set objWMIService = GetObject("winmgmts:")
Set colProcesses = objWMIService.ExecQuery("S
For Each objprocess In colProcesses
If objprocess.Handle = procid Then
GetTaskName = objprocess.executablepath
Exit Function
End If
Next
End Function
...
.AddItem "active window hwnd:" & vbTab & gui.hwndactive
.AddItem " taskname = " & GetTaskName(gui.hwndactive
.AddItem " active window title:" & vbTab & GetActiveWindowTitle(gui.h