In this blog post, you'll find a couple of useful AutoHotkey scripts to inspire, simplify and improve your daily tasks. It assumes you are already familiar with AutoHotkey. If not, then there are plenty of tutorials available on the internet, including an official one: AutoHotkey Beginner Tutorial.
Notice: AutoHotkey is only available for Windows OS.
Useful One-Liners
Let's start with easiest scripts that fit in one-line. My favourites in this list are "Hassle-free Re-mappings" because they allow to use a mouse and always have your left hand sit on top of AWSD keys. Other ones are also can be pretty useful when you have to navigate to a particular folder.
Open AppData/Roaming folder:
^#a::Run, %A_AppData%
Open AppData/Local folder:
^+#a::Run % StrReplace(A_AppData, "Roaming", "Local")
Open MyDocuments folder:
^#d::Run %A_MyDocuments%
Open Dropbox folder:
^+#d::Run, C:\Users\%A_UserName%\Dropbox
Hassle-free Re-mappings:
CapsLock & g::Send,{Enter}
CapsLock & f::Send,{Delete}
CapsLock & f::Send,{Backspace}
Tip: I recommend using it with this script:
Use Caps Lock for Hand-Friendly Text Navigation | LifeHacker
Toggle Slashes in the Clipboard
Script:
CapsLock & b::
replaceCount = 0
replacement := StrReplace(clipboard, "\", "/", replaceCount)
if replaceCount <= 0
{
replacement := StrReplace(clipboard, "/", "\", replaceCount)
}
if replaceCount > 0
{
clipboard := replacement
}
return
Example:
Copy this to clipboard:
C:\Program Files\AutoHotkey
Press "CapsLock + b". The content of the clipboard will be changed to:
C:/Program Files/AutoHotkey
Press the same hotkey again, and the content of the clipboard will be changed to:
C:\Program Files\AutoHotkey
Convert Windows Path to WSL Path And Wise Versa
Script:
CapsLock & w::
replaceCount = 0
wslPath := RegExReplace(clipboard, "^([a-zA-Z]):(.*)", "/mnt/$L1$2", replaceCount)
if replaceCount <= 0
{
winPath := RegExReplace(clipboard, "^\/mnt\/([a-zA-Z])(.*)", "$U1:$2", replaceCount)
if replaceCount >= 1
{
StringReplace, winPath, winPath, /, \, All
clipboard := winPath
}
}
else
{
StringReplace, wslPath, wslPath, \, /, All
clipboard := wslPath
}
return
Example 1:
Copy this to clipboard:
R:\Temp
Press CapsLock+w, this will change the content of the clipboard to:
/mnt/r/Temp
Example 2:
Copy this to clipboard:
/mnt/r/Temp
press CapsLock+w, this will be in the clipboard:
R:\Temp
Insert Date and Time (HS)
Script:
:*:]d::
FormatTime, CurrentDateTime,, dd.MM.yyyy HH:mm
SendInput %CurrentDateTime%
return
Example input:
]d
It will be replaced with:
28.01.2021 06:50
Insert UUID (GUID, HS)
Script:
:*:]uu::
newGuid := CreateUUID()
SendInput, %newGuid%
return
CreateUUID()
{
VarSetCapacity(UUID, 16, 0)
if (DllCall("rpcrt4.dll\UuidCreate", "ptr", &UUID) != 0)
return (ErrorLevel := 1) & 0
if (DllCall("rpcrt4.dll\UuidToString", "ptr", &UUID, "uint*", suuid) != 0)
return (ErrorLevel := 2) & 0
return StrGet(suuid), DllCall("rpcrt4.dll\RpcStringFree", "uint*", suuid)
}
Example input:
]uu
It will be replaced with:
1b1ae064-4d59-4a0a-b879-cdcbb0bc8c68
Notice, it's based on the following thread: GUID & UUID - AutoHotkey Community.
Wrap text from clipboard and paste (HS)
I use it to search a particular string in evernote intitle. But it might give you ideas for something more relevant. For example, you can wrap a piece of code, etc.
Script:
:*:]eint::
result := RegExReplace(clipboard, "(.*)", "intitle:""$1""",, 1)
SendInput %result%
return
Example:
Copy this to clipboard:
Blog Post
Enter the following string:
]eint
It will be replaced with:
intitle:"Blog Post"
Summary
This post doesn't pretend to be the most complete, but I hope it'll help you start with AutoHotkey a bit quicker. AutoHotkey gives you an easy way to add extra hotkeys to Windows OS, as well as useful "Hot Strings". And the best part - it's mature enough, that if you want to use it for something specific to you, most likely it's already available on the internet - you can find hundreds of scripts on GitHub, forums and blog posts. And if it's not, AutoHotkey has impressive documentation and a responsive user base eager to help.