How can I retrieve information about the last accessed window (ahk_id, ClassNN)?
Current active window: ahk_id Current_Win
Currently active ClassNN of currently active window: Current_WinNN
Last active window: ahk_id Last_Win
Last active ClassNN of the last active window: Last_WinNN
How to retrieve last activated ahk_id & ClassNN Topic is solved
Re: How to retrieve last activated ahk_id & ClassNN
There are plenty of examples of RegisterShellHookWindow which you can use to detect changes of the active window. You can use that as a trigger to set ahk_id Current_Win and move the old value to ahk_id Last_Win.
ClassNN belongs to a control and not a window, or do you mean ahk_class?
ClassNN belongs to a control and not a window, or do you mean ahk_class?
Re: How to retrieve last activated ahk_id & ClassNN
From googling it, RegisterShellHookWindow seems to be some MSDN stuff, which I am not familiar with.Nextron wrote:There are plenty of examples of RegisterShellHookWindow which you can use to detect changes of the active window. You can use that as a trigger to set ahk_id Current_Win and move the old value to ahk_id Last_Win.
ClassNN belongs to a control and not a window, or do you mean ahk_class?
Is there another way of achieving the same goal without MSDN?
And yes, the last accessed ClassNN is what I want.
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: How to retrieve last activated ahk_id & ClassNN Topic is solved
Or this:
Code: Select all
#Persistent
SetTimer last_accessed_windows, 300
return
last_accessed_windows:
WinGet, CurrentActive_ID, ID, A
If (CurrentActive_ID = NewActive_ID)
ControlGetFocus, LastFocusedControl, A
else
{
LastActive_ID = %NewActive_ID%
NewActive_ID := CurrentActive_ID
WinGetTitle, NewActiveTitle, ahk_id %NewActive_ID%
WinGetTitle, LastActiveTitle, ahk_id %LastActive_ID%
ControlGetFocus, NewFocusedControl, A
CoordMode, ToolTip, Screen
ToolTip, Current active window:`nTitle: %NewActiveTitle%`nLast Focused Control: %NewFocusedControl%`nID: %NewActive_ID%`n`nLast active window:`nTitle: %LastActiveTitle%`nLast Focused Control: %LastFocusedControl%`nID: %LastActive_ID%, 0, 0
}
return
Re: How to retrieve last activated ahk_id & ClassNN
Exactly what I wanted. Thank you GEV.
- Blackholyman
- Posts: 1293
- Joined: 29 Sep 2013, 22:57
- Location: Denmark
- Contact:
Re: How to retrieve last activated ahk_id & ClassNN
Code: Select all
Gui +LastFound
DllCall( "RegisterShellHookWindow", UInt, WinExist() )
OnMessage( DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" ), "ShellMessage" )
global LastActiveWindowID := WinActive("A")
Return ; // End of Auto-Execute Section //
ShellMessage( wParam, lParam ) {
If ( wParam = 4 And WinExist( "ahk_id " lParam ) ) { ; HSHELL_WINDOWACTIVATED = 4
WinGetTitle, LastActiveTitle, ahk_id %LastActiveWindowID%
WinGetTitle, NewActiveTitle, % "ahk_id " LastActiveWindowID := lParam
ToolTip, Current active window:`nTitle: %NewActiveTitle%`n`nLast active window:`nTitle: %LastActiveTitle%, 0, 0
}
}
Courses on AutoHotkey
My Autohotkey Blog
Who is online
Users browsing this forum: mikeyww and 145 guests