====== 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 %userprofile%\Documents\AutoHotKey.ahk 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 F3::Send {numpad0} 0::Send o ^0::Send O ===== application shortcut key re-map ===== * firefox #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 * command #IfWinActive ahk_class ConsoleWindowClass ^V:: SendInput {Raw}%clipboard% return #IfWinActive * notepad ;===========notepad #IfWinActive ahk_class Notepad !MButton::Send {Enter} !Escape::Send {Enter} Return #IfWinActive ===== Windows System GUI Automation Scripting ===== * access window menu item; //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 * window toggle AlwaysOnTop (works on win10 as well) (ref: https://www.groovypost.com/howto/howto/windows-programs-always-on-top/) ^SPACE:: Winset, Alwaysontop, , A * window toggle maximize ;===window toggle maximize #s:: WinGet MX, MinMax, A If MX WinRestore A Else WinMaximize A return * window resize ;=============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) * move window with left-mouse-button drag while holding Windows key ;----------------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