-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoHotkey64.ahk
263 lines (229 loc) · 14.3 KB
/
AutoHotkey64.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
;;FOR AHK-V2; DVORAK. THIS SCRIPT GENERALLY EMULATES CTRL WITH ALT (!c/!v FOR COPY/PASTE, ETC). MOUSE TOO!
;;HOTKEYS: DUPLICATE ^d DVORAK ^!+d TRANSPARENCY #t ALWAYSONTOP #SPACE SUSPEND ^!SPACE TITLEBAR F12 GRIP ^F12 WINDOW-LIST F11 HIDDEN-WINDOW-LIST +F11 CONTROLLIST ^F11 RENAME !r EXPLORER !e.
;;~300 LINES & ~2000 WORDS. AHK2EXE SENDS STRIPPED SCRIPT TO RESOURCES AutoHotkey64.exe\.rsrc\RCDATA\1. USE 7-ZIP TO EXTRACT ALL DATA TO A FOLDER TO VERIFY CRC SHA.
DVORAK := TRUE ;SCRIPT-OPTIONS. SWITCH TO FALSE FOR NO DVORAK BY DEFAULT. V2 REQUIRES :=. MORE LAYOUTS COULD BE ADDED, TOO.
TRANSPARENT := 128 ;ALPHA LEVEL FOR TRANSPARENCY. BIGGER MEANS MORE OPAQUE.
NPP := "notepad++.exe" ;NO-DUPLICATE FOR NPP (^d PASSTHROUGH). COULD BE RENAMED ADVANCEDTEXTEDITOR. IN NPP CAN SET ^D=SCI_SELECTIONDUPLICATE. SCI=SCINTILLA. ALSO SET ^!D=SCI_LINEDELETE. REMOVE SCI_LINEDUPLICATE BECAUSE SCI_SELECTIONDUPLICATE ALREADY DUPLICATES LINES IF NOTHING IS SELECTED. CAN ALSO SET !~/!1 FOR LOWER/UPPERCASE TOGGLING.
EXPLORERS := "explorer.exe" ;NOT CASE SENSITIVE. EXAMPLE: "explorer.exe explorer++.exe". USE "..." NOT '...'. DUPLICATE PASTES ONCE ONLY FOR THESE APPS.
#SINGLEINSTANCE ;AHK DIRECTIVE .
;@AHK2EXE-BASE AutoHotkey64.exe ;COMPILER DIRECTIVES.
;@AHK2EXE-EXENAME AutoHotkey64..exe
A := "A" ;ABBREV. ACTIVE WINDOW.
TRY A_TRAYMENU.DEFAULT := "&RELOAD SCRIPT" ;FOR DEBUGGING. NOT CASE SENSITIVE.
CATCH
A_TRAYMENU.DEFAULT := "&SUSPEND HOTKEYS" ;FOR COMPILATION.
A_ICONTIP := FORMAT("AHKVersion {}`n{} @DOUBLE-CLICK",A_AHKVERSION,A_TRAYMENU.DEFAULT)
A_ALLOWMAINWINDOW := 1 ;FOR COMPILATION. V2 USES A_ALLOWMAINWINDOW, A_ICONTIP & A_TRAYMENU.
A_TRAYMENU.INSERT "&OPEN" ;DIVIDER. &OPEN MEANS ALL THESE GO ONTOP.
A_TRAYMENU.INSERT "&OPEN", "DUPLICATE/DOUBLE-PASTE `t ^d ",DUPLICATE ;`t,`n,#,^,!,+ = TAB,LINE,WIN,CTRL,ALT,SHIFT. `=ESCAPE-CHAR. A MONOSPACE FONT MIGHT BE PREFERRED, LIKE CONSOLAS OR COURIER NEW. TRIVIAL EXAMPLES CAN ALSO BE ADDED, LIKE !e & !r.
A_TRAYMENU.INSERT "&OPEN"
A_TRAYMENU.INSERT "&OPEN", "TOGGLE DVORAK `t ^!+d ",TOGGLE_DVORAK ;HAS CHECKBOX.
A_TRAYMENU.INSERT "&OPEN", "TOGGLE ALWAYSONTOP `t #SPACE",TOGGLE_ALWAYSONTOP
A_TRAYMENU.INSERT "&OPEN", "TOGGLE TRANSPARENCY `t #t ",TOGGLE_TRANSPARENCY
A_TRAYMENU.INSERT "&OPEN", "TOGGLE WS_SIZEBOX|WS_CAPTION `t F12 ",TOGGLE_TITLEBAR
A_TRAYMENU.INSERT "&OPEN", "TOGGLE WS_SIZEBOX `t ^F12 ",TOGGLE_TITLEBAR ;WINDOWSTYLE SIZEBOX ALLOWS RESIZING WITHOUT ANNOYING TITLEBAR. BUT IT CHANGES HORIZONTAL SIZE, SLIGHTLY.
A_TRAYMENU.INSERT "&OPEN"
A_TRAYMENU.INSERT "&OPEN", "WINGETLIST `t F11 ",WINGET_LIST ;LIST OF WINDOWS.
A_TRAYMENU.INSERT "&OPEN", "WINDOW LISTS, FULL `t +F11 ",WINGET_LIST_FULL ;ALL WINDOWS.
A_TRAYMENU.INSERT "&OPEN", "WINGETCONTROLS `t ^F11 ",WINGET_CONTROLS ;LIST OF WINDOW CONTROLS.
A_TRAYMENU.INSERT "&OPEN"
A_TRAYMENU.INSERT "&OPEN"
TOGGLE_DVORAK(*){ ;@A_TRAYMENU & @^!+d. V2 REQUIRES (*)=(ITEMNAME,ITEMPOS,A_TRAYMENU)
A_TRAYMENU.TOGGLECHECK "TOGGLE DVORAK `t ^!+d "
GLOBAL DVORAK := !DVORAK
}
!WHEELUP::SEND "^{WHEELUP}" ;MOUSE SECTION, !MOUSE=^MOUSE. ALT-ZOOM. SEND MORE RELIABLE FOR ^WHEELUP AFTER !WHEELUP (DIRECT MAPPING CAUSES CONFUSION).
!WHEELDOWN::SEND "^{WHEELDOWN}"
!LBUTTON::SEND "{CTRL DOWN}{LBUTTON}{CTRL UP}" ;{CTRL DOWN} IS MORE RELIABLE IN LINUX & NPP. ALT FILE SELECTIONS & MULTI-LINE EDIT, LIKE CTRL. COMPATIBLE WITH EXPLORER & NOTEPAD++. ALT ALREADY APPLIES TO RBUTTON IN ITS OWN WAY.
!UP::^UP ;^UP ALT FOR NPP.
!DOWN::^DOWN
!LEFT::^LEFT ;JUMPS BY A WORD LEFT & RIGHT. SELECTION TOO.
!RIGHT::^RIGHT
~!+UP:: ;~PASSTHROUGHS. NPP SHIFTED CTRL FLIPS LINES AROUND, BUT ALT IS LESS INTRUSIVE. HIT ESC TO RETURN CURSOR. USING SEND DOESN'T REQUIRE THESE RETURNS.
~!+DOWN::RETURN
^SPACE::
!SPACE::
#SPACE::WINSETALWAYSONTOP -1,A
#SUSPENDEXEMPT ;V2 REQUIRES THIS.
^!SPACE::SUSPEND ;S-SPACE-SUSPEND
#SUSPENDEXEMPT FALSE
F11::WINGET_LIST
+F11::WINGET_LIST_FULL
^F11::WINGET_CONTROLS
F12::TOGGLE_TITLEBAR
+F12::
^F12::TOGGLE_TITLEBAR "^F12" ;F12 TOGGLES VIDEO TITLE-BAR, BUT ^F12 TOGGLES GRIP. F12 IS POST-IT IN NOTEPAD++. #g FOR WIN-GRIP IS ALREADY TAKEN!
!F11::F11 ;!F11/12 CAN DO WHATEVER F11/12 SHOULD DO, LIKE A PASSTHROUGH.
!F12::F12
!q::^q ;q COMMENT TOGGLE (NPP). QWERTY ROW ALTS. DIRECT MAPPINGS PRESERVE SHIFTS. SEND REQUIRES MORE LINES. AN ALTERNATIVE IS TO MAKE ALL THESE LEFTIES, <!. BUT ON LINUX < NOTATION INVALID.
!e::#e ;e EXPLORER. #. IS EMOTICONS!
^e::#e
!r::F2 ;r RENAME. IDEALLY THIS WOULD SEND ENTER, IF ALREADY RENAMING.
^r::F2
!t:: ;t TRANSPARENCY.
^t::
#t::WINSETTRANSPARENT WINGETTRANSPARENT(A) ? "OFF" : TRANSPARENT , A ;A DIFFERENT CONCEPT IS TO RUN THIS ON AN AUTO-TIMER.
!u::^u ;u URL OPEN (SMPLAYER). (I ALSO SET +TAB FOR THIS.)
!o::^o ;o OPEN.
!a::^a ;a ALL. HOME ROW.
!s::^s ;s SAVE.
!d::
^d::DUPLICATE
^!+d::TOGGLE_DVORAK
!f::^f ;f FIND
!z::^z ;z UNDO/REDO. BOTTOM ROW.
!x::^x ;x CUT.
!c::^c ;c COPY.
!v::^v ;v PASTE.
#HOTIF DVORAK ; V2 USES HOTIF. #HOTIF ALTS COULD BE ANOTHER OPTION, TOO. BUT CODING ONLY THE DVORAK OPTION IS SIMPLER. DVORAK USERS COPY/PASTE WITH 2 HANDS. MAY APPLY TO s d f z x c v.
^;::^s ;s SAVE. HOME ROW OUT, BUT NOT IN!
!;::^s
!h::
^h::DUPLICATE
^y::^f ;f FIND.
!y::^f
#p::#l ;l LOCK. DVORAK-LOCK. ~#*p::l ALSO WORKS.
^/::^z ;z UNDO/REDO. BOTTOM ROW.
!/::^z
^b::^x ;x CUT. REMOVE THIS LINE FOR ^b=BOLD.
!b::^x
^i::^c ;c COPY. REMOVE THIS LINE FOR ^i=ITALIC.
!i::^c
^.::^v ;v PASTE.
!.::^v
#HOTIF DVORAK AND NOT(GETKEYSTATE("CTRL") OR GETKEYSTATE("ALT") OR GETKEYSTATE("LWIN") OR GETKEYSTATE("RWIN")) ;DVORAK CONTROLS ARE EXPLICITLY ABOVE.
-::[ ;DIGITS ROW IN.
=::]
q::' ;QWERTY ROW. CASE SENSITIVE.
w::,
e::.
r::p ;Р=R & ТУ NEXT TO EACH OTHER, LIKE RUSSIAN: АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ.
t::y
y::f
u::g
i::c
o::r
p::l ;L=Л≈П=P, LIKE RUSSIAN. DVORAK PLACES LR THE OPPOSITE WAY AROUND.
[::/
]::=
; a::a ;HOME ROW.
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-
z::; ;BOTTOM ROW.
x::q
c::j
v::k
b::x
n::b
; m::m
,::w
.::v
/::z
ALTTAB(){ ;@TOGGLE_ALWAYSONTOP, @TOGGLE_TRANSPARENCY, @TOGGLE_TITLEBAR, @DUPLICATE, & @WINGET_CONTROLS.
SEND "{BLIND}!{TAB}{ALTTABMENUDISMISS}" ;{BLIND} MORE RELIABLE! UNFORTUNATELY THERE'S STILL A GLITCH (ALTTAB MENU). THIS RESTORES A MINIMIZED WIN IF THEY'RE ALL MINIMIZED, FOR SIMPLICITY.
WINWAITACTIVE ,,,,"Task Switching" ;SKIP Task Switching. THIS MAY NOT WAIT LONG ENOUGH ON SOME WINDOWS.
}
TOGGLE_ALWAYSONTOP(*){ ;@A_TRAYMENU.
ALTTAB
WINSETALWAYSONTOP -1,A ;V2 TOGGLES WITH -1.
}
TOGGLE_TRANSPARENCY(*){ ;@A_TRAYMENU.
ALTTAB
WINSETTRANSPARENT WINGETTRANSPARENT(A) ? "OFF" : TRANSPARENT , A ;""=FALSE="OFF"=255 (BUT MORE EFFICIENT). INVERT TRANSPARENCY STATE.
}
TOGGLE_TITLEBAR(ITEMNAME:="",ITEMPOS:="",*){ ;@A_TRAYMENU, @F12 & @^F12.
IF ITEMPOS
ALTTAB
WINGETPOS &X,,&W,&H,A ;Y COORD ALREADY PERFECT. TOGGLING GRIP CAUSES A PROBLEM WHICH FATTENS UP VIDEOS.
WINGETCLIENTPOS ,,&W1,,A ;CAN USE WIDTH TO CALCULATE OFFSET.
WINSETSTYLE INSTR(ITEMNAME,"^F12") ? "^0X40000" : "^0XC40000" , A ;TOGGLE GRIP OR ELSE GRIP+TITLEBAR. C BEATS 8 IN MY TESTS, BUT EITHER WORKS. 0XC00000=WS_CAPTION=WS_BORDER|WS_DLGFRAME WS_SIZEBOX=WS_THICKFRAME TOGGLES SIZING. 0X800000 IS WS_BORDER. ^0X# IS XOR (BINARY FLAG TOGGLE)
WINGETCLIENTPOS ,,&W2,,A
OFFSET := (W2-W1)/2 ;CORRECTS CHANGE IN CLIENTPOS DUE TO TOGGLE. UNFORTUNATELY OFF BY 1p.
WINMOVE X+OFFSET,,W-OFFSET*2,H-OFFSET,A
}
DUPLICATE(ITEMNAME:="",*){ ;@A_TRAYMENU, @^d & @^h. ""=FALSE. DUPLICATES OUTSIDE NOTEPAD++.
IF ITEMNAME
ALTTAB ;FAILS TO DUPLICATE DESKTOP SHORTCUTS @A_TRAYMENU.
PROCESSNAME := WINGETPROCESSNAME(A)
IF PROCESSNAME = NPP { ;SPREADSHEET/EXCEL MAY ALSO NEED A SECTION. LINUX USES `n INSTEAD OF .exe.
SEND "^d"
RETURN
}
SEND "^c" ;2 SENDS MORE RELIABLE ON LINUX. LINUX CHANGES HOW ALL SCRIPTS ARE WRITTEN.
PASTE := "^{v 2}"
LOOP PARSE,EXPLORERS," " ; =DELIMITER. LOOP PARSE CONTINUES FROM PRIOR LOOP PARSE.
IF PROCESSNAME = A_LOOPFIELD ;A_LOOPFIELD=EXPLORER.
PASTE := "^v"
SEND PASTE
}
WINGET_CONTROLS(ITEMNAME:="",*){ ;@A_TRAYMENU & @^F11.
IF ITEMNAME
ALTTAB
MSG := ""
CONTROLLIST := WINGETCONTROLS(A)
FOR CONTROL IN CONTROLLIST {
CONTROLGETPOS &X,&Y,&W,&H, CONTROL,A
DISABLED := CONTROLGETENABLED(CONTROL,A) ? "" : "DISABLED" ;SPECIAL FLAG.
MSG .= FORMAT("`n{} {} {}`t X,Y,W,H={},{},{},{}`t TEXT={:.64}",A_INDEX,DISABLED,CONTROL,X,Y,W,H,CONTROLGETTEXT(CONTROL,A)) ;1024 CHAR LIMIT ON CONTROLTEXT.
}
MSGBOX SUBSTR(MSG,2),FORMAT("{} CONTROLS FOR {} PID={} HWND={}",CONTROLLIST.LENGTH,WINGETPROCESSNAME(A),WINGETPID(A),WINACTIVE(A)) ;REMOVE LEADING `n.
}
WINGET_LIST(*){ ;@A_TRAYMENU & @F11. A DIFFERENT CONCEPT IS TO UPDATE THIS USING A TIMER, BUT THIS TAKES A SNAPSHOT INSTEAD. A WINDOW MONITOR CAN BE LIKE TASK MANAGER.
DETECTHIDDENWINDOWS FALSE
MSG := ""
ACTIVEHWND := WINACTIVE(A)
LIST := WINGETLIST()
FOR HWND IN LIST {
WINGETPOS &X,&Y,&W,&H, HWND
PID := WINGETPID( HWND)
MINMAX := WINGETMINMAX(HWND)
XY := MINMAX = -1 ? "" : FORMAT("X,Y={},{}",X,Y) ;X & Y CAN BE NEGATIVE, BUT NONSENSE IF MINIMIZED (X<-10000).
ACTIVE := HWND != ACTIVEHWND ? "" : "ACTIVE`t "
MINMAX := ["MINIMIZED","","MAXIMIZED"][MINMAX+2]
MSG .= FORMAT("`n`n{}: {}{}`t {}`n{}`t CLASS={}`t PID={}`t {} {} W,H={},{}`t HWND={}",A_INDEX,ACTIVE,WINGETTITLE(HWND),PROCESSGETPATH(PID),PROCESSGETNAME(PID),WINGETCLASS(HWND),PID,MINMAX,XY,W,H,HWND) ;CAPS ARE LIKE FLAGS.
TRY MSG .= FORMAT("`t PARENT={}",PROCESSGETNAME(PROCESSGETPARENT(PID))) ;PARENT TOO!
}
DETECTHIDDENWINDOWS TRUE
MSGBOX SUBSTR(MSG,3),FORMAT("{} WINDOWS, +{} HIDDEN!",LIST.LENGTH,WINGETCOUNT()-LIST.LENGTH) ;REMOVE LEADING `n`n.
}
WINGET_LIST_FULL(*){ ;@A_TRAYMENU & @+F11.
DETECTHIDDENWINDOWS TRUE
MSG := ""
MSG2 := ""
LIST := WINGETLIST() ;~340 IN WIN-10.
FOR HWND IN LIST {
PROCESSNAME := "" ;ACCESS DENIED FOR AT LEAST 1 (#259), EVEN AS ADMIN.
TRY PROCESSNAME := WINGETPROCESSNAME(HWND)
MSG .= FORMAT("{} {} ",A_INDEX,PROCESSNAME )
MSG2 .= FORMAT("{} {} ",A_INDEX,WINGETCLASS(HWND))
}
MSGBOX MSG ,LIST.LENGTH . " WINDOWS TOTAL. PROCESSES BELOW. CLICK OK FOR CLASSES." ;A SEPARATE THREAD WOULD BE MORE ELEGANT.
MSGBOX MSG2,LIST.LENGTH . " WINDOWS TOTAL. CLASSES BELOW."
}
;;A DIFFERENT VERSION COULD COMBINE THE 4 OPTIONS INTO CLASS/OBJECT O.
;;FUTURE VERSION SHOULD RETURN CLIPBOARD MEMORY AFTER DUPLICATE.
;;FUTURE VERSION SHOULD HAVE !` & !1 FOR LOWERCASE/UPPERCASE TOGGLES. NOTEPAD++ CAN ALREADY DO THIS!
;;EXPLORER BUG: !d THEN DEL FAILS TO DELETE. USE !d THEN ALT ALT DEL.
;;IN VIRTUALBOX CAN DISABLE "Auto Capture Keyboard". OR CAN USE LINUX ahk_x11, BASED ON v1.0. IN MACOS-VMWARE SWITCH Command(⌘) & Control(^) MODIFIER KEYS. FOR BRACKETS.IO SET: Select All,Save,Undo,Cut,Copy,Paste = ⌥A,⌥O,⌥;,⌥J,⌥K,⌥Q & Redo,Open Recent... = ⌥⇧;,⌥⇧O IN Keyboard→Shortcuts→App Shortcuts→All Applications→+. UNLOCKED VMWARE PERFORMS BETTER.
;;CHECK V1.1, V1.0 & LINUX SCRIPTS FOR A VARIETY OF CODES. EACH IS UNIQUELY VALID.
;;KEY MEMORY IS DIFFERENT TO WORD MEMORY. I'M NOT SURE WHERE THE KEYS ARE ON MY OWN KEYBOARD, WITHOUT TYPING A WORD. LIKE XAVIER FOR X. IN PRINCIPLE COPY/PASTE FROM ALPHABET COULD BE AS FAST AS NOT TOUCH TYPING. SO EFFICIENT ALTS ARE IMPORTANT. SOME PPL LIKE VARIETY, WHEREAS I PREFER CLONING SO THAT !c=^c=^i=!i, ETC (ALL BUTTONS DO THE SAME THING).
;;MAYBE !4 & !5 COULD CLOSE & REFRESH, BUT NOT WORTH RISK. ALSO POSSIBLE TO MAKE ALT+HOME_ROW INTO DIGITS. A DVORAK VARIANT ALSO REMAPPED DIGITS.
; *RWIN::DLLCALL "LockWorkStation" ;USER32.DLL ENTRIES ARE CASE SENSITIVE. INVALID ON LINUX, BUT #l IS DODGY. * (WILDCARD MOD) IS NECESSARY FOR SHIFT+RWIN TO TRIGGER, ALONG WITH OTHER MODS. ACCIDENTAL RWIN-LOCK IS TOO ANNOYING IF A PASSWORD IS LONG OR UNKNOWN. BUT IT COULD ALSO PREVENT SEIZURE OF A SYSTEM WHICH IS TOO DIFFICULT TO LOCK.
; F10::MSGBOX WINGETTEXT(A) ;WINGETTEXT IS TOO MUCH FOR F11.
; F1::WINSETSTYLE "^0X1" ,A ;CAN TEST WINSETSTYLE & WINSETEXSTYLE FLAGS. CYCLE TRHOUGH ALL POWERS OF 2. MAX FLAG 0X80000000.
; F2::WINSETSTYLE "^0X2" ,A
; F3::WINSETSTYLE "^0X4" ,A
; F4::WINSETSTYLE "^0X8" ,A
; F5::WINSETSTYLE "^0X10",A
; F6::WINSETSTYLE "^0X20",A
; F7::WINSETSTYLE "^0X40",A
; F8::WINSETSTYLE "^0X80",A
; F1::WINSETEXSTYLE "^0X1" ,A ;ETC.