Skip to content

Commit 01bb4bc

Browse files
Create QuickType.ahk
1 parent f64d411 commit 01bb4bc

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

SCRIPTS-UTIL/QuickType.ahk

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
; AutoHotKey - QuickType (a Text Expander type-dealy)
2+
; by Ben Howard - [email protected]
3+
4+
; You can customize this template by editing "C:\Windows\ShellNew\Template.ahk"
5+
;===============================================================================================
6+
; This Template.ahk file contains several of the most common items that I find myself often
7+
; needing or adding to my scripts. It's not all essential. Here's a short list of what's here:
8+
; - Function (CheckScriptUpdate) that will auto-reload the script when it detects a change
9+
; in the last modified timestamp on the script file itself
10+
; - Sleep duration shortcuts - so that sleep times can be modified in one place to affect all
11+
; - Modifier Memory Helper - just a comment section to remind you of what the codes are for things
12+
;
13+
; See comments througout the file to figure out what something is here for.
14+
15+
;===== START OF AUTO-EXECUTION SECTION =========================================================
16+
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
17+
; #Warn ; Enable warnings to assist with detecting common errors.
18+
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
19+
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
20+
; #Persistent ; Keeps script permanently running.
21+
#SingleInstance force ; Ensures that there is only a single instance of this script running.
22+
; SetTitleMatchMode, 2 ; sets title matching to search for "containing" instead of "exact"
23+
24+
; The 2 lines below pertain to the 'reload on save' function below (CheckScriptUpdate).
25+
; They are required for it to work.
26+
FileGetTime ScriptStartModTime, %A_ScriptFullPath%
27+
SetTimer CheckScriptUpdate, 100, 0x7FFFFFFF ; 100 ms, highest priority
28+
29+
;===== INITIALIZATION - VARIABLES ==============================================================
30+
; Sleep shortcuts - use these to standardize sleep times. Change here to change everywhere.
31+
sleepShort = 333
32+
sleepMedium = 666
33+
sleepLong = 1500
34+
sleepDeep = 3500
35+
36+
splashScreenX = %1%
37+
splashScreenY = %2%
38+
splashScreenTimeout = %3%
39+
Location_currentSystemLocation = %4%
40+
41+
;===== SPLASH SCREEN TO ANNOUNCE WHAT SCRIPT DOES ==============================================
42+
SplashTextOn, 600, 100, Launching %A_ScriptFullPath%, Expand text shortcuts.`nEdit this file to add/change shortcuts.
43+
WinMove, Launching %A_ScriptFullPath%, , %splashScreenX%, %splashScreenY%
44+
SetTimer, RemoveSplashScreen, %splashScreenTimeout%
45+
Sleep, sleepDeep
46+
SplashTextOff
47+
48+
;===== END OF AUTO-EXECUTE =====================================================================
49+
;===== MODIFIER MEMORY HELPER ==================================================================
50+
; combine below with key and '::' to define hotkey
51+
; e.g.- ^f1::Msgbox You pressed Control and F1
52+
; #=Win | !=Alt | ^=Ctrl | +=Shift | &=combine keys | *=ignore other mods
53+
; <=use left mod key| >=use right mod key | UP=fires on release
54+
55+
;===== MAIN HOTKEY DEFINITIONS HERE ============================================================
56+
57+
; The text expanding 'Hotsrings' are simple to format.
58+
; Just type them in this format:
59+
; ::shortcut::Text to type in place of shortcut
60+
; (This is documented in the AHK docs here - https://www.autohotkey.com/docs/Hotstrings.htm)
61+
62+
::bp::buttonpusher
63+
64+
65+
66+
67+
68+
::]ts:: ; <-- Send time & date as text
69+
FormatTime, now,, hh:mm tt
70+
today = %A_YYYY%-%A_MMM%-%A_DD%
71+
theTimeStamp = %now% - %today%
72+
Send, %theTimeStamp%
73+
return
74+
75+
::]t:: ; <-- Send time ONLY as text
76+
FormatTime, now,, hh:mm tt
77+
theTimeStamp = %now%
78+
Send, %theTimeStamp%
79+
return
80+
81+
::]d:: ; <-- Send date ONLY as text
82+
today = %A_YYYY%-%A_MMM%-%A_DD%
83+
theTimeStamp = %today%
84+
Send, %theTimeStamp%
85+
return
86+
;===== FUNCTIONS ===============================================================================
87+
RemoveSplashScreen:
88+
SplashTextOff
89+
SetTimer RemoveSplashScreen, Off
90+
return
91+
92+
; use this function to Remove ToolTips - pretty self-explanatory
93+
RemoveToolTip(duration) {
94+
SetTimer, ToolTipOff, %duration%
95+
Return
96+
97+
ToolTipOff:
98+
ToolTip
99+
return
100+
}
101+
102+
; This function will auto-reload the script on save.
103+
CheckScriptUpdate() {
104+
global ScriptStartModTime
105+
FileGetTime curModTime, %A_ScriptFullPath%
106+
If (curModTime <> ScriptStartModTime) {
107+
Loop
108+
{
109+
reload
110+
Sleep 300 ; ms
111+
MsgBox 0x2, %A_ScriptName%, Reload failed. ; 0x2 = Abort/Retry/Ignore
112+
IfMsgBox Abort
113+
ExitApp
114+
IfMsgBox Ignore
115+
break
116+
} ; loops reload on "Retry"
117+
}
118+
}

0 commit comments

Comments
 (0)