Skip to content

Instantly share code, notes, and snippets.

@tomfa
Last active October 1, 2023 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomfa/81042352f705c746d7ddb8d192a91afe to your computer and use it in GitHub Desktop.
Save tomfa/81042352f705c746d7ddb8d192a91afe to your computer and use it in GitHub Desktop.
Autohotkey script examples (found in 2012-archive)
{
"slides": "https://docs.google.com/presentation/d/1WyicsfMJirQDpJYTVOFwRxwiwgfAVq6fRyylFXc6_G4/edit?usp=sharing",
"date": "September 2012"
}
; Dette skriptet gjentar et tastetrykk med en viss pause mellom hvert trykk
;
; Se artikkel Send/SendRaw/SendInput/Send... for hvordan å
; spesifisere hvilken tast som skal trykkes. ({Click} er venstre musetast)
;
; win-g starter skriptet med popupboks for antall ganger knappen skal trykkes
; dette kan droppes (loop uendelig inntil avbryt) ved å fjerne %antall% etter loop,
; samt linjene fom. Inputbox tom return
; win-q avbryter skriptet
#g::
InputBox, antall, Mappesti, Hvor mange ganger vil du trykke knappen, , 640, 180
if ErrorLevel <> 0
return
Loop %antall%
{
Send, {Click} ; Spesifiser knappen
sleep 1000 ; Spesifiser tiden i millisekunder
}
return
#q:: EXITAPP
;#notrayicon ; fjerner ikonet av
RegRead, OutputVar, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, %A_ScriptName%
if (ErrorLevel = 1){ ; hvis jeg ikke er i oppstarten
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, %A_ScriptName%, %A_ScriptFullPath% ; Create registry key
}
r = 3000
;Random, r, 180000, 1800000
sleep %r% ; pause skriptet i en god tid (random) etter startup for å ikke vise umiddelbar korrelasjon
WinMinimizeAll
;loop {
; sleep 180000 ; pauser skriptet i x millisekunder
; WinMinimizeAll ; minimerer alle vinduer
;}
; Programer
^#1:: run chrome ; Win-ctrl-1 hotkey
^#2:: run C:\Users\media\AppData\Roaming\Spotify\spotify.exe ; Win-ctrl-2 hotkey, merk at det er path
^#3:: run notepad++ ; Win-ctrl-3 hotkey
^#4:: run thunderbird ; Win-ctrl-4 hotkey
; Mapper sd
!#1:: run C:\doc\Orakel ; win-alt-1 hotkey
!#2:: run C:\doc\Skole ; win-alt-2 hotkey
; Linker
+#1:: run https://bas.ntnu.no ; win-shift-1 hotkey
+#2:: run https://studweb.ntnu.no ; win-shift-2 hotkey
+#3:: run http://innsida.ntnu.no ; win-shift-3 hotkey
+#4:: run http://www.gmail.com ; win-shift-4 hotkey
return
#h:: ; Win+H hotkey
; Get the text currently selected. The clipboard is used instead of
; "ControlGet Selected" because it works in a greater variety of editors
; (namely word processors). Save the current clipboard contents to be
; restored later. Although this handles only plain text, it seems better
; than nothing:
AutoTrim Off ; Retain any leading and trailing whitespace on the clipboard.
ClipboardOld = %ClipboardAll%
Clipboard = ; Must start off blank for detection to work.
Send ^c
ClipWait 1
if ErrorLevel ; ClipWait timed out.
return
; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring:
; The same is done for any other characters that might otherwise
; be a problem in raw mode:
StringReplace, Hotstring, Clipboard, ``, ````, All ; Do this replacement first to avoid interfering with the others below.
StringReplace, Hotstring, Hotstring, `r`n, ``r, All ; Using `r works better than `n in MS Word, etc.
StringReplace, Hotstring, Hotstring, `n, ``r, All
StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
StringReplace, Hotstring, Hotstring, `;, ```;, All
Clipboard = %ClipboardOld% ; Restore previous contents of clipboard.
; This will move the InputBox's caret to a more friendly position:
SetTimer, MoveCaret, 10
; Show the InputBox, providing the default hotstring:
InputBox, Hotstring, New Hotstring, Type your abreviation at the indicated insertion point. You can also edit the replacement text if you wish.`n`nExample entry: :R:btw`::by the way,,,,,,,, :R:`::%Hotstring%
if ErrorLevel ; The user pressed Cancel.
return
IfInString, Hotstring, :R`:::
{
MsgBox You didn't provide an abbreviation. The hotstring has not been added.
return
}
; Otherwise, add the hotstring and reload the script:
FileAppend, `n%Hotstring%, %A_ScriptFullPath% ; Put a `n at the beginning in case file lacks a blank line at its end.
Reload
Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The hotstring just added appears to be improperly formatted. Would you like to open the script for editing? Note that the bad hotstring is at the bottom of the script.
IfMsgBox, Yes, Edit
return
MoveCaret:
IfWinNotActive, New Hotstring
return
; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.
Send {Home}{Right 3}
SetTimer, MoveCaret, Off
return
:R:|h::Hei,`r
:R:|b::Ditt brukernavn er
:R:|passord::Du kan sette nytt passord ved å gå til bas[1], og velge `r"Reset Password". Til dette behøver du pin-koden som du `rbenytter på studentweb, og ditt studentnummer. Dersom `rdu mangler dette, kan det fås ved å kontakte `rStudentservice[2]. Nytt passord kan også fås ved å `rsende en SMS til vår passordtelefon, 9189 7112. `rMeldingen må inneholde ditt brukernavn, og komme fra `rditt registrerte telefonnummer. `r`rMerk at det vil ta opptil 2 timer før ditt nye passord`rblir aktivt i alle NTNUs systemer.
:R:|ha::Ha en fortsatt flott dag!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment