Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | devwiki:autohotkey [2021/12/11 19:16] (current) – [Windows System GUI Automation Scripting] ying | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== AutoHotKey ====== | ||
+ | |||
+ | AutoHotkey is a Windows programs that provides GUI and Keystroke automation and scripting. | ||
+ | |||
+ | Download: http:// | ||
+ | |||
+ | AHK script is the scripting language used to write automation script and key mapping. | ||
+ | |||
+ | The default configuration file for AutoHotKey is under < | ||
+ | |||
+ | AHKscript online reference: http:// | ||
+ | * additional ref: http:// | ||
+ | |||
+ | ====== My Common AHK scripts ====== | ||
+ | ===== Just remap key ===== | ||
+ | * remap key and some example <code ahk> | ||
+ | 0::Send o | ||
+ | ^0::Send O | ||
+ | </ | ||
+ | |||
+ | ===== application shortcut key re-map ===== | ||
+ | |||
+ | * firefox < | ||
+ | ^+z::Send ^j ; dowload list | ||
+ | !t::Send ^t ; Open a new tab | ||
+ | !r::Send ^r ; Reload the page | ||
+ | !w::Send ^w ; Close the tab | ||
+ | !q::Send ^+b ; bookmark | ||
+ | !c::Send ^+{Del} ; clean history | ||
+ | F2:: | ||
+ | Return | ||
+ | # | ||
+ | </ | ||
+ | * command < | ||
+ | ^V:: | ||
+ | SendInput {Raw}%clipboard% | ||
+ | return | ||
+ | # | ||
+ | </ | ||
+ | * notepad < | ||
+ | ; | ||
+ | # | ||
+ | !MButton:: | ||
+ | !Escape:: | ||
+ | Return | ||
+ | # | ||
+ | </ | ||
+ | ===== Windows System GUI Automation Scripting ===== | ||
+ | |||
+ | * access window menu item< | ||
+ | # | ||
+ | F4:: | ||
+ | Return | ||
+ | # | ||
+ | </ | ||
+ | * window toggle AlwaysOnTop (works on win10 as well) (ref: https:// | ||
+ | ^SPACE:: | ||
+ | </ | ||
+ | * window toggle maximize < | ||
+ | ;===window toggle maximize | ||
+ | #s:: | ||
+ | WinGet MX, MinMax, A | ||
+ | If MX | ||
+ | WinRestore A | ||
+ | Else WinMaximize A | ||
+ | return | ||
+ | </ | ||
+ | * window resize < | ||
+ | ResizeWin(Width = 0,Height = 0) | ||
+ | { | ||
+ | WinGetPos, | ||
+ | If %Width% = 0 | ||
+ | Width := W | ||
+ | |||
+ | If %Height% = 0 | ||
+ | Height := H | ||
+ | |||
+ | WinMove, | ||
+ | } | ||
+ | PoseWin(locx = 0,locy = 0) | ||
+ | { | ||
+ | WinGetPos, | ||
+ | If %locx% = 0 | ||
+ | locx := X | ||
+ | |||
+ | If %locy% = 0 | ||
+ | locy := Y | ||
+ | |||
+ | WinMove, | ||
+ | } | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | </ | ||
+ | * move window with left-mouse-button drag while holding Windows key < | ||
+ | ; | ||
+ | LWIN & !LButton:: | ||
+ | |||
+ | CoordMode, Mouse ; Switch to screen/ | ||
+ | MouseGetPos, | ||
+ | WinGetPos, EWD_OriginalPosX, | ||
+ | WinGet, EWD_WinState, | ||
+ | if EWD_WinState = 0 ; Only if the window isn't maximized | ||
+ | SetTimer, EWD_WatchMouse, | ||
+ | return | ||
+ | |||
+ | EWD_WatchMouse: | ||
+ | GetKeyState, | ||
+ | if EWD_LButtonState = U ; Button has been released, so drag is complete. | ||
+ | { | ||
+ | SetTimer, EWD_WatchMouse, | ||
+ | return | ||
+ | } | ||
+ | GetKeyState, | ||
+ | if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled. | ||
+ | { | ||
+ | SetTimer, EWD_WatchMouse, | ||
+ | WinMove, ahk_id %EWD_MouseWin%,, | ||
+ | return | ||
+ | } | ||
+ | ; Otherwise, reposition the window to match the change in mouse coordinates | ||
+ | ; caused by the user having dragged the mouse: | ||
+ | CoordMode, Mouse | ||
+ | MouseGetPos, | ||
+ | WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin% | ||
+ | SetWinDelay, | ||
+ | WinMove, ahk_id %EWD_MouseWin%,, | ||
+ | EWD_MouseStartX := EWD_MouseX | ||
+ | EWD_MouseStartY := EWD_MouseY | ||
+ | return | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||