Every snippet below runs on its own. Add #Requires AutoHotkey v2.0 at the top of the file, paste one in, and try it.
CapsLock::Ctrl +CapsLock::CapsLock ; Shift+CapsLock still toggles caps
^!l::
{
stamp := FormatTime(A_Now, "yyyy-MM-dd HH:mm")
FileAppend stamp " " A_Clipboard "`n", A_Desktop "\clips.txt"
ToolTip "Saved"
Sleep 800
ToolTip
}
#l::
{
half := A_ScreenWidth / 2
WinMove 0, 0, half, A_ScreenHeight, "ahk_exe code.exe"
WinMove half, 0, half, A_ScreenHeight, "ahk_exe chrome.exe"
}
^!g::
{
saved := A_Clipboard
A_Clipboard := ""
Send "^c"
if ClipWait(1)
Run "https://duckduckgo.com/?q=" A_Clipboard
A_Clipboard := saved
}
ClipWait is what keeps this honest: it waits until the copy actually lands instead of reading a stale clipboard.
MyGui := Gui()
MyGui.Add("Text", , "What should I call you?")
MyGui.Add("Edit", "w180 vName")
MyGui.Add("Button", , "OK").OnEvent("Click", Greet)
MyGui.Show()
Greet(*)
{
saved := MyGui.Submit()
MsgBox "Hello, " saved.Name
}
#space::
{
static maximized := false
maximized := !maximized
if maximized
WinMaximize "A"
else
WinRestore "A"
}
A static variable keeps its value between calls, which is how a hotkey remembers what it did last time.
More context for these patterns is on the commands and functions pages; longer builds live under Windows automation.
Yes. All of them use v2 syntax; add #Requires AutoHotkey v2.0 to the top of your file.
Copying is not instant. ClipWait pauses until the clipboard has new content so the script does not read the previous value.