Autohotkey Is So Useful

Autohotkey is mind bogglingly useful! Autohotkey is a free, open source Windows program that lets you do simple and complicated scripting with keyboard commands. I’ve been using it since about 2001. I use it a zillion times a day. I couldn’t imagine not having it.

Some things you can do with it:
– Have a second copy-paste clipboard
– Do a “paste” and strip out the formatting
– type often used strings like addresses, phone numbers, and email signatures with just a few strokes.
– make a window on your computer to be always on top of the other windows
– start a favorite program (Chrome, Word, Calc, whatever) with a single keystroke
– Type today’s date with a single keystroke

I’ve set it up to do about 50 commands. If you want to do things on the computer faster and easier, you might want to use it too. Just download Autohotkey¬†and put some of the scripts I have below in your setting file. There’s a bunch of ways to do that, here is a tutorial.

Here is my settings file. Just look at the first line of each script to see what it does.


; See the docs at the end of this file.

^!i:: ; Run IEP Calendar with Ctrl-Alt-i
IfWinExist, IEP Calendar.xlsx
WinActivate
else
Run, “C:\aaa\OT Work\IEP Calendar.xlsx”
return

^!s:: ; Run Scratch with Ctrl-Alt-s
IfWinExist, Scratch.docx
WinActivate
else
Run, “C:\aaa\OT Work\Scratch.docx”
return

; Ctrl-Alt-v to paste text only; the formatted version remains in clipboard.
^!v:: ; paste stripping formatting via https://autohotkey.com/board/topic/10412-paste-plain-text-and-copycut/
; remove white space and new line marks and that avoids “pasting” because that can trigger unnecessary paste options in Microsoft
gosub getplain
clipboard:=clipboardt ; This works and does so quickly as long as “Ctrl-v” is used to paste
Send ^v
; Send {Raw}%clipboardt% ; This works but it’s slow
; SendInput {Raw}%clipboardt% ; This SHOULD work but it fucks shit up
clipboardt =
return

