congdantoancau

Capslock Windows Switcher [OLD]

May 21st, 2020
3,078
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* CAPSLOCK WINDOWS SWITCHER
  2. * Notice that this will let your left mouse can not drag.
  3. * Do it by hold the alt button down then click once to start, click twice to stop dragging
  4. * Or delete the LButton function but live with your own lack of full function
  5. */
  6. ; initial variables
  7. lastwin := ""
  8.  
  9. ; Hold mouse | Free hand Click and Drag
  10. ; https://autohotkey.com/board/topic/95066-minecraft-hold-left-mouse-button/
  11. !LButton:: Send % "{Click " . ( GetKeyState("LButton") ? "Up}" : "Down}" )
  12.  
  13. $LButton::
  14.     ; for WINDOWS SWITCHER FUNCTION
  15.     CoordMode, Mouse, Screen
  16.     MouseGetPos, x, y
  17.     if (x > 40 && x < A_ScreenWidth / 2 + 200 && y > A_ScreenHeight - 40) {
  18.         ; click on the programs on the taskbar area (height: 40px)
  19.         WinGetTitle, lastwin, a
  20.         Sleep 10
  21.     }
  22.     send {Lbutton}
  23. return
  24.  
  25. CapsLock::
  26.     if (lastwin) {
  27.         WinGetTitle, thiswin, a
  28.         Sleep 100
  29.         if (thiswin == lastwin) {
  30.             send !{esc}
  31.         }
  32.         else {
  33.             ; TrayTip, ,%lastwin%
  34.             WinGetTitle, thiswin, a
  35.             Sleep 10
  36.             WinActivate, %lastwin%
  37.             lastwin := thiswin
  38.         }
  39.     } else {
  40.         WinGetTitle, lastwin, a
  41.         send !{esc}
  42.     }
  43. return
RAW Paste Data