Last active
November 4, 2022 23:04
-
-
Save stef-levesque/8927e17217fe2fd3e48d to your computer and use it in GitHub Desktop.
AutoHotKey useful scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; FIND IN GOOGLE | |
| LWIN & f:: | |
| Send, ^c | |
| Sleep 50 | |
| Run, http://www.google.com/search?q=%clipboard% | |
| return | |
| ; SAVE/RESTORE WINDOW SIZE & LOCATION | |
| ;LAlt & LShift & 1:: | |
| !+1:: | |
| WinGet, ID1, ID, A | |
| WinGetPos, X1, Y1, W1, H1, ahk_id %ID1% | |
| MsgBox, The active window %ID1% is at %X1%`,%Y1%-%W1%`,%H1% | |
| return | |
| ;LAlt & 1:: | |
| !1:: | |
| WinShow, ahk_id %ID1% | |
| WinMove, ahk_id %ID1%,, X1, Y1, W1, H1 | |
| return | |
| ; VIRTUAWIN SHORTCUTS | |
| LWIN & WheelDown:: Send, ^!{Down} | |
| LWIN & WheelUp:: Send, ^!{Up} | |
| ; TOGGLE WINDOW MAXIMIZE-RESTORE | |
| LWIN & XButton1:: | |
| MouseGetPos,,,EWD_MouseWin | |
| WinRestore, ahk_id %EWD_MouseWin% | |
| return | |
| LWIN & XButton2:: | |
| MouseGetPos,,,EWD_MouseWin | |
| WinMaximize, ahk_id %EWD_MouseWin% | |
| return | |
| ; TOGGLE TITLE BAR | |
| LWIN & RButton:: | |
| MouseGetPos,,,EWD_MouseWin | |
| WinGet, Style, Style, ahk_id %EWD_MouseWin% ; A for active window | |
| if (Style & 0xC00000) | |
| WinSet, Style, -0xC00000, ahk_id %EWD_MouseWin% | |
| else | |
| WinSet, Style, +0xC00000, ahk_id %EWD_MouseWin% | |
| return | |
| ; CLOSE WINDOW | |
| LWIN & MButton:: | |
| MouseGetPos,,,EWD_MouseWin | |
| WinKill, ahk_id %EWD_MouseWin% ; A for active window | |
| return | |
| ; MOVE WINDOW | |
| LWIN & LButton:: | |
| CoordMode, Mouse ; Switch to screen/absolute coordinates. | |
| MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin | |
| WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin% | |
| WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin% | |
| if EWD_WinState = 0 ; Only if the window isn't maximized | |
| SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it. | |
| return | |
| EWD_WatchMouse: | |
| GetKeyState, EWD_LButtonState, LButton, P | |
| if EWD_LButtonState = U ; Button has been released, so drag is complete. | |
| { | |
| SetTimer, EWD_WatchMouse, off | |
| return | |
| } | |
| GetKeyState, EWD_EscapeState, Escape, P | |
| if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled. | |
| { | |
| SetTimer, EWD_WatchMouse, off | |
| WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY% | |
| return | |
| } | |
| ; Otherwise, reposition the window to match the change in mouse coordinates | |
| ; caused by the user having dragged the mouse: | |
| CoordMode, Mouse | |
| MouseGetPos, EWD_MouseX, EWD_MouseY | |
| WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin% | |
| SetWinDelay, -1 ; Makes the below move faster/smoother. | |
| WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY | |
| EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine. | |
| EWD_MouseStartY := EWD_MouseY | |
| return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment