-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrHotKeys.ahk
191 lines (149 loc) · 4.64 KB
/
drHotKeys.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
DetectHiddenWindows, On
SetTitleMatchMode, 2
#SingleInstance, force
OnExit("closeScripts")
global VoiceTyped := ComObjCreate("SAPI.SpVoice")
global VoiceCommand := ComObjCreate("SAPI.SpVoice")
VoiceCommand.Priority := 1 ; Alert priority
; Alternative fix is to loop through files in working dir and populate scriptNames with files starting in "dr"
global scriptNames := ["drMagnifier"]
; Append each file name with the file extension of drHotKeys
SplitPath, A_ScriptName, , , extension
for index, fileName in scriptNames {
scriptNames[index] := fileName "." extension
}
drMagnifier := % scriptNames[1]
inputHook := InputHook("V", "{Space}.{`,}{?}{!}{Enter}")
inputHook.OnEnd := Func("speakWord")
#Include, settingsGUI.ahk
#Include, drInput.ahk
#Include, drWordPad.ahk
constructGUI()
startScripts()
if (!TypedMute) {
inputHook.Start()
}
speak("F-Access Running", 1)
;-------------------------------------------------------------------------------
; Auto Execute End
Return
;-------------------------------------------------------------------------------
F12::
if WinActive("Project Settings") {
Gui, Hide
}
else {
Gui, Show, , % "Project Settings"
}
Return
print() {
defaultPrinter := getDefaultPrinter()
if (defaultPrinter = False) {
speak("Please set a default printer", 0)
Return
}
printerName := StrSplit(defaultPrinter, A_Space) ; Incase of a long printer name
if (printerOffline(defaultPrinter)) {
speak("Unable to print, please turn on your " printerName[1] " printer", 1)
Return
}
Send ^p
Sleep 500
Send {Enter}
speak("Printing", 1)
}
getDefaultPrinter() {
; https://docs.microsoft.com/en-us/windows/win32/printdocs/getdefaultprinter
if !(DllCall("winspool.drv\GetDefaultPrinter", "ptr",0, "uint*",size)) { ; Getting the required size for the buffer to hold the printer's name
size := VarSetCapacity(printer, size*2, 0)
if (DllCall("winspool.drv\GetDefaultPrinter", "str",printer, "uint*",size)) {
Return printer
}
}
Return False
}
printerOffline(printerName) {
global offlineCheckAllowed
if (!offlineCheckAllowed) {
return False
}
RegRead, printerAttributes, HKLM\System\CurrentControlSet\Control\Print\Printers\%printerName%, Attributes
; *Status flags method*
; PRINTER_STATUS_OFFLINE = 0x80 -> The printer is offline.
; PRINTER_STATUS_IO_ACTIVE = 0x100 -> The printer is in an active input or output state.
; = 0x180 (384 decimal)
; *PrintUI dll method*
; rundll32.exe printui.dll PrintUIEntry /Xg /n "EPSON91D7A1 (ET-2600 Series)" /f "printerSettings.txt" /q
; *Attributes flags method*
; PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 0x200
; PRINTER_ATTRIBUTE_ENABLE_BIDI = 0x800
; PRINTER_ATTRIBUTE_WORK_OFFLINE = 0x400
; = 0xe00 (3584 decimal)
; msgbox % Format("0x{:X}", printerAttributes)
if (printerAttributes = 3584) {
return True ; Printer offline
}
return False
}
toggleDictation() {
Send, #h
}
toggleMag() {
global drMagnifier
if WinExist(drMagnifier "ahk_class AutoHotkey") {
WinClose
speak("Magnifier Closed", 3)
}
else {
Run, %drMagnifier% "ahk_class AutoHotkey"
speak("Magnifier Open", 3)
}
}
; Zoom in magnifier or zoom in general
NumpadAdd::
if WinExist(drMagnifier "ahk_class AutoHotkey") {
Send, !{F7}
}
else {
Send, {CTRLDOWN}{WheelUp}{CTRLUP}
}
Return
; Zoom out magnifier or zoom out general
NumpadSub::
if WinExist(drMagnifier "ahk_class AutoHotkey") {
Send, !{F8}
}
else {
Send, {CTRLDOWN}{WheelDown}{CTRLUP}
}
Return
restart() {
VoiceTyped.Speak("", 2) ; Purges VoiceTypes - handling the case of a very long word being spoken
speak("Restarting", 3) ; Asynchronous | PurgeBeforeSpeach
VoiceCommand.WaitUntilDone(-1)
Reload
}
speak(sentence, flag := 0) {
global CommandMute
if (CommandMute) {
return
}
VoiceCommand.Speak(sentence, flag)
}
startScripts() {
global magStartup
for index, name in scriptNames {
if (index == 1 and !magStartup) {
continue
}
Run, %name% "ahk_class AutoHotkey"
}
}
closeScripts() {
for index, name in scriptNames {
WinClose, % name "ahk_class AutoHotkey"
}
}