Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== AutoHotKey ====== AutoHotkey is a Windows programs that provides GUI and Keystroke automation and scripting. Download: http://www.autohotkey.com/ AHK script is the scripting language used to write automation script and key mapping. The default configuration file for AutoHotKey is under <code>%userprofile%\Documents\AutoHotKey.ahk</code> AHKscript online reference: http://www.autohotkey.com/docs/ * additional ref: http://www.jeffjade.com/2016/03/11/2016-03-11-autohotkey/ ====== My Common AHK scripts ====== ===== Just remap key ===== * remap key and some example <code ahk>F3::Send {numpad0} 0::Send o ^0::Send O </code> ===== application shortcut key re-map ===== * firefox <code>#IfWinActive ahk_class MozillaUIWindowClass ^+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::SendInput, whatapc{Enter} Return #IfWinActive </code> * command <code>#IfWinActive ahk_class ConsoleWindowClass ^V:: SendInput {Raw}%clipboard% return #IfWinActive </code> * notepad <code> ;===========notepad #IfWinActive ahk_class Notepad !MButton::Send {Enter} !Escape::Send {Enter} Return #IfWinActive </code> ===== Windows System GUI Automation Scripting ===== * access window menu item<code>; //demo of click XnView application, Tools menu, Set as Wallpaper sub menu, 3rd item #IfWinActive ahk_class XmainClass F4::WinMenuSelectItem, XnView, , Tools, Set as Wallpaper, 3& Return #IfWinActive </code> * window toggle AlwaysOnTop (works on win10 as well) (ref: https://www.groovypost.com/howto/howto/windows-programs-always-on-top/) <code> ^SPACE:: Winset, Alwaysontop, , A </code> * window toggle maximize <code> ;===window toggle maximize #s:: WinGet MX, MinMax, A If MX WinRestore A Else WinMaximize A return </code> * window resize <code>;=============base function of resize ResizeWin(Width = 0,Height = 0) { WinGetPos,X,Y,W,H,A If %Width% = 0 Width := W If %Height% = 0 Height := H WinMove,A,,%X%,%Y%,%Width%,%Height% } PoseWin(locx = 0,locy = 0) { WinGetPos,X,Y,W,H,A If %locx% = 0 locx := X If %locy% = 0 locy := Y WinMove,A,,%locx%,%locy%,%W%,%H% } #F1::ResizeWin(1024,768) #F2::ResizeWin(800,600) #F3::ResizeWin(640,480) #F4::PoseWin(1,1) </code> * move window with left-mouse-button drag while holding Windows key <code> ;----------------move tool 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 </code> devwiki/autohotkey.txt Last modified: 2021/12/11 19:16by ying