getplain:
StringReplace, clipboardt, clipboard, `r, %A_Space%, All ; The `r strips out carriage return, `n strips out newlines.
clipboardt := RegExReplace(clipboardt, “` {2,}”, “` “)
StringLeft, 1st, clipboardt, 1
IfInString, 1st, %A_Space%
StringTrimLeft, clipboardt, clipboardt, 1
StringRIght, last, clipboardt, 1
IfInString, last, %A_Space%
StringTrimRight, clipboardt, clipboardt, 1
return

; copy selected text to AutohotkeyClipboard
^!n:: ;Ctrl-Alt-n copy selected text to AutohotkeyClipboard
originalclipboardcontents = %clipboardall%
clipboard = ; Start off empty to allow ClipWait to detect when the text has arrived
Send ^c
clipwait ; wait for the clipboard to contain text
autohotkeyclipboard = %clipboard% ; Grab it, strip it, and shove it
clipboard = %originalclipboardcontents% ; Restore original clipboard contents
; originalclipboardcontents = ; Free up memory
Return

; paste text out of the AutohotkeyClipboard
^!m:: ;Ctrl-Alt-m to paste from memory
Send %autohotkeyclipboard%{space}
Return

; hit ctrl-space to make the current window always on top. From http://www.labnol.org/software/tutorials/keep-window-always-on-top/5213/
^SPACE:: Winset, Alwaysontop, , A

^!d:: ; Run Chrome with Ctrl-Alt-d
IfWinExist, New Tab – Google Chrome ; If there is already a blank window, bring it to front.
{
WinActivate, New Tab – Google Chrome
ControlFocus, Chrome_OmniboxView1
}
else
{
Run, chrome
; Run, “C:\Program Files\Google\Chrome\Application\chrome.exe”
; WinWaitActive, New Tab – Google Chrome, , 3 ; wait for for Chrome to open
;if ErrorLevel ; if Chrome doesn’t open within the timeframe, throw an error on the desktop
; {
; ; MsgBox, Chrome WinWait timed out.
; TrayTip, Autohotkey, Chrome WinWait timed out, 5
; WinActivate, New Tab – Google Chrome ; activate the chrome window
; return
; }
Loop 10 ; Let’s try pulling it up 10 times (Loop 10) waiting .2 seconds (sleep 200) to check and pull it up
{
Sleep, 200 ; maybe this will help guarantee that it catches????????
; SoundPlay *-1
IfWinExist, New Tab – Google Chrome ; If there is already a blank window, bring it to front.
{
WinActivate, New Tab – Google Chrome
ControlFocus, Chrome_OmniboxView1
}
}
}
return

; This script opens my favorite text editor. If it’s already open, it pulls it to the front. I use this a zillion times a day
; I made it Ctrl-Alt-e because it used to start Editpad… My fingers remember the “e” better than the “s”. Change it to whatever you like.
^!e:: ; Run SublimeText++ with Ctrl-Alt-e
IfWinExist, sublime_text.exe
WinActivate
else
Run, “C:\Program Files\Sublime Text 3\sublime_text.exe”
return

; Start up my favorite calculator
^!c:: ; Run Calc with Ctrl-Alt-c
IfWinExist, Moffsoft FreeCalc
WinActivate
else
Run, “C:\Program Files (x86)\Moffsoft FreeCalc\MoffFreeCalc.exe”
return

^!t:: ; Run Truecrypt with Ctrl-Alt-t
IfWinExist, TrueCrypt
WinActivate
else
Run, “C:\aaa\pocketpc.tc”
return

^!k:: ; Open Truecrypt k: with Ctrl-Alt-k
SetTitleMatchMode, 2 ; allow partial matches for WinExist

If WinExist(“K:\”,”Namespace Tree Control”) or WinExist(“&crumb=location:K%3A”)
{
WinActivate
ControlFocus, DirectUIHWND1
}
else
{
Run, explorer K:\
ControlFocus, DirectUIHWND1
}
return

; I have a lot of “..” codes. Just type “.. and whatever” and the text appears.
; type “..sig” and my signature appears
:o:..sig::Thanks,{enter}Lee Sonko, OTR/L{enter}Occupational Therapist{enter}

:o:..ot::occupational therapist
:o:..pot::pediatric occupational therapist

:o:..b::Berkeley
:o:..bc::Berkeley, CA
:o:..9::94706

:o:..s::San Francisco
:o:..c:: California

:0:..80::123456789012345678901234567890123456 >40< 3456789012345678901234567890123456 >80{enter}

:o:..-::{enter}————————————————–{up}

:o:..=::=================================================={Right}

; Here’s some old school message quoting. I don’t use this often. Try “..<” when you are at the top of some text you want to do message quoting to. ; :o:.>::{Home}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}>{left}{down}{Enter}

:o:.<::{Home}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}>{Right 76}{ctrl left}{Enter}

; More message quoting. Try “..>” then hit enter, then type a number from 1 to 99 and hit enter again
:o:.>:: ; Perform message quoting… Give it 1-99 and it’ll quote that many lines.
Input,variable,L2,{Enter}
SetKeyDelay 0
BlockInput,on
Send {Home}
Loop, %variable%
{
Send >{Right 78}{ctrldown}{left}{ctrlup}{Enter}
}
BlockInput,off

:o:.p::——– Page Break ————-{enter}

:o:.ms::——– Original Message ————-{enter}

:o:.me::——– End of Original Message ——{enter}

:o:.ss::—- Start of Snippet —-{home}{down}

:o:.se::—- End of Snippet —-{enter}

:o:..d:: ; current date
FormatTime, CurrentDateTime,, M-d-yy ; It will look like 9-1-17
SetKeyDelay 0 ; This sets the keystrokes below to be sent faster than the default.
Send %CurrentDateTime%
Send {space}{enter}————————————————–{up}
return

:o:..date:: ; This hotstring replaces “]d” with the current date and time.
FormatTime, CurrentDateTime,, M/d/yyyy h:mm tt ; It will look like 9/1/2005 3:53 PM
SetKeyDelay 0 ; This sets the keystrokes below to be sent faster than the default.
Send %CurrentDateTime%
return

; —————————————————————————————————–
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments. They are not executed.

; This script is a .INI file because it is a special script that is
; automatically launched when you run the program directly. By contrast,
; text files that end in .ahk are associated with the program, which
; means that they can be launched simply by double-clicking them.
; You can have as many .ahk files as you want, located in any folder.
; You can also run more than one .ahk file simultaneously and each will
; get its own tray icon.

; Please read the QUICK-START TUTORIAL near the top of the help file.
; It explains how to perform common automation tasks such as sending
; keystrokes and mouse clicks. It also explains how to use hotkeys.

; SAMPLE HOTKEYS: Below are two sample hotkeys. The first is Win+Z and it
; launches a web site in the default browser. The second is Control+Alt+N
; and it launches a new Notepad window (or activates an existing one). To
; try out these hotkeys, run AutoHotkey again, which will load this file.

; Find Hotstring documentation here: http://www.autohotkey.com/docs/Hotstrings.htm

 

One Comment

  1. lee says:

    I just updated the “paste stripping formatting” and “second clipboard” scripts to work faster and more reliably.

Leave a Comment

Do not write "http://" in your comment, it will be blocked. It may take a few days for me to manually approve your first comment.

You can edit your comment after submitting it.