Autohotkey Script Examples

Good one! Though, I’m personally not a fan of overwriting global hotkeys #n is a new Quick Note in OneNote. And, the w and t keys only works if you don’t have more things in your context menu that have the w as the trigger key. For me, I have WinZip installed and it’s trigger is a w leaving new text file the second w.

Here’s a way around that. This will copy the current path of the current File Explorer and create a new empty text file in that same directory (also notice I used !n as to not overwrite built in hotkeys).

!n::
KeyWait, n
Send, ^l^c
FileAppend,, %clipboard%\new_file.txt
return

Expanding on that, I like to keep a directory of text file notes. This one will take what you have in your clipboard, write it to a text file in your notes directory of choice then, show you the file.

^!n::
FormatTime, t,, yyyy-MM-dd-HH-mm
file = C:\path\to\notes\directory\%t%.txt
FileAppend, %clipboard%, %file%
run, %file%
return

Furthermore, if we want to use OneNote’s built in Quick Note, I made a hotkey that creates the Quick Note and adds the current date as the title triggered.

~#n::
WinWaitActive, Untitled page - OneNote
Send, ^+t
FormatTime, stamp,, yyyy-MM-dd h:mm:ss tt
SendInput, %stamp%{enter}
return

Note: the tilde in this hotkey allows the hotkey’s native function to still execute thus not overwriting it.

Hope someone gets some use out of these!

2 Likes

I use Windows at work, the Mac at home. As such, I get so little time on the Mac to learn its basics. MPU and Automators have been a big help.

If you haven’t tried it yet, AuotIt 3 is s programming language/ framework that wraps much of the windows API. You can automate s lot of GUI activity, but you have to write the code yourself.
It’s an amazing free tool though.

Good tip! The founder of AutoHotkey actually used AutoIt v2 as a base and expanded on it. In my personal opinion and preference, AHK has a lot more functionality and is easier to use/write. But, again, just my opinion. I have tried both and settled on AHK due to those reasons. It just seemed a bit more powerful too.

I encourage everyone to check them both out though! You might find that AutoIt vs AutoHotkey is a lot like Windows vs MacOS or any other opposing arguments (Google vs. MS or Android vs iOS). It just comes down to personal preference!

Cheers.

2 Likes

You’re right. I do remember reading that a few years ago, but forgot. I’ll need to look into AHK again.

Made a quick water downed version of a hotstring creator I once had. It allows you to create auto replacements on the fly.

Script code
^+h::
{
	Gui, Color, White
	Gui, Font, s11
	Gui, Add, Text,, Replace
	Gui, Add, Edit, vtxtReplace w400 r5
	Gui, Add, Text,, With
	Gui, Add, Edit, vtxtWith w400 r5
	Gui, Add, Button, vbtnSubmit gSubmit, Submit
	Gui, Show, AutoSize Center, AutoType
	return
}

Submit:
{
	Gui, Submit
	replacementText := prep(txtWith)
	newhs := ":*:" txtReplace "::" replacementText
	FileAppend, `n%newhs%, %A_ScriptFullPath%
	Reload
	ExitApp
}

GuiClose:
	ExitApp
	
prep(str) {
	str := RegExReplace(str, "\{", "{{}")
	str := RegExReplace(str, "\}", "{}}")
	str := RegExReplace(str, "!", "{!}")
	str := RegExReplace(str, "#", "{#}")
	str := RegExReplace(str, "\^", "{^}")
	str := RegExReplace(str, "\+", "{+}")
	str := RegExReplace(str, "\n", "``n")
	str := RegExReplace(str, "\r", "``r")
	return str
}
:*:btw::by the way
:*:qq::quick question for you
Want to just download the script file instead

autotype.ahk

Basically, run this as an AutoHotkey script (it’ll stay running) and push CTRL+SHIFT+H and it’ll open a dialog to enter in text to type and text to replace when typed. I have some other examples above, but this script will keep them together and reload when you make a new one.