Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; CAPSLOCK WINDOWS SWITCHER
- ; Initial variables
- ; Can using just one variables (GLOBAL_WIN_STORED) for both of following two var instead
- ; but keep them separate will help to keep the code more clear
- WinStoreByKey :=
- WinStoreByMouse :=
- h_taskbar := 40 ; height of the taskbar
- w_spacetotray := 200 ; width count from the middle of the taskbar to the system tray
- ; value depend on if the system tray is full of program or not
- ; Left mouse button store the window id and be used when the Capslock is trigger
- ~LButton::
- CoordMode, Mouse, Screen
- MouseGetPos, x, y
- ; check if user clicked on the programs area on the taskbar
- if (x > h_taskbar && x < A_ScreenWidth / 2 + w_spacetotray && y > A_ScreenHeight - h_taskbar) {
- ; get and assign new win id as a lastwin
- ; and when the hot key is burned so it will go to this {lastwin}
- lastwin := WinStoreByKey
- WinGet, WinStoreByMouse, ID, a
- WinStoreByKey := WinStoreByMouse
- }
- return
- ; CapsLock switch to the last active window
- CapsLock::
- if (lastwin) { ; the lastwin is exist in the memory
- ; Store new windows id and check it before switch to the lastwin
- Winget, newwin, ID, a
- if (newwin == lastwin) { ; In the case last window was closed
- TrayTip, WinSwitcher, Last window is the same with this window.
- ; switch to the last window by available Windows hotkey
- send !{esc}
- }
- else { ; No problem with the new window id, so switch right away to the new win
- WinActivate, ahk_id %lastwin%
- ; assign the new win as a lastwin after switched window
- lastwin := newwin
- ; Get the new win id then send to mouse click action
- Winget, WinStoreByKey, ID, a
- }
- } else { ; there are no last window in the memory (this will work at the first time when the Script is trigged)
- ; get the new window id
- Winget, newwin, ID, a
- send !{esc}
- ; assign the new window id as a lastwin after switch to the new win
- lastwin := newwin
- }
- return
Add Comment
Please, Sign In to add comment