What AutoHotkey [1] scripts have you found that proved to be extremely useful?
I'll share one that I am using for multiple monitors.
Windows + Right: Move window from the left monitor to the right monitor
#right::
WinGet, mm, MinMax, A
WinRestore, A
WinGetPos, X, Y,,,A
WinMove, A,, X+A_ScreenWidth, Y
if(mm = 1){
WinMaximize, A
}
return
Windows + Left: Move window from the right monitor to the left monitor
#left::
WinGet, mm, MinMax, A
WinRestore, A
WinGetPos, X, Y,,,A
WinMove, A,, X-A_ScreenWidth, Y
if(mm = 1){
WinMaximize, A
}
return
Middle mouse button in combination with mouse wheel scrolling activates Alt-Tab
(down) and Shift-Alt-Tab
(up):
~MButton & WheelDown::AltTab
~MButton & WheelUp::ShiftAltTab
Replace Printscreen button with Vista/Windows7 snipping tool
PRINTSCREEN::
Run snippingtool
return
This does what it says on the tin, uses the Windows snipping tool instead of bog standard print screen.
Find more info on snipping tool here: snipping tool info at lifehacker [1]
update: Just a little FYI incase anyone else needs to capture multiple pages in one go...
I must admit that I now use Ducklink screen capture software now ( ducklink [2]) because it does capturing of 'scrolling windows' which I find useful. It's free, and it has a keyboard shortcut option, so I have print screen mapped to capture a region with the software instead of the snipping tool/AHK solution.
[1] http://lifehacker.com/228885/windows-vista-tip--take-screenshots-with-the-snipping-toolWindowPad [1]
A tool much like WinSplit Revolution, but based on Autohotkey. Works a lot better than WinSplit for me.
[1] http://www.autohotkey.com/forum/topic21703.htmlPoor man's SnagIt. Screen capture utility (puts current window screenshot into Paint for editing).
#p::
Send !{PrintScreen}
Run, mspaint.exe
WinWaitActive, untitled - Paint
{
Send ^v
}
return
Clipboard enhancements
; Append to clipboard (cut)
^+x::
clipboardBefore = %clipboard%
Send ^x
ClipWait, 2
clipboard = %clipboardBefore% %clipboard%
return
; Append to clipboard (copy)
^+c::
clipboardBefore = %clipboard%
Send ^c
ClipWait, 2
clipboard = %clipboardBefore% %clipboard%
return
; Paste as plain text
^+v::
ClipSaved := ClipboardAll ; Save the entire clipboard to a variable of your choice.
clipboard = %clipboard% ; Convert any copied files, HTML, or other formatted text to plain text.
ClipWait, 2
Send ^v
Sleep, 1000
Clipboard := ClipSaved ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved = ; Free the memory in case the clipboard was very large.
return
Boss Button [1] (hides distracting programs, restores work related ones)
#z::
SoundSet, 0
Process, Close, pidgin.exe
WinMinimize, iTunes
SetTitleMatchMode 2
WinMinimize, Mozilla Firefox
WinMinimize, - Windows Internet Explorer
WinMaximize, - Microsoft Visual Studio
WinRestore, SourceSafe
return
Make active window transparent so you can look through it while the keys are held down
; Transparent
^!Space::WinSet, Transparent, 125, A
^!Space UP::WinSet, Transparent, OFF, A
Disable Caps Lock unless you press CTRL
Capslock::Ctrl
+Capslock::Capslock
Auto-reloads the running AutoHotkey script when you save it in an editor with CTRL-
~^s::
SetTitleMatchMode 2
IfWinActive, .ahk
{
Sleep, 1000
ToolTip, Reloading...
Sleep, 500
Reload
}
return
[1] http://kenrockwell.com/business/two-hour-rule.htmToggle the active window topmost status (always on top):
^+t::
WinSet, AlwaysOnTop, Toggle,A
return
This script does a google search on the selected text. The selection can be made in almost any application. It works by issuing a ctrl+C keypress, and then formatting the Google search URL from the clipboard. I admit it seems kind of patchy, but it works very well for me.
GetSelectedText()
{
tmp = %ClipboardAll% ; save clipboard
Clipboard := "" ; clear
Send, ^c ; simulate Ctrl+C (=selection in clipboard)
selection = %Clipboard% ; save the content of the clipboard
Clipboard = %tmp% ; restore old content of the clipboard
return selection
}
CapsLock & g::
selection := GetSelectedText()
browser := GetBrowser()
if selection <>
Run, %browser% "http://www.google.com/search?q=%selection%"
else
Run, %browser% "http://www.google.com/"
return
Note: the GetBrowser() function should return the full file path of your browser application.
Any combination that disables the most annoying key in the keyboard ( caps lock [1]). Depending on your preferences it can be used to aid you in almost anything. In my case I decided to assign leftAlt+shift to it which is used to switch between languages for the keyboard (I am greek).
So :
SetCapsLockState, AlwaysOff
Capslock::Send {LAlt Down}{Shift}{LAlt Up}
return
[1] http://en.wikipedia.org/wiki/Caps%5Flockctrl+` to toggle a secondary display:
^`::EnableDisplayDevice("\.\DISPLAY2", -1) ; toggle secondary
Invaluable when you have a second monitor, but do gaming and want to flip it on and off without going into Windows Display Settings.
(You'll need the EnableDisplayDevice and EnumDisplayDevice scripts from a thread [1] on the AutoHotkey Community Forum.)
[1] http://www.autohotkey.com/forum/topic21800.htmlThe Input function is very powerful and allows creation of key "chords" similar to visual studio.
This example allows you to type CTRL ~ Followed by any 2 arbitrary characters. You can then perform any action based on the 2 characters entered.
^`::
Input, TextEntry1, L1,{Esc}{Enter}{F1}{Down}{Up}
endKey=%ErrorLevel%
Input, TextEntry2, L1 T1,{Esc}{Enter}
timeout=%ErrorLevel%
entry=%TextEntry1%%TextEntry2%
if entry=cp
{
; Command prompt
run cmd
}
else if entry=ca
{
; Calculator
run calc
}
else if entry=ou
{
; Outlook
SetTitleMatchMode 2
IfWinExist, Microsoft Outlook
{
WinActivate
}
else
{
run outlook
}
SetTitleMatchMode 1
}
return
Google selected text
Select text in any app (that supports 'Ctrl+c' to copy) and Win+s will Google it...
#s:: MyClip := ClipboardAll clipboard = ; empty the clipboard Send, ^c ClipWait Run http://www.google.com/#hl=en&q;=%clipboard% Clipboard := MyClip
I've been using AutoCorrect.ahk for a while now. ( Here's [1] the most recent version.) It is basically a list of hotstrings for replacing common misspellings with the corrected version, based on a large list of common misspellings. For example,
::teh::the
::wiht::with
I love it, as I spell poorly. You can add your own to the list using a Win-H while the misspelled word is selected.
[1] http://www.autohotkey.com/download/AutoCorrect.ahk::Mohm::MΩ
? - endolith
Run a program or focus it, if it's already running.
I've been using this AutoHotkey function for a couple of years. It's like a generalized version of Phoshi's FireFox script.
; Function to run a program or activate an already running instance
RunOrActivateProgram(Program, WorkingDir="", WindowSize=""){
SplitPath Program, ExeFile
Process, Exist, %ExeFile%
PID = %ErrorLevel%
if (PID = 0) {
Run, %Program%, %WorkingDir%, %WindowSize%
}else{
WinActivate, ahk_pid %PID%
}
}
Some example key bindings using the function:
; Start programs using AltGr + some key
^!d::RunOrActivateProgram("cmd.exe", UserProfile)
^!g::RunOrActivateProgram("C:\Program Files\VMware\VMware Workstation\vmware.exe")
^!i::RunOrActivateProgram("c:\Program Files\Internet Explorer\iexplore.exe")
^!l::RunOrActivateProgram("C:\Windows\System32\calc.exe")
^!o::RunOrActivateProgram("C:\Program Files\Opera\Opera.exe")
^!p::RunOrActivateProgram("C:\Program Files\Cisco Systems\VPN Client\ipsecdialer.exe")
^!u::RunOrActivateProgram("c:\Program Files\UltraEdit\uedit32.exe")
^!w::RunOrActivateProgram("C:\Program Files\TotalCMD\TOTALCMD.EXE", "", "Max")
^!x::RunOrActivateProgram("c:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE")
I mix these shortcuts with direct calls to Run, for programs I want to have multiple instances of, e.g.:
^!r::Run "c:\windows\System32\mstsc.exe", UserProfile
^!t::Run, c:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE
Poor-man's insta-calc:
^!c::
ClipSave := ClipboardAll
Send ^x
Run calc.exe
WinWaitActive Calculator
Send ^v
Send {Enter}
Sleep 250
Send ^c
WinClose
Send ^v
Clipboard := ClipSave
return
Highlight a math operation, then press Ctrl+Alt+C. It will open a calculator and paste the equation in there, copy the result, and paste it into whatever app you were in before.
My most used is probably:
Capslock::
SetTitleMatchMode, 2
IfWinExist, Mozilla Firefox
{
IfWinActive, Mozilla Firefox
{
Send ^t
Send !d
sleep, 100
Send ^a
}
WinActivate
WinWaitActive
}
else
Run %programfiles%\Mozilla Firefox 3.1 Beta 3\firefox.exe
return
+Capslock::Capslock
Opens FF if it's closed, focuses it if it's not, and opens a new tab and focuses the location bar if it is, all on capslock.
Opening that to copypaste, though, I used:
#^F5::Edit
to open the script,
XButton1::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500)
{
Send ^c
}
Return
XButton2::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500)
{
Send ^v
}
Return
to copypaste the script, and
XButton1 & LButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return
EWD_WatchMouse:
GetKeyState, EWD_RButtonState, LButton, P
if EWD_RButtonState = 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
(not my script, 'songsoverruins's script) to move the window over to my other monitor quickly so I could see FF, and I'm about to
XButton1 & RButton::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500)
{
send {LButton}
WinClose, A
}
return
to close the window. I also use min/max on mouse1 and scrollwheel, but I've gone on long enough. Suffice to say AHK is an integral part of my workflow, and an absolutely bloody brilliant tool.
Reload the current Autohotkey script currently being edited in Notepad++. Use a single key press instead of having to right click on the tray icon and select "Reload this script".
Could be altered to work with other editors as long as the full filename can be shown in the title bar of the editor.
; CTRL ALT R
^!r::
SetTitleMatchMode 2
IfWinActive - Notepad++
{
WinGetTitle, filePath,A
StringReplace, filePath,filePath,- Notepad++,
StringReplace, filePath,filePath,*,
Progress, B2 zh0 fs11 WS900 W700 H28, Reloading: "%filePath%"
Sleep,1000
filePath = "%filePath%"
Run, AutoHotkey.exe /restart %filePath%
Progress, Off
}
SetTitleMatchMode 1
return
I use the Dvorak keyboard, which has the annoying flaw of moving the Cut, Copy, and Paste keys from their handy location on the standard keyboard (the Ctrl+ X, C and V keys).
So I use AutoHotKey to map them back:
^j::^c
^k::^v
^q::^x
SciTE4AutoHotkey [1] is not a script per se, but helps a lot with editing.
[1] http://www.autohotkey.com/forum/topic41503.html$#WheelUp::send #{NumpadAdd}
$#WheelDown::send #{NumpadSub}
So with Windows 7 Magnifier, you can use Windows Key and Mousewheel to zoom in and out. Like they should have done from the beginning.
This script auto indents brackets (braces in the us) ({), closes it and leaves you in the middle so you can type (in Notepad++, but it can be tweaked for other editors) only if a termination character is used afterwards.
It uses EndChars, otherwise it doesn't work ( { } are an ending characters)
#Hotstring EndChars -()[]:;'"/\,.?!`n `t
:?O:{::{{}`n`n{}}{up}`t{end}
!^r::
reload
return
should be more refined with the %programfiles% variable
#o::
;switch between outlook and thunderbird
Run, C:\Program Files\Microsoft Office\Office12\outlook.exe /c ipm.note
;Run, C:\program files\Mozilla Thunderbird\thunderbird.exe -compose,,min,
Quick access to commonly used programs/urls
#Numpad7::Run, firefox.exe https://mail.google.com
#Numpad8::Run, firefox.exe http://www.google.com/reader
http://www.autohotkey.com/forum/viewtopic.php?t=33353
Other frequent key sentences: email address, my city (very handy with flat hunting and google map searches), "Thanks, [my name]", ...
And this one will hotkey F12 as a calendar viewer (W7, maybe Vista)
**#InstallKeybdHook
#Persistent**
#HotkeyInterval,100
SetKeyDelay, -1
f12::
{
send, {lwin down}b{lwin up}
sleep 10
send, {left}
sleep 10
send, {enter}
Return
}
I find that I mistype the ".com" in URLs and they end up coming out as example.cm or example.ocm
I use the following hotstrings to autocorrect these mistypes.
:*?:.cm::.com
:*?:.ocm::.com
The asterisk in the string makes AutoHotkey perform the change instantly. The question mark ignores the fact that the .whatever is part of another word (the beginning of the URL in this case).