Advertisement
Lorenzo501
Feb 21st, 2025
1
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; this has not been tested, but might work (I'm trying an even better way for now, activating WorkerW and then GroupActivate to go back)
  2.  
  3. #HotIf (WinActive("ahk_exe notepad.exe") || WinActive("- Visual Studio Code ahk_class Chrome_WidgetWin_1"))
  4. ;MButton::WinActivate("ahk_class Progman")
  5. MButton::
  6. {
  7.     A_ControlDelay := -1 ; Changes only the control delay of the thread made for this specific hotkey
  8.     global lastActiveWnd := WinExist("A")
  9.     WinActivate("ahk_class Progman")
  10.     ControlClick("x0 y0", "ahk_class Progman",,,, "Pos")
  11.     HookEvent(EVENT_SYSTEM_FOREGROUND, HandleActivatedWindowTextEditorEvent)
  12.  
  13.     HandleActivatedWindowTextEditorEvent(hWinEventHook, event, hWnd, *)
  14.     {
  15.         try
  16.             if (!WinGetClass(hWnd) = "Progman" || !WinGetClass(hWnd) = "WorkerW")
  17.             {
  18.                 DllCall("UnhookWinEvent", "Ptr", hWinEventHook)
  19.                 global lastActiveWnd := unset
  20.             }
  21.     }
  22. }
  23.  
  24. ;#HotIf (WinActive("ahk_class WorkerW"))
  25. #HotIf (WinActive("ahk_class Progman"))
  26. MButton::try WinActivate(lastActiveWnd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement