Advertisement
Lorenzo501

Left-Click App In Taskbar Opens Latest Active Window.ahk

Oct 25th, 2024 (edited)
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     This works only on Windows 11 (it's not the latest active wnd on Windows 10).
  3.  */
  4. #Requires AutoHotkey 2.0
  5. #NoTrayIcon
  6. A_KeyDelay := -1 ; For Send b/c it reverts to the Event SendMode when another AHK script installs a native low-level keyboard hook
  7.  
  8. ; https://www.autohotkey.com/docs/v2/misc/RegEx-QuickRef.htm (Regular Expressions [RegEx] - Quick Reference)
  9. ; ClassNN argument consists of three classes seperated by the | (OR) symbol, the first two for W11 and the third one for W10 (can be seen by using WinSpy++ on the app section in taskbar)
  10. #HotIf MouseIsOverControl("ahk_class Shell_TrayWnd", "iS)\QWindows.UI.Composition.DesktopWindowContentBridge1\E|MSTaskSwWClass1|MSTaskListWClass")
  11. ~*LButton::Send("{Blind+!#}{Ctrl down}"), KeyWait("LButton"), Send("{Blind+!#}{Ctrl up}")
  12.  
  13. MouseIsOverControl(winTitle, classNN)
  14. {
  15.     try return (MouseGetPos(,, &winId, &control), WinExist(winTitle " ahk_id " winId) && control ~= classNN)
  16.     return false
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement