├── 16082_900.png
├── 16291_900.png
├── AhkSpy picture 2020-11-14 07.15.51.png
├── AhkSpy.ahk
├── AhkSpy.exe
├── Extra
├── AccViewer Source.ahk
├── AhkSpyZoom.ahk
└── iWB2 Learner.ahk
├── Old
├── 449
├── AhkSpy.ahk
└── AhkSpy.exe
├── Readme.txt
├── Test
├── 422 2ex.ahk
├── AhkSpy.ahk
├── AhkSpyVersion 4.21 ie11.ahk
├── AhkSpy_DC.ahk
├── Crop 449.ahk
└── art.test
└── menu.png
/16082_900.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serzh82saratov/AhkSpy/18816a663030e5bd19a080db024da49c5c5c4c93/16082_900.png
--------------------------------------------------------------------------------
/16291_900.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serzh82saratov/AhkSpy/18816a663030e5bd19a080db024da49c5c5c4c93/16291_900.png
--------------------------------------------------------------------------------
/AhkSpy picture 2020-11-14 07.15.51.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serzh82saratov/AhkSpy/18816a663030e5bd19a080db024da49c5c5c4c93/AhkSpy picture 2020-11-14 07.15.51.png
--------------------------------------------------------------------------------
/AhkSpy.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serzh82saratov/AhkSpy/18816a663030e5bd19a080db024da49c5c5c4c93/AhkSpy.exe
--------------------------------------------------------------------------------
/Extra/AccViewer Source.ahk:
--------------------------------------------------------------------------------
1 | #SingleInstance Force
2 | #Persistent
3 | #NoEnv
4 | #NoTrayIcon
5 | ListLines Off
6 | SetBatchLines -1
7 |
8 | {
9 | WM_ACTIVATE := 0x06
10 | WM_KILLFOCUS := 0x08
11 | WM_LBUTTONDOWN := 0x201
12 | WM_LBUTTONUP := 0x202
13 | global Border := new Outline, Stored:={}, Acc, ChildId, TVobj, Win:={}
14 | }
15 | {
16 | DetectHiddenWindows, On
17 | OnExit, OnExitCleanup
18 | OnMessage(0x200,"WM_MOUSEMOVE")
19 | ComObjError(false)
20 | Hotkey, ~LButton Up, Off
21 | }
22 | {
23 | Gui Main: New, HWNDhwnd LabelGui AlwaysOnTop, Accessible Info Viewer
24 | Gui Main: Default
25 | Win.Main := hwnd
26 | Gui, Add, Button, x160 y8 w105 h20 vShowStructure gShowStructure, Show Acc Structure
27 | {
28 | Gui, Add, Text, x10 y3 w25 h26 Border gCrossHair ReadOnly HWNDh8 Border
29 | CColor(h8, "White")
30 | Gui, Add, Text, x10 y3 w25 h4 HWNDh9 Border
31 | CColor(h9, "0046D5")
32 | Gui, Add, Text, x13 y17 w19 h1 Border vHBar
33 | Gui, Add, Text, x22 y8 w1 h19 Border vVBar
34 | }
35 | {
36 | Gui, Font, bold
37 | Gui, Add, GroupBox, x2 y32 w275 h130 vWinCtrl, Window/Control Info
38 | Gui, Font
39 | Gui, Add, Text, x7 y49 w42 h20 Right, WinTitle:
40 | Gui, Add, Edit, x51 y47 w221 h20 vWinTitle ,
41 | Gui, Add, Text, x7 y71 w42 h20 Right, Text:
42 | Gui, Add, Edit, x51 y69 w221 h20 vText ,
43 | Gui, Add, Text, x7 y93 w42 h20 Right, Hwnd:
44 | Gui, Add, Edit, x51 y91 w72 h20 vHwnd,
45 | Gui, Add, Text, x126 y93 w51 h20 vClassText Right, Class(NN):
46 | Gui, Add, Edit, x178 y91 w94 h20 vClass,
47 | Gui, Add, Text, x7 y115 w42 h20 Right, Position:
48 | Gui, Add, Edit, x51 y113 w72 h20 vPosition,
49 | Gui, Add, Text, x126 y115 w51 h20 Right, Process:
50 | Gui, Add, Edit, x178 y113 w94 h20 vProcess,
51 | Gui, Add, Text, x7 y137 w42 h20 Right, Size:
52 | Gui, Add, Edit, x51 y135 w72 h20 vSize,
53 | Gui, Add, Text, x126 y137 w51 h20 Right, Proc ID:
54 | Gui, Add, Edit, x178 y135 w94 h20 vProcID,
55 | }
56 | {
57 | Gui, Font, bold
58 | Gui, Add, GroupBox, x2 y165 w275 h240 vAcc, Accessible Info
59 | Gui, Font
60 | Gui, Add, Text, x7 y182 w42 h20 Right, Name:
61 | Gui, Add, Edit, x51 y180 w221 h20 vAccName ,
62 | Gui, Add, Text, x7 y204 w42 h20 Right, Value:
63 | Gui, Add, Edit, x51 y202 w221 h20 vAccValue ,
64 | Gui, Add, Text, x7 y226 w42 h20 Right, Role:
65 | Gui, Add, Edit, x51 y224 w72 h20 vAccRole,
66 | Gui, Add, Text, x126 y226 w55 h20 Right, ChildCount:
67 | Gui, Add, Edit, x182 y224 w90 h20 vAccChildCount,
68 | Gui, Add, Text, x7 y248 w42 h20 Right, State:
69 | Gui, Add, Edit, x51 y246 w72 h20 vAccState,
70 | Gui, Add, Text, x126 y248 w55 h20 Right, Selection:
71 | Gui, Add, Edit, x182 y246 w90 h20 vAccSelection,
72 | Gui, Add, Text, x7 y270 w42 h20 Right, Action:
73 | Gui, Add, Edit, x51 y268 w72 h20 vAccAction,
74 | Gui, Add, Text, x126 y270 w55 h20 Right, Focus:
75 | Gui, Add, Edit, x182 y268 w90 h20 vAccFocus,
76 | {
77 | Gui, Add, Text, x7 y292 w55 h20 Right vAccLocationText, Location:
78 | Gui, Add, Edit, x65 y290 w207 h20 vAccLocation ,
79 | Gui, Add, Text, x7 y314 w55 h20 Right, Description:
80 | Gui, Add, Edit, x65 y312 w207 h20 vAccDescription ,
81 | Gui, Add, Text, x7 y336 w55 h20 Right, Keyboard:
82 | Gui, Add, Edit, x65 y334 w207 h20 vAccKeyboard ,
83 | Gui, Add, Text, x7 y358 w55 h20 Right, Help:
84 | Gui, Add, Edit, x65 y356 w207 h20 vAccHelp ,
85 | Gui, Add, Text, x7 y380 w55 h20 Right, HelpTopic:
86 | Gui, Add, Edit, x65 y378 w207 h20 vAccHelpTopic ,
87 | }
88 | }
89 | {
90 | Gui, Add, StatusBar, gShowMainGui
91 | SB_SetParts(70,150)
92 | SB_SetText("`tshow more", 3)
93 | }
94 | {
95 | Gui Acc: New, ToolWindow AlwaysOnTop Resize LabelAcc HWNDhwnd -DPIScale, Acc Structure
96 | Gui, Acc:+OwnerMain
97 | Win.Acc := hwnd
98 | Gui Acc: Add, TreeView, w200 h300 vTView gTreeView R17 AltSubmit
99 | Gui Acc: Show, Hide
100 | }
101 | GoSub, ShowMainGui
102 | WinSet, Redraw, , % "ahk_id" Win.Main
103 |
104 | param1 = %1%
105 | If param1
106 | pObj := ComObjActive(param1)
107 | If pObj
108 | GetAccInfoRun()
109 | return
110 | }
111 | ShowMainGui:
112 | {
113 | if A_EventInfo in 1,2
114 | {
115 | WM_MOUSEMOVE()
116 | StatusBarGetText, SB_Text, %A_EventInfo%, % "ahk_id" Win.Main
117 | if SB_Text
118 | if (A_EventInfo=2 and SB_Text:=SubStr(SB_Text,7))
119 | or if RegExMatch(SB_Text, "Id: \K\d+", SB_Text) {
120 | ToolTip % "clipboard = " clipboard:=SB_Text
121 | SetTimer, RemoveToolTip, -2000
122 | }
123 | }
124 | else {
125 | Gui Main: Default
126 | if ShowingLess {
127 | SB_SetText("`tshow less", 3)
128 | GuiControl, Move, Acc, x2 y165 w275 h240
129 | GuiControl, Show, AccDescription
130 | GuiControl, Show, AccLocation
131 | GuiControl, Show, AccLocationText
132 | {
133 | height := 319
134 | while height<428 {
135 | height += 10
136 | Gui, Show, w280 h%height%
137 | Sleep, 20
138 | }
139 | }
140 | Gui, Show, w280 h428
141 | ShowingLess := false
142 | }
143 | else {
144 | if (ShowingLess != "") {
145 | height := 428
146 | while height>319 {
147 | height -= 10
148 | Gui, Show, w280 h%height%
149 | Sleep, 20
150 | }
151 | }
152 | Gui, Show, w280 h319
153 | GuiControl, Hide, AccDescription
154 | GuiControl, Hide, AccLocation
155 | GuiControl, Hide, AccLocationText
156 | GuiControl, Move, Acc, x2 y165 w275 h130
157 | SB_SetText("`tshow more", 3)
158 | ShowingLess := true
159 | }
160 | WinSet, Redraw, , % "ahk_id" Win.Main
161 | }
162 | return
163 | }
164 |
165 | #if Not Lbutton_Pressed
166 | ^/::
167 | {
168 | SetBatchLines, -1
169 | Lbutton_Pressed := true
170 | Stored.Chwnd := ""
171 | Gui Acc: Default
172 | GuiControl, Disable, TView
173 | while, Lbutton_Pressed
174 | GetAccInfo()
175 | SetBatchLines, 10ms
176 | return
177 | }
178 | #if Lbutton_Pressed
179 | ^/::
180 | {
181 | Lbutton_Pressed := false
182 | Gui Main: Default
183 | Sleep, -1
184 | GuiControl, , WinCtrl, % (DllCall("GetParent", Uint,Acc_WindowFromObject(Acc))? "Control":"Window") " Info"
185 | if Not DllCall("IsWindowVisible", "Ptr",Win.Acc) {
186 | Border.Hide()
187 | SB_SetText("Path: " GetAccPath(Acc).path, 2)
188 | }
189 | else {
190 | Gui Acc: Default
191 | BuildTreeView()
192 | GuiControl, Enable, TView
193 | WinActivate, % "ahk_id" Win.Acc
194 | PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc
195 | }
196 | return
197 | }
198 | #if
199 | ~Lbutton Up::
200 | {
201 | Hotkey, ~LButton Up, Off
202 | Lbutton_Pressed := False
203 | Gui Main: Default
204 | if Not CH {
205 | GuiControl, Show, HBar
206 | GuiControl, Show, VBar
207 | CrossHair(CH:=true)
208 | }
209 | Sleep, -1
210 | GuiControl, , WinCtrl, % (DllCall("GetParent", Uint,Acc_WindowFromObject(Acc))? "Control":"Window") " Info"
211 | if Not DllCall("IsWindowVisible", "Ptr",Win.Acc) {
212 | Border.Hide()
213 | SB_SetText("Path: " GetAccPath(Acc).path, 2)
214 | }
215 | else {
216 | Gui Acc: Default
217 | BuildTreeView()
218 | GuiControl, Enable, TView
219 | WinActivate, % "ahk_id" Win.Acc
220 | PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc
221 | }
222 | return
223 | }
224 | CrossHair:
225 | {
226 | if (A_GuiEvent = "Normal") {
227 | SetBatchLines, -1
228 | Hotkey, ~LButton Up, On
229 | {
230 | GuiControl, Hide, HBar
231 | GuiControl, Hide, VBar
232 | CrossHair(CH:=false)
233 | }
234 | Lbutton_Pressed := True
235 | Stored.Chwnd := ""
236 | Gui Acc: Default
237 | GuiControl, Disable, TView
238 | while, Lbutton_Pressed
239 | GetAccInfo()
240 | SetBatchLines, 10ms
241 | }
242 | return
243 | }
244 | OnExitCleanup:
245 | {
246 | CrossHair(true)
247 | GuiClose:
248 | ExitApp
249 | }
250 | ShowStructure:
251 | {
252 | ControlFocus, Static1, % "ahk_id" Win.Main
253 | if DllCall("IsWindowVisible", "Ptr",Win.Acc) {
254 | PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc
255 | return
256 | }
257 | WinGetPos, x, y, w, , % "ahk_id" Win.Main
258 | WinGetPos, , , AccW, AccH, % "ahk_id" Win.Acc
259 | WinMove, % "ahk_id" Win.Acc,
260 | , (x+w+AccW > A_ScreenWidth? x-AccW-10:x+w+10)
261 | , % y+5, %AccW%, %AccH%
262 | WinShow, % "ahk_id" Win.Acc
263 | if ComObjType(Acc, "Name") = "IAccessible"
264 | BuildTreeView()
265 | if Lbutton_Pressed
266 | GuiControl, Disable, TView
267 | else
268 | GuiControl, Enable, TView
269 | PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc
270 | return
271 | }
272 | BuildTreeView()
273 | {
274 | r := GetAccPath(Acc)
275 | AccObj:=r.AccObj, Child_Path:=r.Path, r:=""
276 | Gui Acc: Default
277 | TV_Delete()
278 | GuiControl, -Redraw, TView
279 | parent := TV_Add(Acc_Role(AccObj), "", "Bold Expand")
280 | TVobj := {(parent): {is_obj:true, obj:AccObj, need_children:false, childid:0, Children:[]}}
281 |
282 | Loop Parse, Child_Path, .
283 | {
284 | if A_LoopField is not Digit
285 | TVobj[parent].Obj_Path := Trim(TVobj[parent].Obj_Path "," A_LoopField, ",")
286 | else {
287 | StoreParent := parent
288 | parent := TV_BuildAccChildren(AccObj, parent, "", A_LoopField)
289 | TVobj[parent].need_children := false
290 | TV_Expanded(StoreParent)
291 | TV_Modify(parent,"Expand")
292 | AccObj := TVobj[parent].obj
293 | }
294 | }
295 | if Not ChildId {
296 | TV_BuildAccChildren(AccObj, parent)
297 | TV_Modify(parent, "Select")
298 | }
299 | else
300 | TV_BuildAccChildren(AccObj, parent, ChildId)
301 | TV_Expanded(parent)
302 | Sleep 100
303 | TV_Modify(TV_GetSelection(),"Vis")
304 | GuiControl, +Redraw, TView
305 | }
306 | AccClose:
307 | {
308 | Border.Hide()
309 | Gui Acc: Hide
310 | TV_Delete()
311 | Gui Main: Default
312 | GuiControl, Enable, ShowStructure
313 | return
314 | }
315 | AccSize:
316 | {
317 | Anchor(TView, "wh")
318 | return
319 | }
320 | TreeView:
321 | {
322 | Gui, Submit, NoHide
323 | if (A_GuiEvent = "S")
324 | UpdateAccInfo(TVobj[A_EventInfo].obj, TVobj[A_EventInfo].childid, TVobj[A_EventInfo].obj_path)
325 | if (A_GuiEvent = "+") {
326 | GuiControl, -Redraw, TView
327 | TV_Expanded(A_EventInfo)
328 | GuiControl, +Redraw, TView
329 | }
330 | return
331 | }
332 | RemoveToolTip:
333 | {
334 | ToolTip
335 | return
336 | }
337 | GetAccInfoRun() {
338 | global Whwnd, pObj
339 |
340 | Acc := pObj.AccObj.AccObj
341 | ChildId := pObj.AccObj.Child
342 | Location := GetAccLocation(Acc, ChildId)
343 | Hwnd := Acc_WindowFromObject(Acc)
344 | if parent := DllCall("GetParent", Uint,hwnd) {
345 | WinGetTitle, title, ahk_id %parent%
346 | ControlGetText, text, , ahk_id %Hwnd%
347 | Whwnd := pObj.AccObj.WinID
348 | class := GetClassNN(Hwnd,Whwnd)
349 | ControlGetPos, posX, posY, posW, posH, , ahk_id %Hwnd%
350 | WinGet, proc, ProcessName, ahk_id %parent%
351 | WinGet, procid, PID, ahk_id %parent%
352 | }
353 | else
354 | {
355 | WinGetTitle, title, ahk_id %Hwnd%
356 | WinGetText, text, ahk_id %Hwnd%
357 | WinGetClass, class, ahk_id %Hwnd%
358 | WinGetPos, posX, posY, posW, posH, ahk_id %Hwnd%
359 | WinGet, proc, ProcessName, ahk_id %Hwnd%
360 | WinGet, procid, PID, ahk_id %Hwnd%
361 | }
362 | GuiControl, , WinTitle, %title%
363 | GuiControl, , Text, %text%
364 | SetFormat, IntegerFast, H
365 | GuiControl, , Hwnd, % Hwnd+0
366 | SetFormat, IntegerFast, D
367 | GuiControl, , Class, %class%
368 | GuiControl, , Position, x%posX% y%posY%
369 | GuiControl, , Size, w%posW% h%posH%
370 | GuiControl, , Process, %proc%
371 | GuiControl, , ProcId, %procid%
372 |
373 | UpdateAccInfo(Acc, ChildId)
374 | SB_SetText("Path: " GetAccPath(Acc).path, 2)
375 | Gosub ShowMainGui
376 | Gosub ShowStructure
377 | }
378 | GetAccInfo() {
379 | global Whwnd
380 | static ShowButtonEnabled
381 | MouseGetPos, , , Whwnd
382 | if (Whwnd!=Win.Main and Whwnd!=Win.Acc) {
383 | {
384 | GuiControlGet, SectionLabel, , WinCtrl
385 | if (SectionLabel != "Window/Control Info")
386 | GuiControl, , WinCtrl, Window/Control Info
387 | }
388 | Acc := Acc_ObjectFromPoint(ChildId)
389 | Location := GetAccLocation(Acc, ChildId)
390 | if Stored.Location != Location {
391 | Hwnd := Acc_WindowFromObject(Acc)
392 | if Stored.Hwnd != Hwnd {
393 | if parent := DllCall("GetParent", Uint,hwnd) {
394 | WinGetTitle, title, ahk_id %parent%
395 | ControlGetText, text, , ahk_id %Hwnd%
396 | class := GetClassNN(Hwnd,Whwnd)
397 | ControlGetPos, posX, posY, posW, posH, , ahk_id %Hwnd%
398 | WinGet, proc, ProcessName, ahk_id %parent%
399 | WinGet, procid, PID, ahk_id %parent%
400 | }
401 | else {
402 | WinGetTitle, title, ahk_id %Hwnd%
403 | WinGetText, text, ahk_id %Hwnd%
404 | WinGetClass, class, ahk_id %Hwnd%
405 | WinGetPos, posX, posY, posW, posH, ahk_id %Hwnd%
406 | WinGet, proc, ProcessName, ahk_id %Hwnd%
407 | WinGet, procid, PID, ahk_id %Hwnd%
408 | }
409 | {
410 | GuiControl, , WinTitle, %title%
411 | GuiControl, , Text, %text%
412 | SetFormat, IntegerFast, H
413 | GuiControl, , Hwnd, % Hwnd+0
414 | SetFormat, IntegerFast, D
415 | GuiControl, , Class, %class%
416 | GuiControl, , Position, x%posX% y%posY%
417 | GuiControl, , Size, w%posW% h%posH%
418 | GuiControl, , Process, %proc%
419 | GuiControl, , ProcId, %procid%
420 | }
421 | Stored.Hwnd := Hwnd
422 | }
423 | UpdateAccInfo(Acc, ChildId)
424 | }
425 | }
426 | }
427 | UpdateAccInfo(Acc, ChildId, Obj_Path="") {
428 | global Whwnd
429 | Gui Main: Default
430 | Location := GetAccLocation(Acc, ChildId, x,y,w,h)
431 | {
432 | GuiControl, , AccName, % Acc.accName(ChildId)
433 | GuiControl, , AccValue, % Acc.accValue(ChildId)
434 | GuiControl, , AccRole, % Acc_GetRoleText(Acc.accRole(ChildId))
435 | GuiControl, , AccState, % Acc_GetStateText(Acc.accState(ChildId))
436 | GuiControl, , AccAction, % Acc.accDefaultAction(ChildId)
437 | GuiControl, , AccChildCount, % ChildId? "N/A":Acc.accChildCount
438 | GuiControl, , AccSelection, % ChildId? "N/A":Acc.accSelection
439 | GuiControl, , AccFocus, % ChildId? "N/A":Acc.accFocus
440 | GuiControl, , AccLocation, %Location%
441 | GuiControl, , AccDescription, % Acc.accDescription(ChildId)
442 | GuiControl, , AccKeyboard, % Acc.accKeyboardShortCut(ChildId)
443 | Guicontrol, , AccHelp, % Acc.accHelp(ChildId)
444 | GuiControl, , AccHelpTopic, % Acc.accHelpTopic(ChildId)
445 | SB_SetText(ChildId? "Child Id: " ChildId:"Object")
446 | SB_SetText(DllCall("IsWindowVisible", "Ptr",Win.Acc)? "Path: " Obj_Path:"", 2)
447 | }
448 | Border.Transparent(true)
449 | Border.show(x,y,x+w,y+h)
450 | Border.setabove(Whwnd)
451 | Border.Transparent(false)
452 | Stored.Location := Location
453 | }
454 | GetClassNN(Chwnd, Whwnd) {
455 | global _GetClassNN := {}
456 | _GetClassNN.Hwnd := Chwnd
457 | Detect := A_DetectHiddenWindows
458 | WinGetClass, Class, ahk_id %Chwnd%
459 | _GetClassNN.Class := Class
460 | DetectHiddenWindows, On
461 | EnumAddress := RegisterCallback("GetClassNN_EnumChildProc")
462 | DllCall("EnumChildWindows", "uint",Whwnd, "uint",EnumAddress)
463 | DetectHiddenWindows, %Detect%
464 | return, _GetClassNN.ClassNN, _GetClassNN:=""
465 | }
466 | GetClassNN_EnumChildProc(hwnd, lparam) {
467 | static Occurrence
468 | global _GetClassNN
469 | WinGetClass, Class, ahk_id %hwnd%
470 | if _GetClassNN.Class == Class
471 | Occurrence++
472 | if Not _GetClassNN.Hwnd == hwnd
473 | return true
474 | else {
475 | _GetClassNN.ClassNN := _GetClassNN.Class Occurrence
476 | Occurrence := 0
477 | return false
478 | }
479 | }
480 | TV_Expanded(TVid) {
481 | For Each, TV_Child_ID in TVobj[TVid].Children
482 | if TVobj[TV_Child_ID].need_children
483 | TV_BuildAccChildren(TVobj[TV_Child_ID].obj, TV_Child_ID)
484 | }
485 | TV_BuildAccChildren(AccObj, Parent, Selected_Child="", Flag="") {
486 | TVobj[Parent].need_children := false
487 | Parent_Obj_Path := Trim(TVobj[Parent].Obj_Path, ",")
488 | for wach, child in Acc_Children(AccObj) {
489 | if Not IsObject(child) {
490 | added := TV_Add("[" A_Index "] " Acc_GetRoleText(AccObj.accRole(child)), Parent)
491 | TVobj[added] := {is_obj:false, obj:Acc, childid:child, Obj_Path:Parent_Obj_Path}
492 | if (child = Selected_Child)
493 | TV_Modify(added, "Select")
494 | }
495 | else {
496 | added := TV_Add("[" A_Index "] " Acc_Role(child), Parent, "bold")
497 | TVobj[added] := {is_obj:true, need_children:true, obj:child, childid:0, Children:[], Obj_Path:Trim(Parent_Obj_Path "," A_Index, ",")}
498 | }
499 | TVobj[Parent].Children.Insert(added)
500 | if (A_Index = Flag)
501 | Flagged_Child := added
502 | }
503 | return Flagged_Child
504 | }
505 | GetAccPath(Acc, byref hwnd="") {
506 | If !hwnd := Acc_WindowFromObject(Acc)
507 | return
508 | WinObj := Acc_ObjectFromWindow(hwnd)
509 | WinObjPos := Acc_Location(WinObj).pos
510 | while Acc_WindowFromObject(Parent:=Acc_Parent(Acc)) = hwnd {
511 | t2 := GetEnumIndex(Acc) "." t2
512 | if Acc_Location(Parent).pos = WinObjPos
513 | return {AccObj:Parent, Path:SubStr(t2,1,-1)}
514 | Acc := Parent
515 | }
516 | while Acc_WindowFromObject(Parent:=Acc_Parent(WinObj)) = hwnd
517 | t1.="P.", WinObj:=Parent
518 | return {AccObj:Acc, Path:t1 SubStr(t2,1,-1)}
519 | }
520 | GetEnumIndex(Acc, ChildId=0) {
521 | if Not ChildId {
522 | ChildPos := Acc_Location(Acc).pos
523 | For Each, child in Acc_Children(Acc_Parent(Acc))
524 | if IsObject(child) and Acc_Location(child).pos=ChildPos
525 | return A_Index
526 | }
527 | else {
528 | ChildPos := Acc_Location(Acc,ChildId).pos
529 | For Each, child in Acc_Children(Acc)
530 | if Not IsObject(child) and Acc_Location(Acc,child).pos=ChildPos
531 | return A_Index
532 | }
533 | }
534 | GetAccLocation(AccObj, Child=0, byref x="", byref y="", byref w="", byref h="") {
535 | AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), Child)
536 | return "x" (x:=NumGet(x,0,"int")) " "
537 | . "y" (y:=NumGet(y,0,"int")) " "
538 | . "w" (w:=NumGet(w,0,"int")) " "
539 | . "h" (h:=NumGet(h,0,"int"))
540 | }
541 | WM_MOUSEMOVE() {
542 | static hCurs := new Cursor(32649)
543 | MouseGetPos,,,,ctrl
544 | if (ctrl = "msctls_statusbar321")
545 | DllCall("SetCursor","ptr",hCurs.ptr)
546 | }
547 | class Cursor {
548 | __New(id) {
549 | this.ptr := DllCall("LoadCursor","UInt",NULL,"Int",id,"UInt")
550 | }
551 | __delete() {
552 | DllCall("DestroyCursor","Uint",this.ptr)
553 | }
554 | }
555 | class Outline {
556 | __New(color="red") {
557 | Gui, +HWNDdefault
558 | Loop, 4 {
559 | Gui, New, -Caption +ToolWindow HWNDhwnd -DPIScale
560 | Gui, Color, %color%
561 | this[A_Index] := hwnd
562 | }
563 | this.visible := false
564 | this.color := color
565 | this.top := this[1]
566 | this.right := this[2]
567 | this.bottom := this[3]
568 | this.left := this[4]
569 | Gui, %default%: Default
570 | }
571 | Show(x1, y1, x2, y2, sides="TRBL") {
572 | Gui, +HWNDdefault
573 | if InStr( sides, "T" )
574 | Gui, % this[1] ":Show", % "NA X" x1-2 " Y" y1-2 " W" x2-x1+4 " H" 2
575 | Else, Gui, % this[1] ":Hide"
576 | if InStr( sides, "R" )
577 | Gui, % this[2] ":Show", % "NA X" x2 " Y" y1 " W" 2 " H" y2-y1
578 | Else, Gui, % this[2] ":Hide"
579 | if InStr( sides, "B" )
580 | Gui, % this[3] ":Show", % "NA X" x1-2 " Y" y2 " W" x2-x1+4 " H" 2
581 | Else, Gui, % this[3] ":Hide"
582 | if InStr( sides, "L" )
583 | Gui, % this[4] ":Show", % "NA X" x1-2 " Y" y1 " W" 2 " H" y2-y1
584 | Else, Gui, % this[3] ":Hide"
585 | self.visible := true
586 | Gui, %default%: Default
587 | }
588 | Hide() {
589 | Gui, +HWNDdefault
590 | Loop, 4
591 | Gui, % this[A_Index] ": Hide"
592 | self.visible := false
593 | Gui, %default%: Default
594 | }
595 | SetAbove(hwnd) {
596 | ABOVE := DllCall("GetWindow", "uint", hwnd, "uint", 3)
597 | Loop, 4
598 | DllCall( "SetWindowPos", "uint", this[A_Index], "uint", ABOVE
599 | , "int", 0, "int", 0, "int", 0, "int", 0
600 | , "uint", 0x1|0x2|0x10 )
601 | }
602 | Transparent(param) {
603 | Loop, 4
604 | WinSet, Transparent, % param=1? 0:255, % "ahk_id" this[A_Index]
605 | self.visible := !param
606 | }
607 | Color(color) {
608 | Gui, +HWNDdefault
609 | Loop, 4
610 | Gui, % this[A_Index] ": Color" , %color%
611 | self.color := color
612 | Gui, %default%: Default
613 | }
614 | Destroy() {
615 | Loop, 4
616 | Gui, % this[A_Index] ": Destroy"
617 | }
618 | }
619 | CColor(Hwnd, Background="", Foreground="") {
620 | return CColor_(Background, Foreground, "", Hwnd+0)
621 | }
622 | CColor_(Wp, Lp, Msg, Hwnd) {
623 | static
624 | static WM_CTLCOLOREDIT=0x0133, WM_CTLCOLORLISTBOX=0x134, WM_CTLCOLORSTATIC=0x0138
625 | ,LVM_SETBKCOLOR=0x1001, LVM_SETTEXTCOLOR=0x1024, LVM_SETTEXTBKCOLOR=0x1026, TVM_SETTEXTCOLOR=0x111E, TVM_SETBKCOLOR=0x111D
626 | ,BS_CHECKBOX=2, BS_RADIOBUTTON=8, ES_READONLY=0x800
627 | ,CLR_NONE=-1, CSILVER=0xC0C0C0, CGRAY=0x808080, CWHITE=0xFFFFFF, CMAROON=0x80, CRED=0x0FF, CPURPLE=0x800080, CFUCHSIA=0xFF00FF,CGREEN=0x8000, CLIME=0xFF00, COLIVE=0x8080, CYELLOW=0xFFFF, CNAVY=0x800000, CBLUE=0xFF0000, CTEAL=0x808000, CAQUA=0xFFFF00
628 | ,CLASSES := "Button,ComboBox,Edit,ListBox,Static,RICHEDIT50W,SysListView32,SysTreeView32"
629 | If (Msg = "") {
630 | if !adrSetTextColor
631 | adrSetTextColor := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetTextColor")
632 | ,adrSetBkColor := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkColor")
633 | ,adrSetBkMode := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkMode")
634 | BG := !Wp ? "" : C%Wp% != "" ? C%Wp% : "0x" SubStr(WP,5,2) SubStr(WP,3,2) SubStr(WP,1,2)
635 | FG := !Lp ? "" : C%Lp% != "" ? C%Lp% : "0x" SubStr(LP,5,2) SubStr(LP,3,2) SubStr(LP,1,2)
636 | WinGetClass, class, ahk_id %Hwnd%
637 | If class not in %CLASSES%
638 | return A_ThisFunc "> Unsupported control class: " class
639 | ControlGet, style, Style, , , ahk_id %Hwnd%
640 | if (class = "Edit") && (Style & ES_READONLY)
641 | class := "Static"
642 | if (class = "Button")
643 | if (style & BS_RADIOBUTTON) || (style & BS_CHECKBOX)
644 | class := "Static"
645 | else
646 | return A_ThisFunc "> Unsupported control class: " class
647 | if (class = "ComboBox") {
648 | VarSetCapacity(CBBINFO, 52, 0), NumPut(52, CBBINFO), DllCall("GetComboBoxInfo", "UInt", Hwnd, "UInt", &CBBINFO)
649 | hwnd := NumGet(CBBINFO, 48)
650 | %hwnd%BG := BG, %hwnd%FG := FG, %hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : -1
651 | IfEqual, CTLCOLORLISTBOX,,SetEnv, CTLCOLORLISTBOX, % OnMessage(WM_CTLCOLORLISTBOX, A_ThisFunc)
652 | If NumGet(CBBINFO,44)
653 | Hwnd := Numget(CBBINFO,44), class := "Edit"
654 | }
655 | if class in SysListView32,SysTreeView32
656 | {
657 | m := class="SysListView32" ? "LVM" : "TVM"
658 | SendMessage, %m%_SETBKCOLOR, ,BG, ,ahk_id %Hwnd%
659 | SendMessage, %m%_SETTEXTCOLOR, ,FG, ,ahk_id %Hwnd%
660 | SendMessage, %m%_SETTEXTBKCOLOR, ,CLR_NONE, ,ahk_id %Hwnd%
661 | return
662 | }
663 | if (class = "RICHEDIT50W")
664 | return f := "RichEdit_SetBgColor", %f%(Hwnd, -BG)
665 | if (!CTLCOLOR%Class%)
666 | CTLCOLOR%Class% := OnMessage(WM_CTLCOLOR%Class%, A_ThisFunc)
667 | return %Hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : CLR_NONE, %Hwnd%BG := BG, %Hwnd%FG := FG
668 | }
669 | critical
670 | Hwnd := Lp + 0, hDC := Wp + 0
671 | If (%Hwnd%) {
672 | DllCall(adrSetBkMode, "uint", hDC, "int", 1)
673 | if (%Hwnd%FG)
674 | DllCall(adrSetTextColor, "UInt", hDC, "UInt", %Hwnd%FG)
675 | if (%Hwnd%BG)
676 | DllCall(adrSetBkColor, "UInt", hDC, "UInt", %Hwnd%BG)
677 | return (%Hwnd%)
678 | }
679 | }
680 | CrossHair(OnOff=1) {
681 | static AndMask, XorMask, $, h_cursor, IDC_CROSS := 32515
682 | ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13
683 | , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
684 | , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13
685 | if (OnOff = "Init" or OnOff = "I" or $ = "") {
686 | $ := "h"
687 | , VarSetCapacity( h_cursor,4444, 1 )
688 | , VarSetCapacity( AndMask, 32*4, 0xFF )
689 | , VarSetCapacity( XorMask, 32*4, 0 )
690 | , system_cursors := "32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650"
691 | StringSplit c, system_cursors, `,
692 | Loop, %c0%
693 | h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
694 | , h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
695 | , b%A_Index% := DllCall("LoadCursor", "Uint", "", "Int", IDC_CROSS, "Uint")
696 | }
697 | $ := (OnOff = 0 || OnOff = "Off" || $ = "h" && (OnOff < 0 || OnOff = "Toggle" || OnOff = "T")) ? "b" : "h"
698 | Loop, %c0%
699 | h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
700 | , DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
701 | }
702 |
703 | { ; Acc Library
704 | Acc_Init()
705 | {
706 | Static h
707 | If Not h
708 | h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
709 | }
710 | Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
711 | {
712 | Acc_Init()
713 | If DllCall("oleacc\AccessibleObjectFromEvent", "Ptr", hWnd, "UInt", idObject, "UInt", idChild, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
714 | Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
715 | }
716 | Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "")
717 | {
718 | Acc_Init()
719 | If DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
720 | Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
721 | }
722 | Acc_ObjectFromWindow(hWnd, idObject = 0)
723 | {
724 | Acc_Init()
725 | If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
726 | Return ComObjEnwrap(9,pacc,1)
727 | }
728 | Acc_WindowFromObject(pacc)
729 | {
730 | If DllCall("oleacc\WindowFromAccessibleObject", "Ptr", IsObject(pacc)?ComObjValue(pacc):pacc, "Ptr*", hWnd)=0
731 | Return hWnd
732 | }
733 | Acc_GetRoleText(nRole)
734 | {
735 | nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0)
736 | VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize)
737 | DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1)
738 | Return sRole
739 | }
740 | Acc_GetStateText(nState)
741 | {
742 | nSize := DllCall("oleacc\GetStateText", "Uint", nState, "Ptr", 0, "Uint", 0)
743 | VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize)
744 | DllCall("oleacc\GetStateText", "Uint", nState, "str", sState, "Uint", nSize+1)
745 | Return sState
746 | }
747 | Acc_Role(Acc, ChildId=0) {
748 | try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetRoleText(Acc.accRole(ChildId)):"invalid object"
749 | }
750 | Acc_State(Acc, ChildId=0) {
751 | try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetStateText(Acc.accState(ChildId)):"invalid object"
752 | }
753 | Acc_Children(Acc) {
754 | if ComObjType(Acc,"Name")!="IAccessible"
755 | error_message := "Cause:`tInvalid IAccessible Object`n`n"
756 | else {
757 | Acc_Init()
758 | cChildren:=Acc.accChildCount, Children:=[]
759 | if DllCall("oleacc\AccessibleChildren", "Ptr", ComObjValue(Acc), "Int", 0, "Int", cChildren, "Ptr", VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*", cChildren)=0 {
760 | Loop %cChildren%
761 | i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=3?child:Acc_Query(child)), ObjRelease(child)
762 | return Children
763 | }
764 | }
765 | error:=Exception("",-1)
766 | MsgBox, 262148, Acc_Children Failed, % (error_message?error_message:"") "File:`t" (error.file==A_ScriptFullPath?A_ScriptName:error.file) "`nLine:`t" error.line "`n`nContinue Script?"
767 | IfMsgBox, No
768 | ExitApp
769 | }
770 | Acc_Location(Acc, ChildId=0) {
771 | try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
772 | catch
773 | return
774 | return {x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")
775 | , pos:"x" NumGet(x,0,"int")" y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")}
776 | }
777 | Acc_Parent(Acc) {
778 | try parent:=Acc.accParent
779 | return parent?Acc_Query(parent):
780 | }
781 | Acc_Child(Acc, ChildId=0) {
782 | try child:=Acc.accChild(ChildId)
783 | return child?Acc_Query(child):
784 | }
785 | Acc_Query(Acc) {
786 | try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
787 | }
788 | }
789 |
790 | Anchor(i, a = "", r = false) {
791 | static c, cs = 12, cx = 255, cl = 0, g, gs = 8, gl = 0, gpi, gw, gh, z = 0, k = 0xffff, ptr
792 | If z = 0
793 | VarSetCapacity(g, gs * 99, 0), VarSetCapacity(c, cs * cx, 0), ptr := A_PtrSize ? "Ptr" : "UInt", z := true
794 | If (!WinExist("ahk_id" . i)) {
795 | GuiControlGet, t, Hwnd, %i%
796 | If ErrorLevel = 0
797 | i := t
798 | Else ControlGet, i, Hwnd, , %i%
799 | }
800 | VarSetCapacity(gi, 68, 0), DllCall("GetWindowInfo", "UInt", gp := DllCall("GetParent", "UInt", i), ptr, &gi)
801 | , giw := NumGet(gi, 28, "Int") - NumGet(gi, 20, "Int"), gih := NumGet(gi, 32, "Int") - NumGet(gi, 24, "Int")
802 | If (gp != gpi) {
803 | gpi := gp
804 | Loop, %gl%
805 | If (NumGet(g, cb := gs * (A_Index - 1)) == gp, "UInt") {
806 | gw := NumGet(g, cb + 4, "Short"), gh := NumGet(g, cb + 6, "Short"), gf := 1
807 | Break
808 | }
809 | If (!gf)
810 | NumPut(gp, g, gl, "UInt"), NumPut(gw := giw, g, gl + 4, "Short"), NumPut(gh := gih, g, gl + 6, "Short"), gl += gs
811 | }
812 | ControlGetPos, dx, dy, dw, dh, , ahk_id %i%
813 | Loop, %cl%
814 | If (NumGet(c, cb := cs * (A_Index - 1), "UInt") == i) {
815 | If a =
816 | {
817 | cf = 1
818 | Break
819 | }
820 | giw -= gw, gih -= gh, as := 1, dx := NumGet(c, cb + 4, "Short"), dy := NumGet(c, cb + 6, "Short")
821 | , cw := dw, dw := NumGet(c, cb + 8, "Short"), ch := dh, dh := NumGet(c, cb + 10, "Short")
822 | Loop, Parse, a, xywh
823 | If A_Index > 1
824 | av := SubStr(a, as, 1), as += 1 + StrLen(A_LoopField)
825 | , d%av% += (InStr("yh", av) ? gih : giw) * (A_LoopField + 0 ? A_LoopField : 1)
826 | DllCall("SetWindowPos", "UInt", i, "UInt", 0, "Int", dx, "Int", dy
827 | , "Int", InStr(a, "w") ? dw : cw, "Int", InStr(a, "h") ? dh : ch, "Int", 4)
828 | If r != 0
829 | DllCall("RedrawWindow", "UInt", i, "UInt", 0, "UInt", 0, "UInt", 0x0101)
830 | Return
831 | }
832 | If cf != 1
833 | cb := cl, cl += cs
834 | bx := NumGet(gi, 48, "UInt"), by := NumGet(gi, 16, "Int") - NumGet(gi, 8, "Int") - gih - NumGet(gi, 52, "UInt")
835 | If cf = 1
836 | dw -= giw - gw, dh -= gih - gh
837 | NumPut(i, c, cb, "UInt"), NumPut(dx - bx, c, cb + 4, "Short"), NumPut(dy - by, c, cb + 6, "Short")
838 | , NumPut(dw, c, cb + 8, "Short"), NumPut(dh, c, cb + 10, "Short")
839 | Return, true
840 | }
841 |
--------------------------------------------------------------------------------
/Extra/AhkSpyZoom.ahk:
--------------------------------------------------------------------------------
1 |
2 | ; version = 1.46
3 |
4 | #NoEnv
5 | #NoTrayIcon
6 | #SingleInstance Ignore
7 | #KeyHistory 0
8 |
9 | hAhkSpy = %1%
10 | ActiveNoPause = %2%
11 | If !WinExist("ahk_id" hAhkSpy)
12 | ExitApp
13 |
14 | ListLines Off
15 | SetBatchLines,-1
16 | CoordMode, Mouse, Screen
17 | OnExit("ZoomOnClose")
18 |
19 | Global oZoom := {}, hAhkSpy, MsgAhkSpyZoom, ActiveNoPause
20 | OnMessage(0x0020, "WM_SETCURSOR")
21 | OnMessage(0x201, "LBUTTONDOWN") ; WM_LBUTTONDOWN
22 | OnMessage(0xA1, "LBUTTONDOWN") ; WM_NCLBUTTONDOWN
23 | OnMessage(0xF, "WM_Paint")
24 | ZoomCreate()
25 | OnMessage(MsgAhkSpyZoom := DllCall("RegisterWindowMessage", "Str", "MsgAhkSpyZoom"), "MsgZoom")
26 | PostMessage, % MsgAhkSpyZoom, 0, % oZoom.hGui, , ahk_id %hAhkSpy%
27 | SetWinEventHook("EVENT_OBJECT_DESTROY", 0x8001)
28 | SetWinEventHook("EVENT_OBJECT_LOCATIONCHANGE", 0x800B)
29 | SetWinEventHook("EVENT_SYSTEM_MINIMIZESTART", 0x0016, 0x0017)
30 | WinGet, Min, MinMax, % "ahk_id " hAhkSpy
31 | If Min != -1
32 | ZoomShow()
33 | SetTimer, CheckAhkSpy, 200
34 | Return
35 |
36 | #If oZoom.Show
37 |
38 | ^+#Up::
39 | ^+#Down::
40 | +#WheelUp::
41 | +#WheelDown::ChangeZoom(InStr(A_ThisHotKey, "Down") ? oZoom.Zoom + 1 : oZoom.Zoom - 1)
42 |
43 | #If (!oZoom.AhkSpyPause && oZoom.Show && !IsMinimize(hAhkSpy))
44 |
45 | +#Up::MouseStep(0, -1)
46 | +#Down::MouseStep(0, 1)
47 | +#Left::MouseStep(-1, 0)
48 | +#Right::MouseStep(1, 0)
49 |
50 | MouseStep(x, y) {
51 | MouseMove, x, y, 0, R
52 | If oZoom.Pause
53 | {
54 | SetTimer, Magnify, Off
55 | oZoom.Pause := 0, Magnify(), oZoom.Pause := 1
56 | SetTimer, Magnify, -30
57 | }
58 | PostMessage, % MsgAhkSpyZoom, 1, 0, , ahk_id %hAhkSpy%
59 | }
60 |
61 | #If
62 |
63 | ZoomCreate() {
64 | oZoom.Zoom := IniRead("MagnifyZoom", 8)
65 | oZoom.Mark := IniRead("MagnifyMark", "Cross")
66 | oZoom.MemoryZoomSize := IniRead("MemoryZoomSize", 0)
67 | oZoom.GuiMinW := 308
68 | oZoom.GuiMinH := 368
69 | If oZoom.MemoryZoomSize
70 | GuiW := IniRead("MemoryZoomSizeW", oZoom.GuiMinW), GuiH := IniRead("MemoryZoomSizeH", oZoom.GuiMinH)
71 | Else
72 | GuiW := oZoom.GuiMinW, GuiH := oZoom.GuiMinH
73 | Gui Zoom: +AlwaysOnTop -DPIScale +hwndhGui +LabelZoomOn -Caption +E0x08000000 +Border
74 | Gui, Zoom: Font, s12
75 | Gui, Zoom: Color, F0F0F0
76 | Gui, Zoom: Add, Slider, hwndhSliderZoom gSliderZoom x8 Range1-50 w176 Center AltSubmit NoTicks, % oZoom.Zoom
77 | Gui, Zoom: Add, Text, hwndhTextZoom Center x+10 yp+3 w36, % oZoom.Zoom
78 | Gui, Zoom: Font
79 | Gui, Zoom: Add, Button, hwndhChangeMark gChangeMark x+10 yp w52, % oZoom.Mark
80 | Gui, Zoom: Show, % "Hide w" GuiW " h" GuiH, AhkSpyZoom
81 | Gui, Zoom: +MinSize
82 | DllCall("SetClassLong", "Ptr", hGui, "int", -26
83 | , "int", DllCall("GetClassLong", "Ptr", hGui, "int", -26) | 0x20000)
84 |
85 | Gui, Dev: +HWNDhDev -Caption -DPIScale +Parent%hGui% +Border
86 | Gui, Dev: Add, Text, hwndhDevCon
87 | Gui, Dev: Show, NA
88 | Gui, Dev: Color, F0F0F0
89 |
90 | oZoom.hdcSrc := DllCall("GetDC", Ptr, "")
91 | oZoom.hdcDest := DllCall("GetDC", Ptr, hDevCon, Ptr)
92 | oZoom.hdcMemory := DllCall("CreateCompatibleDC", "Ptr", 0)
93 | DllCall("gdi32.dll\SetStretchBltMode", "Ptr", oZoom.hdcDest, "Int", 4)
94 | oZoom.hGui := hGui
95 | oZoom.hDev := hDev
96 | oZoom.hDevCon := hDevCon
97 |
98 | oZoom.vTextZoom := hTextZoom
99 | oZoom.vChangeMark := hChangeMark
100 | oZoom.vSliderZoom := hSliderZoom
101 | }
102 |
103 | ZoomShow() {
104 | oZoom.Show := 1
105 | Gui, Zoom: Show, NA
106 | oZoom.Pause ? 0 : Magnify(), ZoomMove()
107 | }
108 |
109 | ZoomHide() {
110 | oZoom.Show := 0
111 | oZoom.Pause := 1
112 | Gui, Zoom: Show, Hide
113 | }
114 |
115 | Magnify() {
116 | If (oZoom.Show && !oZoom.Pause && oZoom.SIZING != 2)
117 | {
118 | MouseGetPos, mX, mY, WinID
119 | If (WinID != oZoom.hGui && WinID != hAhkSpy)
120 | {
121 | SetTimer, Memory, Off
122 | oZoom.MouseX := mX, oZoom.MouseY := mY
123 | StretchBlt(oZoom.hdcDest, 0, 0, oZoom.nWidthDest, oZoom.nHeightDest
124 | , oZoom.hdcSrc, mX - oZoom.nXOriginSrcOffset, mY - oZoom.nYOriginSrcOffset, oZoom.nWidthSrc, oZoom.nHeightSrc)
125 | For k, v In oZoom.oMarkers[oZoom.Mark]
126 | StretchBlt(oZoom.hdcDest, v.x, v.y, v.w, v.h, oZoom.hdcDest, v.x, v.y, v.w, v.h, 0x5A0049) ; PATINVERT
127 | SetTimer, Memory, -30
128 | }
129 | }
130 | SetTimer, Magnify, -1
131 | }
132 |
133 | SetSize() {
134 | Static Top := 64, Left := 4, Right := 4, Bottom := 4, PrWidth, PrHeight
135 | SetTimer, Magnify, Off
136 | GetClientPos(oZoom.hGui, GuiWidth, GuiHeight)
137 | Width := GuiWidth - Left - Right
138 | Height := GuiHeight - Top - Bottom
139 | Zoom := oZoom.Zoom
140 | conW := Mod(Width, Zoom) ? Width - Mod(Width, Zoom) + Zoom : Width
141 | conW := Mod(conW // Zoom, 2) ? conW : conW + Zoom
142 | conH := Mod(Height, Zoom) ? Height - Mod(Height, Zoom) + Zoom : Height
143 | conH := Mod(conH // Zoom, 2) ? conH : conH + Zoom
144 | conX := ((conW - Width) // 2) * -1
145 | conY := ((conH - Height) // 2) * -1
146 |
147 | oZoom.nWidthSrc := conW // Zoom
148 | oZoom.nHeightSrc := conH // Zoom
149 | oZoom.nXOriginSrcOffset := oZoom.nWidthSrc//2
150 | oZoom.nYOriginSrcOffset := oZoom.nHeightSrc//2
151 | oZoom.nWidthDest := nWidthDest := conW
152 | oZoom.nHeightDest := nHeightDest := conH
153 | oZoom.xCenter := xCenter := conW / 2 - Zoom / 2
154 | oZoom.yCenter := yCenter := conH / 2 - Zoom / 2
155 |
156 | oZoom.oMarkers["Cross"] := [{x:0,y:yCenter - 1,w:nWidthDest,h:1}
157 | , {x:0,y:yCenter + Zoom,w:nWidthDest,h:1}
158 | , {x:xCenter - 1,y:0,w:1,h:nHeightDest}
159 | , {x:xCenter + Zoom,y:0,w:1,h:nHeightDest}]
160 |
161 | oZoom.oMarkers["Square"] := [{x:xCenter - 1,y:yCenter,w:Zoom + 2,h:1}
162 | , {x:xCenter - 1,y:yCenter + Zoom + 1,w:Zoom + 2,h:1}
163 | , {x:xCenter - 1,y:yCenter + 1,w:1,h:Zoom}
164 | , {x:xCenter + Zoom,y:yCenter + 1,w:1,h:Zoom}]
165 |
166 | oZoom.oMarkers["Grid"] := Zoom = 1 ? oZoom.oMarkers["Square"]
167 | : [{x:xCenter - Zoom,y:yCenter - Zoom,w:Zoom * 3,h:1}
168 | , {x:xCenter - Zoom,y:yCenter,w:Zoom * 3,h:1}
169 | , {x:xCenter - Zoom,y:yCenter + Zoom,w:Zoom * 3,h:1}
170 | , {x:xCenter - Zoom,y:yCenter + Zoom * 2,w:Zoom * 3,h:1}
171 | , {x:xCenter - Zoom,y:yCenter - Zoom,w:1,h:Zoom * 3}
172 | , {x:xCenter,y:yCenter - Zoom,w:1,h:Zoom * 3}
173 | , {x:xCenter + Zoom,y:yCenter - Zoom,w:1,h:Zoom * 3}
174 | , {x:xCenter + Zoom * 2,y:yCenter - Zoom,w:1,h:Zoom * 3}]
175 |
176 | SetWindowPos(oZoom.hDevCon, conX, conY, conW, conH)
177 | SetWindowPos(oZoom.hDev, Left, Top, Width, Height)
178 | Redraw()
179 | If (PrWidth != Width || PrHeight != Height)
180 | {
181 | PrWidth := Width, PrHeight := Height
182 | If oZoom.MemoryZoomSize
183 | IniWrite(GuiWidth, "MemoryZoomSizeW"), IniWrite(GuiHeight, "MemoryZoomSizeH")
184 | SetTimer, RedrawWindow, -100
185 | }
186 | SetTimer, Magnify, -10
187 | }
188 |
189 | SetWindowPos(hWnd, x, y, w, h) {
190 | Static SWP_ASYNCWINDOWPOS := 0x4000, SWP_DEFERERASE := 0x2000, SWP_NOACTIVATE := 0x0010, SWP_NOCOPYBITS := 0x0100
191 | , SWP_NOOWNERZORDER := 0x0200, SWP_NOREDRAW := 0x0008, SWP_NOSENDCHANGING := 0x0400
192 | DllCall("SetWindowPos"
193 | , "Ptr", hWnd
194 | , "Ptr", 0
195 | , "Int", x
196 | , "Int", y
197 | , "Int", w
198 | , "Int", h
199 | , "UInt", SWP_ASYNCWINDOWPOS|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOOWNERZORDER|SWP_NOREDRAW|SWP_NOSENDCHANGING)
200 | }
201 |
202 | RedrawWindow() {
203 | DllCall("RedrawWindow", "Ptr", oZoom.hGui, "Uint", 0, "Uint", 0, "Uint", 0x1|0x4)
204 | }
205 |
206 | ZoomMove() {
207 | If !oZoom.Show
208 | Return
209 | WinGetPos, WinX, WinY, WinWidth, WinHeight, ahk_id %hAhkSpy%
210 | Gui, Zoom:Show, % "x" WinX + WinWidth " y" WinY " NA"
211 | }
212 |
213 | SliderZoom() {
214 | GuiControlGet, SliderZoom, Zoom:, % oZoom.vSliderZoom
215 | ChangeZoom(SliderZoom)
216 | }
217 |
218 | ChangeZoom(Val) {
219 | If (Val < 1 || Val > 50)
220 | Return
221 | SetTimer, Magnify, Off
222 | GuiControl, Zoom:, % oZoom.vTextZoom, % oZoom.Zoom := Val
223 | GuiControl, Zoom:, % oZoom.vSliderZoom, % oZoom.Zoom
224 | IniWrite(oZoom.Zoom, "MagnifyZoom")
225 | SetTimer, SetSize, -10
226 | }
227 |
228 | ChangeMark() {
229 | oZoom.Mark := ["Cross","Square","Grid","None"][{"Cross":2,"Square":3,"Grid":4,"None":1}[oZoom.Mark]]
230 | GuiControl, Zoom:, % oZoom.vChangeMark, % oZoom.Mark
231 | IniWrite(oZoom.Mark, "MagnifyMark")
232 | Redraw()
233 | }
234 |
235 | WM_Paint() {
236 | If A_GuiControl =
237 | SetTimer, Redraw, -10
238 | }
239 |
240 | Memory() {
241 | SysGet, VirtualScreenX, 76
242 | SysGet, VirtualScreenY, 77
243 | SysGet, VirtualScreenWidth, 78
244 | SysGet, VirtualScreenHeight, 79
245 | oZoom.nXOriginSrc := oZoom.MouseX - VirtualScreenX, oZoom.nYOriginSrc := oZoom.MouseY - VirtualScreenY
246 | hBM := DllCall("Gdi32.Dll\CreateCompatibleBitmap", "Ptr", oZoom.hdcSrc, "Int", VirtualScreenWidth, "Int", VirtualScreenHeight)
247 | DllCall("Gdi32.Dll\SelectObject", "Ptr", oZoom.hdcMemory, "Ptr", hBM), DllCall("DeleteObject", "Ptr", hBM)
248 | BitBlt(oZoom.hdcMemory, 0, 0, VirtualScreenWidth, VirtualScreenHeight, oZoom.hdcSrc, VirtualScreenX, VirtualScreenY)
249 | }
250 |
251 | Redraw() {
252 | StretchBlt(oZoom.hdcDest, 0, 0, oZoom.nWidthDest, oZoom.nHeightDest
253 | , oZoom.hdcMemory, oZoom.nXOriginSrc - oZoom.nXOriginSrcOffset, oZoom.nYOriginSrc - oZoom.nYOriginSrcOffset, oZoom.nWidthSrc, oZoom.nHeightSrc)
254 | For k, v In oZoom.oMarkers[oZoom.Mark]
255 | StretchBlt(oZoom.hdcDest, v.x, v.y, v.w, v.h, oZoom.hdcDest, v.x, v.y, v.w, v.h, 0x5A0049) ; PATINVERT
256 | }
257 |
258 | CheckAhkSpy() {
259 | WinGet, Min, MinMax, % "ahk_id " hAhkSpy
260 | If Min =
261 | ExitApp
262 | If (Min = -1 || (!ActiveNoPause && WinActive("ahk_id" hAhkSpy)))
263 | oZoom.Pause := 1
264 | }
265 |
266 | GetClientPos(hwnd, ByRef W, ByRef H) {
267 | VarSetCapacity(pwi, 60, 0), NumPut(60, pwi, 0, "UInt")
268 | DllCall("GetWindowInfo", "Ptr", hwnd, "UInt", &pwi)
269 | W := NumGet(pwi, 28, "int") - NumGet(pwi, 20, "int")
270 | H := NumGet(pwi, 32, "int") - NumGet(pwi, 24, "int")
271 | }
272 |
273 | IniRead(Key, Error := " ") {
274 | IniRead, Value, %A_AppData%\AhkSpy.ini, AhkSpy, %Key%, %Error%
275 | Return Value = "" ? Error : Value
276 | }
277 |
278 | IniWrite(Value, Key) {
279 | IniWrite, %Value%, %A_AppData%\AhkSpy.ini, AhkSpy, %Key%
280 | Return Value
281 | }
282 |
283 | IsMinimize(hwnd) {
284 | WinGet, Min, MinMax, % "ahk_id " hwnd
285 | If Min = -1
286 | Return 1
287 | }
288 |
289 | SetWinEventHook(EventProc, eventMin, eventMax = 0) {
290 | Return DllCall("SetWinEventHook"
291 | , "UInt", eventMin, "UInt", eventMax := !eventMax ? eventMin : eventMax
292 | , "Ptr", hmodWinEventProc := 0, "Ptr", lpfnWinEventProc := RegisterCallback(EventProc, "F")
293 | , "UInt", idProcess := 0, "UInt", idThread := 0
294 | , "UInt", dwflags := 0x0|0x2, "Ptr") ; WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS
295 | }
296 |
297 | BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster = 0xC000CA) {
298 | Return DllCall("Gdi32.Dll\BitBlt"
299 | , "Ptr", dDC
300 | , "Int", dx
301 | , "Int", dy
302 | , "Int", dw
303 | , "Int", dh
304 | , "Ptr", sDC
305 | , "Int", sx
306 | , "Int", sy
307 | , "Uint", Raster)
308 | }
309 |
310 | StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster = 0xC000CA) {
311 | Return DllCall("Gdi32.Dll\StretchBlt"
312 | , "Ptr", dDC
313 | , "Int", dx
314 | , "Int", dy
315 | , "Int", dw
316 | , "Int", dh
317 | , "Ptr", sDC
318 | , "Int", sx
319 | , "Int", sy
320 | , "Int", sw
321 | , "Int", sh
322 | , "Uint", Raster)
323 | }
324 |
325 | ; _________________________________________________ Events _________________________________________________
326 |
327 | ZoomOnSize() {
328 | If A_EventInfo != 0
329 | Return
330 | SetTimer, SetSize, -10
331 | ZoomMove()
332 | }
333 |
334 | ZoomOnClose() {
335 | DllCall("gdi32.dll\DeleteDC", "Ptr", oZoom.hdcDest)
336 | DllCall("gdi32.dll\DeleteDC", "Ptr", oZoom.hdcSrc)
337 | DllCall("Gdi32.Dll\DeleteDC", "Ptr", oZoom.hdcMemory)
338 | RestoreCursors()
339 | ExitApp
340 | }
341 |
342 | ; wParam: 0 снять паузу, 1 пауза, 2 однократный зум, 3 hide, 4 show, 5 MemoryZoomSize, 6 MinSize, 7 пауза AhkSpy, 8 ActiveNoPause
343 |
344 | MsgZoom(wParam, lParam) {
345 | If wParam = 0
346 | oZoom.Pause := 0, Magnify()
347 | Else If wParam = 1
348 | oZoom.Pause := 1
349 | Else If wParam = 2
350 | {
351 | SetTimer, Magnify, Off
352 | S_Pause := oZoom.Pause, oZoom.Pause := 0, Magnify(), oZoom.Pause := S_Pause
353 | SetTimer, Magnify, -10
354 | }
355 | Else If wParam = 3
356 | ZoomHide()
357 | Else If wParam = 4
358 | ZoomShow()
359 | Else If wParam = 5
360 | {
361 | oZoom.MemoryZoomSize := lParam
362 | If lParam
363 | GetClientPos(oZoom.hGui, GuiWidth, GuiHeight)
364 | , IniWrite(GuiWidth, "MemoryZoomSizeW")
365 | , IniWrite(GuiHeight, "MemoryZoomSizeH")
366 | }
367 | Else If (wParam = 6 && oZoom.Show)
368 | Gui, Zoom:Show, % "NA w" oZoom.GuiMinW " h" oZoom.GuiMinH
369 | Else If wParam = 7
370 | oZoom.AhkSpyPause := lParam
371 | Else If wParam = 8
372 | ActiveNoPause := lParam
373 | }
374 |
375 | EVENT_OBJECT_DESTROY(hWinEventHook, event, hwnd) {
376 | If (idObject || idChild || hwnd != hAhkSpy)
377 | Return
378 | ExitApp
379 | }
380 |
381 | EVENT_OBJECT_LOCATIONCHANGE(hWinEventHook, event, hwnd) {
382 | If (idObject || idChild || hwnd != hAhkSpy)
383 | Return
384 | ZoomMove()
385 | }
386 |
387 | EVENT_SYSTEM_MINIMIZESTART(hWinEventHook, event, hwnd) {
388 | If (idObject || idChild || hwnd != hAhkSpy)
389 | Return
390 | oZoom.Pause := 1
391 | }
392 |
393 | ; _________________________________________________ Sizing _________________________________________________
394 |
395 | WM_SETCURSOR(W, L, M, H) {
396 | Static SIZENWSE := DllCall("User32.dll\LoadCursor", "Ptr", NULL, "Int", 32642, "UPtr")
397 | , SIZENS := DllCall("User32.dll\LoadCursor", "Ptr", NULL, "Int", 32645, "UPtr")
398 | , SIZEWE := DllCall("User32.dll\LoadCursor", "Ptr", NULL, "Int", 32644, "UPtr")
399 | If (oZoom.SIZING = 2)
400 | Return
401 | If (W = oZoom.hGui)
402 | {
403 | MouseGetPos, mX, mY
404 | WinGetPos, WinX, WinY, WinW, WinH, % "ahk_id " oZoom.hDev
405 | If (mX > WinX && mY > WinY)
406 | {
407 | If (mX < WinX + WinW - 10)
408 | DllCall("User32.dll\SetCursor", "Ptr", SIZENS), oZoom.SIZINGType := "NS"
409 | Else If (mY < WinY + WinH)
410 | DllCall("User32.dll\SetCursor", "Ptr", SIZEWE), oZoom.SIZINGType := "WE"
411 | Else
412 | DllCall("User32.dll\SetCursor", "Ptr", SIZENWSE), oZoom.SIZINGType := "NWSE"
413 | Return oZoom.SIZING := 1
414 | }
415 | }
416 | Else
417 | oZoom.SIZING := 0, oZoom.SIZINGType := ""
418 | }
419 |
420 | LBUTTONDOWN(W, L, M, H) {
421 | If oZoom.SIZING
422 | {
423 | oZoom.SIZING := 2
424 | SetSystemCursor("SIZE" oZoom.SIZINGType)
425 | SetTimer, Sizing, -10
426 | KeyWait LButton
427 | SetTimer, Sizing, Off
428 | RestoreCursors()
429 | SetSize()
430 | oZoom.SIZING := 0, oZoom.SIZINGType := ""
431 | }
432 | }
433 |
434 | Sizing() {
435 | MouseGetPos, mX, mY
436 | WinGetPos, WinX, WinY, , , % "ahk_id " oZoom.hGui
437 | If (oZoom.SIZINGType = "NWSE" || oZoom.SIZINGType = "WE")
438 | Width := " w" (mX - WinX < oZoom.GuiMinW ? oZoom.GuiMinW : mX - WinX)
439 | If (oZoom.SIZINGType = "NWSE" || oZoom.SIZINGType = "NS")
440 | Height := " h" (mY - WinY < oZoom.GuiMinH ? oZoom.GuiMinH : mY - WinY)
441 | Gui, Zoom:Show, % "NA" Width . Height
442 | SetTimer, Sizing, -1
443 | }
444 |
445 | SetSystemCursor(CursorName, cx = 0, cy = 0) {
446 | Static SystemCursors := {ARROW:32512, IBEAM:32513, WAIT:32514, CROSS:32515, UPARROW:32516, SIZE:32640, ICON:32641, SIZENWSE:32642
447 | , SIZENESW:32643, SIZEWE:32644 ,SIZENS:32645, SIZEALL:32646, NO:32648, HAND:32649, APPSTARTING:32650, HELP:32651}
448 | Local CursorHandle, hImage, Name, ID
449 | If (CursorHandle := DllCall("LoadCursor", Uint, 0, Int, SystemCursors[CursorName]))
450 | For Name, ID in SystemCursors
451 | hImage := DllCall("CopyImage", Ptr, CursorHandle, Uint, 0x2, Int, cx, Int, cy, Uint, 0)
452 | , DllCall("SetSystemCursor", Ptr, hImage, Int, ID)
453 | }
454 |
455 | RestoreCursors() {
456 | Static SPI_SETCURSORS := 0x57
457 | DllCall("SystemParametersInfo", UInt, SPI_SETCURSORS, UInt, 0, UInt, 0, UInt, 0)
458 | }
459 |
--------------------------------------------------------------------------------
/Extra/iWB2 Learner.ahk:
--------------------------------------------------------------------------------
1 | #SingleInstance Force
2 | #Persistent
3 | #NoEnv
4 | #NoTrayIcon
5 | ListLines Off
6 | SetBatchLines -1
7 |
8 | WM_ACTIVATE = 0x06
9 | WM_KILLFOCUS = 0x08
10 | WM_LBUTTONDOWN = 0x201
11 | WM_LBUTTONUP = 0x202
12 | Stored := object( "AppName", "iWB2 Learner"
13 | , "TextLabel", "InnerText" )
14 |
15 | #NoEnv
16 | #NoTrayIcon
17 | #SingleInstance Force
18 | DetectHiddenWindows,on
19 | SetTitleMatchMode,slow
20 | SetTitleMatchMode,2
21 |
22 |
23 | ComObjError(false)
24 | OnMessage(WM_LBUTTONDOWN, "HandleMessage")
25 | OnExit, OnExitCleanup
26 | Menu, Main, Add, Show Parent Structure, ParentStructure
27 |
28 | Gui, Menu, Main
29 | Gui, Add, Edit, x61 y5 w255 h20 hwndTitleHwnd vTitle HWNDh1,
30 | Gui, Add, Edit, x61 y30 w255 h20 vURLL HWNDh2,
31 | Gui, Add, Edit, x36 y55 w50 h20 vEleIndex HWNDh3,
32 | Gui, Add, Edit, x120 y55 w90 h20 vEleName HWNDh4,
33 | Gui, Add, Edit, x226 y55 w90 h20 vEleIDs HWNDh5,
34 | Gui, Add, ListView, x6 y82 w310 h60 -LV0x10 AltSubmit vVarListView gSubListView NoSortHdr, % "Frame.#|index|name|id|"
35 | LV_ModifyCol(1, 65), LV_ModifyCol(2,49), LV_ModifyCol(3,87), LV_ModifyCol(4,87), LV_ModifyCol(2,"Center")
36 | Gui, Add, Edit, x11 y160 w302 h40 vhtml_text HWNDh6,
37 | Gui, Add, Edit, x10 y217 w302 h140 vhtml_value HWNDh7,
38 | Gui, Add, Text, x35 y7 w25 h20 +Center, Title
39 | Gui, Add, Text, x37 y33 w23 h20 +Center, Url
40 | Gui, Add, Text, x1 y56 w34 h20 +Center, Index
41 | Gui, Add, Text, x89 y57 w30 h21 +Center, Name
42 | Gui, Add, Text, x212 y58 w13 h20 +Center, ID
43 | Gui, Add, GroupBox, x6 y145 w310 h59 vText, InnerText
44 | Gui, Add, GroupBox, x6 y201 w310 h163 , OuterHTML
45 | Gui, Add, Text, x5 y3 w25 h26 Border gCrossHair ReadOnly HWNDh8 Border
46 | CColor(h8, "White")
47 | Gui, Add, Text, x5 y3 w25 h4 HWNDh9 Border
48 | CColor(h9, "0046D5")
49 | Gui, Add, Text, x8 y17 w19 h1 Border vHBar
50 | Gui, Add, Text, x17 y8 w1 h19 Border vVBar
51 | Gui, Font, S6
52 | Gui, Add, Text, x1 y32 w35 h26 +Center, DRAG CURSOR
53 | Gui, +AlwaysOnTop +Delimiter`n -DPIScale
54 | Gui, Show, Center h370 w322, % Stored.AppName
55 | Gui, +LastFoundExist
56 | WinSet, Redraw, , % "ahk_id" GuiWinHWND:=WinExist()
57 | ControlFocus, Static7, ahk_id %GuiWinHWND%
58 | Gui 2: +ToolWindow +AlwaysOnTop +Resize -DPIScale
59 | Gui 2: Add, TreeView, vTView R17
60 | Gui 2: Show, Hide, Parent Structure
61 | WinGetPos, , , 2GuiW, 2GuiH, % "ahk_id"
62 | . Stored.2GUIhwnd := WinExist("Parent Structure ahk_class AutoHotkeyGUI")
63 | Menu, RClickMenu, Add
64 | outline := Outline()
65 | Hotkey, ~LButton Up, Off
66 | return
67 |
68 | #vk53::
69 |
70 | ComObjCreate("SAPI.SpVoice").Speak(Stored.textOfObj)
71 | return
72 |
73 | ~Lbutton Up::
74 |
75 | Hotkey, ~LButton Up, Off
76 | Lbutton_Pressed := False
77 | if IsObject(Stored.BColor)
78 | Stored.BColor := ""
79 | else if Not CH {
80 | GuiControl, Show, HBar
81 | GuiControl, Show, VBar
82 | CrossHair(CH:=true)
83 |
84 | RemoveFocus()
85 | return
86 | }
87 | HandleMessage( p_w, p_l, p_m, p_hw ) {
88 | Gui, Submit, NoHide
89 | if (A_GuiControl = "VarListView") {
90 | global column_num
91 | VarSetCapacity( htinfo, 20 )
92 | , DllCall( "RtlFillMemory", "uint", &htinfo, "uint", 1, "uchar", p_l & 0xFF )
93 | , DllCall( "RtlFillMemory", "uint", &htinfo+1, "uint", 1, "uchar", ( p_l >> 8 ) & 0xFF )
94 | , DllCall( "RtlFillMemory", "uint", &htinfo+4, "uint", 1, "uchar", ( p_l >> 16 ) & 0xFF )
95 | , DllCall( "RtlFillMemory", "uint", &htinfo+5, "uint", 1, "uchar", ( p_l >> 24 ) & 0xFF )
96 | SendMessage, 0x1000+57, 0, &htinfo,, ahk_id %p_hw%
97 | If ( ErrorLevel = -1 )
98 | Return
99 | column_num := ( *( &htinfo+8 ) & 1 ) ? False : 1+*( &htinfo+16 )
100 | }
101 | else if (%A_GuiControl% != "") {
102 | temp := clipboard := %A_GuiControl%
103 | ToolTip, % "clipboard= " (StrLen(temp) > 40 ? SubStr(temp,1,40) "..." : temp)
104 | SetTimer, RemoveToolTip, 1000
105 | }
106 | else if (A_GuiControl = "TView") {
107 | Acc_ObjectFromPoint(child).accSelect(0x3, child)
108 | Hotkey, ~LButton Up, On
109 | global Stored
110 | if TV_GetParent(TVsel:=TV_GetSelection()) {
111 | TV_GetText(text, TVsel)
112 | RegExMatch(text, "\d+", child)
113 | clicked := Stored.pelt.childNodes[child]
114 | }
115 | else {
116 | clicked := Stored.pelt
117 | Loop, % TV_GetDiffCount(Stored.TVitem, TVsel)
118 | clicked := clicked.parentNode
119 | }
120 | Stored.BColor := BCobj(clicked, "silver")
121 | }
122 | RemoveFocus()
123 | }
124 | IE_HtmlElement() {
125 | static IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}", IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
126 | CoordMode, Mouse
127 | MouseGetPos, xpos, ypos,, hCtl, 3
128 | WinGetClass, sClass, ahk_id %hCtl%
129 | If Not sClass == "Internet Explorer_Server"
130 | || Not pdoc := ComObject(9,ComObjQuery(Acc_ObjectFromWindow(hCtl), IID_IHTMLWindow2, IID_IHTMLWindow2),1).document
131 | Return
132 | global outline, Stored, Frame := {}
133 | pwin := ComObject(9,ComObjQuery(pdoc, IID_IHTMLWindow2, IID_IHTMLWindow2),1)
134 | iWebBrowser2 := ComObject(9,ComObjQuery(pwin,IID_IWebBrowserApp,IID_IWebBrowserApp),1)
135 | if pelt := pwin.document.elementFromPoint( xpos-xorg:=pwin.screenLeft, ypos-yorg:=pwin.screenTop ) {
136 | Stored.LV := object()
137 | while (type:=pelt.tagName)="IFRAME" || type="FRAME" {
138 | selt .= A_Index ") **[sourceIndex]=" pelt.sourceindex " **[Name]= " pelt.name " **[ID]= " pelt.id "`n"
139 | , Stored.LV[A_Index, "C1"] := type "." A_Index
140 | , Stored.LV[A_Index, "C2"] := pelt.sourceindex
141 | , Stored.LV[A_Index, "C3"] := pelt.name
142 | , Stored.LV[A_Index, "C4"] := pelt.id
143 | , Frame[A_Index] := pelt
144 | , pwin := ComObject(9,ComObjQuery(pbrt:=pelt.contentWindow, IID_IHTMLWindow2, IID_IHTMLWindow2),1)
145 | , pdoc := pwin.document
146 | , Stored.LV[A_Index, "URL"] := pdoc.url
147 | , pbrt := pdoc.elementFromPoint( xpos-xorg+=pelt.getBoundingClientRect().left
148 | , ypos-yorg+=pelt.getBoundingClientRect().top )
149 | , pelt := pbrt
150 | }
151 | pbrt := pelt.getBoundingClientRect()
152 | , l := pbrt.left
153 | , t := pbrt.top
154 | , r := pbrt.right
155 | , b := pbrt.bottom
156 | if Not outline.visible
157 | || (Stored.pelt.sourceIndex != pelt.sourceIndex) {
158 | if selt
159 | Frect := Frame[Frame.maxIndex()].getBoundingClientRect()
160 | , Frame.x1 := xorg
161 | , Frame.y1 := yorg
162 | , Frame.x2 := FRect.right+xorg
163 | , Frame.y2 := FRect.bottom+yorg
164 | else,
165 | Frame.x1:=Frame.y1:=Frame.x2:=Frame.y2:= "NA"
166 | outline.transparent(true)
167 | , outline.hide()
168 | , coord := GetCoord( Stored.x1 := l+xorg
169 | , Stored.y1 := t+yorg
170 | , Stored.x2 := r+xorg
171 | , Stored.y2 := b+yorg
172 | , iWebBrowser2.HWND )
173 | , outline.show(coord.x1, coord.y1, coord.x2, coord.y2, coord.sides)
174 | , outline.setAbove( iWebBrowser2.HWND )
175 | , outline.transparent( false )
176 | }
177 | Sleep, 1
178 | if (Stored.selt != selt) {
179 | LV_Delete()
180 | Loop, % Stored.LV.MaxIndex()
181 | LV_Add( "" , Stored.LV[A_Index].C1
182 | , Stored.LV[A_Index].C2
183 | , Stored.LV[A_Index].C3
184 | , Stored.LV[A_Index].C4 )
185 | Stored.selt := selt
186 | }
187 | Stored.pelt := pelt
188 | , Stored.LocationName := iWebBrowser2.LocationName
189 | , Stored.LocationURL := iWebBrowser2.LocationURL
190 | GoSub, UpdateGuiControls
191 | Gui, Show, NA, % Stored.AppName " :: <" Stored.pelt.tagName ">"
192 | }
193 | }
194 | CrossHair:
195 | {
196 | if (A_GuiEvent = "Normal") {
197 | SetBatchLines, -1
198 | Hotkey, ~LButton Up, On
199 | {
200 | GuiControl, Hide, HBar
201 | GuiControl, Hide, VBar
202 | CrossHair(CH:=false)
203 | }
204 | Lbutton_Pressed := True
205 | while, Lbutton_Pressed
206 | IE_HtmlElement()
207 | outline.hide()
208 | if Stored.pelt.tagName != ""
209 | Gui, Show, NA, % Stored.AppName " :: <" Stored.pelt.tagName "> [" GetTagIndex(Stored.pelt) "]"
210 | if WinVisible("ahk_id" Stored.2GUIhwnd)
211 | GoSub, ParentStructure
212 | SetBatchLines, 10ms
213 | }
214 | return
215 | }
216 | OnExitCleanup:
217 | {
218 | CrossHair(true)
219 | GuiClose:
220 | ExitApp
221 | }
222 | UpdateGuiControls:
223 | {
224 | SetBatchLines, -1
225 | Gui, 1: Default
226 | textOfObj := inpt(Stored.pelt)
227 | GuiControl, , Title, % Stored.LocationName
228 | GuiControl, , URLL, % Stored.LocationURL
229 | GuiControl, , EleIndex, % Stored.pelt.sourceindex
230 | GuiControl, , EleName, % Stored.pelt.name
231 | GuiControl, , EleIDs, % Stored.pelt.id
232 | if (Stored.textOfObj != textOfObj)
233 | GuiControl, , html_text, % Stored.textOfObj:=textOfObj
234 | if (Stored.outerHTML != (val:=Stored.pelt.outerHTML) )
235 | GuiControl, , html_value, % Stored.outerHTML:=val
236 | textOfObj:=val:=""
237 | RemoveFocus()
238 | }
239 | SubListView:
240 | {
241 | if (A_GuiEvent = "Normal") {
242 | if (column_num = 1)
243 | LVselection := Stored.LV[A_EventInfo].url
244 | else,
245 | LV_GetText(LVselection, A_EventInfo, column_num)
246 | if LVselection {
247 | clipboard := LVSelection
248 | ToolTip, % "clipboard= " (StrLen(LVSelection) > 40 ? SubStr(LVSelection,1,40) "..." : LVSelection)
249 | SetTimer, RemoveToolTip, 1000
250 | }
251 | }
252 | Return
253 | }
254 | RemoveToolTip:
255 | {
256 | SetTimer, RemoveToolTip, off
257 | ToolTip
258 | return
259 | }
260 | ParentStructure:
261 | {
262 | {
263 | SetBatchLines, -1
264 | if Not Stored.pelt.tagName
265 | return
266 | nodes := object()
267 | elem := Stored.pelt
268 | Gui 2: Default
269 | TV_Delete()
270 | Loop {
271 | if A_Index != 1
272 | elem := elem.parentNode
273 | nodes.insert( 1, elem.tagName
274 | . (elem.id!=""? " id= """ elem.id """":"")
275 | . (elem.name!=""? " name= """ elem.name """":"") )
276 | } Until, elem.tagName = "html"
277 | GuiControl, -Redraw, TView
278 | For, Each, item in nodes
279 | Stored.TVitem := TV_Add(item)
280 | nodes := Stored.pelt.childNodes
281 | Loop, % nodes.length {
282 | elem := nodes.item(A_Index-1)
283 | TV_Add("[" A_Index-1 "] " elem.tagName
284 | . (elem.id!=""? " id= """ elem.id """":"")
285 | . (elem.name!=""? " name= """ elem.name """":"")
286 | , Stored.TVitem )
287 | }
288 | nodes:=elem:=""
289 | GuiControl, +Redraw, TView
290 | TV_Modify(Stored.TVitem, "Select Bold")
291 | if Not WinVisible("ahk_id" Stored.2GUIhwnd) {
292 | WinGetPos, x, y, w, , ahk_id %GuiWinHWND%
293 | WinMove, % "ahk_id" Stored.2GUIhwnd,
294 | , (x+w+2GuiW > A_ScreenWidth? x-2GuiW-5:x+w+5)
295 | , %y%, %2GuiW%, %2GuiH%
296 | WinShow, % "ahk_id" Stored.2GUIhwnd
297 | temp:=""
298 | }
299 | return
300 | }
301 | 2GuiClose:
302 | {
303 | Gui 2: Hide
304 | Gui 1: Default
305 | Stored.TVitem := ""
306 | return
307 | }
308 | 2GuiSize:
309 | {
310 | Anchor(TView, "wh")
311 | return
312 | }
313 | 2GuiContextMenu:
314 | {
315 | if (A_GuiControl = "TView") {
316 | Acc_ObjectFromPoint(child).accSelect(0x3, child)
317 | Menu, RClickMenu, DeleteAll
318 | TV_GetText(text, TV_GetSelection())
319 | if RegExMatch(text, "id= ""\K[^""]+", ElemID)
320 | Menu, RClickMenu, Add, Copy ID, RClick
321 | if RegExMatch(text, "name= ""\K[^""]+", ElemName)
322 | Menu, RClickMenu, Add, Copy Name, RClick
323 | Menu, RClickMenu, Add, Use Element, RClick
324 | Menu, RClickMenu, Show
325 | }
326 | return
327 | }
328 | RClick:
329 | {
330 | Gui, 2: +OwnDialogs
331 | if (A_ThisMenuItem = "Copy ID")
332 | clipboard := ElemID
333 | else if (A_ThisMenuItem = "Copy Name")
334 | clipboard := ElemName
335 | else if (A_ThisMenuItem = "Use Element") {
336 | temp := Stored.pelt
337 | Gui, 2: Default
338 | if TV_GetParent(TVsel:=TV_GetSelection()) {
339 | TV_GetText(text, TVsel)
340 | RegExMatch(text, "\d+", child)
341 | Stored.pelt := Stored.pelt.childNodes[child]
342 | }
343 | else,
344 | Loop, % TV_GetDiffCount(Stored.TVitem, TVsel)
345 | Stored.pelt := Stored.pelt.parentNode
346 | if Not Stored.pelt.sourceIndex {
347 | MsgBox, 262160, Selection Error, Cannot access this element.
348 | Stored.pelt := temp
349 | }
350 | else {
351 | Gui, 1: Default
352 | Gui, Show, NA, % Stored.AppName " :: <" Stored.pelt.tagName ">"
353 | . (Stored.pelt.tagName="HTML"? "":" [" GetTagIndex(Stored.pelt) "]")
354 | GoSub, UpdateGuiControls
355 | if WinVisible("ahk_id" Stored.2GUIhwnd)
356 | GoSub, ParentStructure
357 | }
358 | }
359 | ElemName:=ElemID:=TVsel:=child:=temp:=""
360 | return
361 | }
362 | }
363 | {
364 | Outline(color="red") {
365 | self := object( "base", object( "show", "Outline_Show"
366 | , "hide", "Outline_Hide"
367 | , "setAbove", "Outline_SetAbove"
368 | , "transparent", "Outline_Transparent"
369 | , "color", "Outline_Color"
370 | , "destroy", "Outline_Destroy"
371 | , "__delete", "Object_Delete" ) )
372 | Loop, 4 {
373 | Gui, % A_Index+95 ": -Caption +ToolWindow -DPIScale"
374 | Gui, % A_Index+95 ": Color", %color%
375 | Gui, % A_Index+95 ": Show", NA h0 w0, outline%A_Index%
376 | self[A_Index] := WinExist("outline" A_Index " ahk_class AutoHotkeyGUI")
377 | }
378 | self.visible := false
379 | , self.color := color
380 | , self.top := self[1]
381 | , self.right := self[2]
382 | , self.bottom := self[3]
383 | , self.left := self[4]
384 | Return, self
385 | }
386 | Outline_Show(self, x1, y1, x2, y2, sides="TRBL") {
387 | if InStr( sides, "T" )
388 | try Gui, 96:Show, % "NA X" x1-2 " Y" y1-2 " W" x2-x1+4 " H" 2,outline1
389 | Else, Gui, 96: Hide
390 | if InStr( sides, "R" )
391 | Gui, 97:Show, % "NA X" x2 " Y" y1 " W" 2 " H" y2-y1,outline2
392 | Else, Gui, 97: Hide
393 | if InStr( sides, "B" )
394 | Gui, 98:Show, % "NA X" x1-2 " Y" y2 " W" x2-x1+4 " H" 2,outline3
395 | Else, Gui, 98: Hide
396 | if InStr( sides, "L" )
397 | try Gui, 99:Show, % "NA X" x1-2 " Y" y1 " W" 2 " H" y2-y1,outline4
398 | Else, Gui, 99: Hide
399 | self.visible := true
400 | }
401 | Outline_Hide(self) {
402 | Loop, 4
403 | Gui, % A_Index+95 ": Hide"
404 | self.visible := false
405 | }
406 | Outline_SetAbove(self, hwnd) {
407 | ABOVE := DllCall("GetWindow", "uint", hwnd, "uint", 0x3)
408 | Loop, 4
409 | DllCall( "SetWindowPos", "uint", self[ A_Index ], "uint", ABOVE
410 | , "int", 0, "int", 0, "int", 0, "int", 0
411 | , "uint", 0x1|0x2|0x10 )
412 | }
413 | Outline_Transparent(self, param) {
414 | Loop, 4
415 | WinSet, Transparent, % param=1? 0:255, % "ahk_id" self[A_Index]
416 | self.visible := !param
417 | }
418 | Outline_Color(self, color) {
419 | Loop, 4
420 | Gui, % A_Index+95 ": Color" , %color%
421 | self.color := color
422 | }
423 | Outline_Destroy(self) {
424 | VarSetCapacity(self, 0)
425 | }
426 | Object_Delete() {
427 | Loop, 4
428 | Gui, % A_Index+95 ": Destroy"
429 | }
430 | }
431 | CrossHair(OnOff=1) {
432 | static AndMask, XorMask, $, h_cursor, IDC_CROSS := 32515
433 | ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13
434 | , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
435 | , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13
436 | if (OnOff = "Init" or OnOff = "I" or $ = "") {
437 | $ := "h"
438 | , VarSetCapacity( h_cursor,4444, 1 )
439 | , VarSetCapacity( AndMask, 32*4, 0xFF )
440 | , VarSetCapacity( XorMask, 32*4, 0 )
441 | , system_cursors := "32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650"
442 | StringSplit c, system_cursors, `,
443 | Loop, %c0%
444 | h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
445 | , h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
446 | , b%A_Index% := DllCall("LoadCursor", "Uint", "", "Int", IDC_CROSS, "Uint")
447 | }
448 | $ := (OnOff = 0 || OnOff = "Off" || $ = "h" && (OnOff < 0 || OnOff = "Toggle" || OnOff = "T")) ? "b" : "h"
449 | Loop, %c0%
450 | h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
451 | , DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
452 | }
453 | inpt(i) {
454 | global Stored
455 | tag := i.tagName
456 | if tag in BUTTON,INPUT,OPTION,SELECT,TEXTAREA
457 | {
458 | if (Stored.TextLabel = "InnerText")
459 | GuiControl, , Text, % Stored.TextLabel:="Value"
460 | return, i.value
461 | }
462 | if (Stored.TextLabel = "Value")
463 | GuiControl, , Text, % Stored.TextLabel:="InnerText"
464 | return, i.innerText
465 | }
466 | GetCoord( x1,y1,x2,y2, WinHWND ) {
467 | global Frame, outline
468 | WinGetPos, Wx, Wy, , , ahk_id %WinHWND%
469 | ControlGetPos, Cx1, Cy1, Cw, Ch, Internet Explorer_Server1, ahk_id %WinHWND%
470 | Cx1+=Wx
471 | , Cy1+=Wy
472 | , Cx2:=Cx1+Cw
473 | , Cy2:=Cy1+Ch
474 | Return, object( "x1", Value( x1,Cx1,Frame["x1"], ">" )
475 | , "y1", Value( y1,Cy1,Frame["y1"], ">" )
476 | , "x2", Value( x2,Cx2,Frame["x2"], "<" )
477 | , "y2", Value( y2,Cy2,Frame["y2"], "<" )
478 | , "sides", ( ElemCoord( y1,Cy1,Frame["y1"], ">" ) ? "T" : "" )
479 | . ( ElemCoord( x2,Cx2,Frame["x2"], "<" ) ? "R" : "" )
480 | . ( ElemCoord( y2,Cy2,Frame["y2"], "<" ) ? "B" : "" )
481 | . ( ElemCoord( x1,Cx1,Frame["x1"], ">" ) ? "L" : "" ) )
482 | }
483 | Value( E,C,F, option=">" ) {
484 | return, F+0=""? (option=">"? (E>=C? E:C) : (E<=C? E:C))
485 | : (option=">"? (E>=C? (E>=F? E:F) : (C>=F? C:F)) : (E<=C? (E<=F? E:F) : (C<=F? C:F)))
486 | }
487 | ElemCoord( E,C,F, option=">" ) {
488 | return, F+0=""? (option=">"? (E>=C? 1:0):(E<=C? 1:0))
489 | : (option=">"? (E>=C && E>=F? 1:0):(E<=C && E<=F? 1:0))
490 | }
491 | GetTagIndex(element) {
492 | if IsMemberOf(element, "sourceIndex")
493 | and (index:=element.sourceIndex)
494 | and (tags:=element.ownerDocument.all.tags(element.tagName))
495 | and (top:=tags.length, bottom:=0)
496 | Loop {
497 | test := Floor( (top+bottom)/2 )
498 | i := tags[test].sourceIndex
499 | if (index < i)
500 | top := test
501 | else if (index > i)
502 | bottom := test
503 | else,
504 | return, test
505 | }
506 | }
507 | IsMemberOf(obj, name) {
508 | return, DllCall(NumGet(NumGet(1*p:=ComObjUnwrap(obj))+A_PtrSize*5)
509 | , "Ptr", p
510 | , "Ptr", VarSetCapacity(iid,16,0)*0+&iid
511 | , "Ptr*", &name
512 | , "UInt", 1
513 | , "UInt", 1024
514 | , "Int*", dispID)=0
515 | && dispID+1, ObjRelease(p)
516 | }
517 | TV_GetDiffCount(p1, p2) {
518 | count = 0
519 | while, p1 != p2
520 | p1 := TV_GetPrev(p1)
521 | , count++
522 | return, count
523 | }
524 | WinVisible(WinTitle) {
525 | temp := A_DetectHiddenWindows
526 | DetectHiddenWindows, Off
527 | out := WinExist(WinTitle)
528 | DetectHiddenWindows, %temp%
529 | return, out
530 | }
531 | BCobj(elem, color) {
532 | static base := object("__delete","BCobj_Delete")
533 | return, object("elem",elem, "color",elem.style.backgroundColor, "base",base)
534 | , elem.style.backgroundColor := color
535 | }
536 | BCobj_Delete(self) {
537 | self.elem.style.backgroundColor := self.color
538 | }
539 | RemoveFocus() {
540 | global GuiWinHWND
541 | ControlGetFocus, focus, ahk_id %GuiWinHWND%
542 | if (SubStr(focus,1,4) == "Edit") {
543 | ControlGet, text, Selected, , %focus%, ahk_id %GuiWinHWND%
544 | if Not text
545 | ControlFocus, Static7, ahk_id %GuiWinHWND%
546 | }
547 | }
548 | CColor(Hwnd, Background="", Foreground="") {
549 | return CColor_(Background, Foreground, "", Hwnd+0)
550 | }
551 | CColor_(Wp, Lp, Msg, Hwnd) {
552 | static
553 | static WM_CTLCOLOREDIT=0x0133, WM_CTLCOLORLISTBOX=0x134, WM_CTLCOLORSTATIC=0x0138
554 | ,LVM_SETBKCOLOR=0x1001, LVM_SETTEXTCOLOR=0x1024, LVM_SETTEXTBKCOLOR=0x1026, TVM_SETTEXTCOLOR=0x111E, TVM_SETBKCOLOR=0x111D
555 | ,BS_CHECKBOX=2, BS_RADIOBUTTON=8, ES_READONLY=0x800
556 | ,CLR_NONE=-1, CSILVER=0xC0C0C0, CGRAY=0x808080, CWHITE=0xFFFFFF, CMAROON=0x80, CRED=0x0FF, CPURPLE=0x800080, CFUCHSIA=0xFF00FF,CGREEN=0x8000, CLIME=0xFF00, COLIVE=0x8080, CYELLOW=0xFFFF, CNAVY=0x800000, CBLUE=0xFF0000, CTEAL=0x808000, CAQUA=0xFFFF00
557 | ,CLASSES := "Button,ComboBox,Edit,ListBox,Static,RICHEDIT50W,SysListView32,SysTreeView32"
558 | If (Msg = "") {
559 | if !adrSetTextColor
560 | adrSetTextColor := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetTextColor")
561 | ,adrSetBkColor := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkColor")
562 | ,adrSetBkMode := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkMode")
563 | BG := !Wp ? "" : C%Wp% != "" ? C%Wp% : "0x" SubStr(WP,5,2) SubStr(WP,3,2) SubStr(WP,1,2)
564 | FG := !Lp ? "" : C%Lp% != "" ? C%Lp% : "0x" SubStr(LP,5,2) SubStr(LP,3,2) SubStr(LP,1,2)
565 | WinGetClass, class, ahk_id %Hwnd%
566 | If class not in %CLASSES%
567 | return A_ThisFunc "> Unsupported control class: " class
568 | ControlGet, style, Style, , , ahk_id %Hwnd%
569 | if (class = "Edit") && (Style & ES_READONLY)
570 | class := "Static"
571 | if (class = "Button")
572 | if (style & BS_RADIOBUTTON) || (style & BS_CHECKBOX)
573 | class := "Static"
574 | else return A_ThisFunc "> Unsupported control class: " class
575 | if (class = "ComboBox") {
576 | VarSetCapacity(CBBINFO, 52, 0), NumPut(52, CBBINFO), DllCall("GetComboBoxInfo", "UInt", Hwnd, "UInt", &CBBINFO)
577 | hwnd := NumGet(CBBINFO, 48)
578 | %hwnd%BG := BG, %hwnd%FG := FG, %hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : -1
579 | IfEqual, CTLCOLORLISTBOX,,SetEnv, CTLCOLORLISTBOX, % OnMessage(WM_CTLCOLORLISTBOX, A_ThisFunc)
580 | If NumGet(CBBINFO,44)
581 | Hwnd := Numget(CBBINFO,44), class := "Edit"
582 | }
583 | if class in SysListView32,SysTreeView32
584 | {
585 | m := class="SysListView32" ? "LVM" : "TVM"
586 | SendMessage, %m%_SETBKCOLOR, ,BG, ,ahk_id %Hwnd%
587 | SendMessage, %m%_SETTEXTCOLOR, ,FG, ,ahk_id %Hwnd%
588 | SendMessage, %m%_SETTEXTBKCOLOR, ,CLR_NONE, ,ahk_id %Hwnd%
589 | return
590 | }
591 | if (class = "RICHEDIT50W")
592 | return f := "RichEdit_SetBgColor", %f%(Hwnd, -BG)
593 | if (!CTLCOLOR%Class%)
594 | CTLCOLOR%Class% := OnMessage(WM_CTLCOLOR%Class%, A_ThisFunc)
595 | return %Hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : CLR_NONE, %Hwnd%BG := BG, %Hwnd%FG := FG
596 | }
597 | critical
598 | Hwnd := Lp + 0, hDC := Wp + 0
599 | If (%Hwnd%) {
600 | DllCall(adrSetBkMode, "uint", hDC, "int", 1)
601 | if (%Hwnd%FG)
602 | DllCall(adrSetTextColor, "UInt", hDC, "UInt", %Hwnd%FG)
603 | if (%Hwnd%BG)
604 | DllCall(adrSetBkColor, "UInt", hDC, "UInt", %Hwnd%BG)
605 | return (%Hwnd%)
606 | }
607 | }
608 | Acc_Init()
609 | {
610 | Static h
611 | If Not h
612 | h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
613 | }
614 | Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)
615 | {
616 | Acc_Init()
617 | If DllCall("oleacc\AccessibleObjectFromEvent", "Ptr", hWnd, "UInt", idObject, "UInt", idChild, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
618 | Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
619 | }
620 | Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "")
621 | {
622 | Acc_Init()
623 | If DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
624 | Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
625 | }
626 | Acc_ObjectFromWindow(hWnd, idObject = 0)
627 | {
628 | Acc_Init()
629 | If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
630 | Return ComObjEnwrap(9,pacc,1)
631 | }
632 | Acc_WindowFromObject(pacc)
633 | {
634 | If DllCall("oleacc\WindowFromAccessibleObject", "Ptr", IsObject(pacc)?ComObjValue(pacc):pacc, "Ptr*", hWnd)=0
635 | Return hWnd
636 | }
637 | Acc_GetRoleText(nRole)
638 | {
639 | nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0)
640 | VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize)
641 | DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1)
642 | Return sRole
643 | }
644 | Acc_GetStateText(nState)
645 | {
646 | nSize := DllCall("oleacc\GetStateText", "Uint", nState, "Ptr", 0, "Uint", 0)
647 | VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize)
648 | DllCall("oleacc\GetStateText", "Uint", nState, "str", sState, "Uint", nSize+1)
649 | Return sState
650 | }
651 | Acc_SetWinEventHook(eventMin, eventMax, pCallback)
652 | {
653 | Return DllCall("SetWinEventHook", "Uint", eventMin, "Uint", eventMax, "Uint", 0, "Ptr", pCallback, "Uint", 0, "Uint", 0, "Uint", 0)
654 | }
655 | Acc_UnhookWinEvent(hHook)
656 | {
657 | Return DllCall("UnhookWinEvent", "Ptr", hHook)
658 | }
659 | Acc_Role(Acc, ChildId=0) {
660 | try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetRoleText(Acc.accRole(ChildId)):"invalid object"
661 | }
662 | Acc_State(Acc, ChildId=0) {
663 | try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetStateText(Acc.accState(ChildId)):"invalid object"
664 | }
665 | Acc_Location(Acc, ChildId=0, byref Position="") {
666 | try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
667 | catch
668 | return
669 | Position := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
670 | return {x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")}
671 | }
672 | Acc_Parent(Acc) {
673 | try parent:=Acc.accParent
674 | return parent?Acc_Query(parent):
675 | }
676 | Acc_Child(Acc, ChildId=0) {
677 | try child:=Acc.accChild(ChildId)
678 | return child?Acc_Query(child):
679 | }
680 | Acc_Query(Acc) {
681 | try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
682 | }
683 | Acc_Error(p="") {
684 | static setting:=0
685 | return p=""?setting:setting:=p
686 | }
687 | Acc_Children(Acc) {
688 | if ComObjType(Acc,"Name") != "IAccessible"
689 | ErrorLevel := "Invalid IAccessible Object"
690 | else {
691 | Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
692 | if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
693 | Loop %cChildren%
694 | i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child):
695 | return Children.MaxIndex()?Children:
696 | } else
697 | ErrorLevel := "AccessibleChildren DllCall Failed"
698 | }
699 | if Acc_Error()
700 | throw Exception(ErrorLevel,-1)
701 | }
702 | Acc_ChildrenByRole(Acc, Role) {
703 | if ComObjType(Acc,"Name")!="IAccessible"
704 | ErrorLevel := "Invalid IAccessible Object"
705 | else {
706 | Acc_Init(), cChildren:=Acc.accChildCount, Children:=[]
707 | if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 {
708 | Loop %cChildren% {
709 | i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i)
710 | if NumGet(varChildren,i-8)=9
711 | AccChild:=Acc_Query(child), ObjRelease(child), Acc_Role(AccChild)=Role?Children.Insert(AccChild):
712 | else
713 | Acc_Role(Acc, child)=Role?Children.Insert(child):
714 | }
715 | return Children.MaxIndex()?Children:, ErrorLevel:=0
716 | } else
717 | ErrorLevel := "AccessibleChildren DllCall Failed"
718 | }
719 | if Acc_Error()
720 | throw Exception(ErrorLevel,-1)
721 | }
722 | Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
723 | static properties := {Action:"DefaultAction", DoAction:"DoDefaultAction", Keyboard:"KeyboardShortcut"}
724 | AccObj := IsObject(WinTitle)? WinTitle
725 | : Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 )
726 | if ComObjType(AccObj, "Name") != "IAccessible"
727 | ErrorLevel := "Could not access an IAccessible Object"
728 | else {
729 | StringReplace, ChildPath, ChildPath, _, %A_Space%, All
730 | AccError:=Acc_Error(), Acc_Error(true)
731 | Loop Parse, ChildPath, ., %A_Space%
732 | try {
733 | if A_LoopField is digit
734 | Children:=Acc_Children(AccObj), m2:=A_LoopField
735 | else
736 | RegExMatch(A_LoopField, "(\D*)(\d*)", m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1)
737 | if Not Children.HasKey(m2)
738 | throw
739 | AccObj := Children[m2]
740 | } catch {
741 | ErrorLevel:="Cannot access ChildPath Item #" A_Index " -> " A_LoopField, Acc_Error(AccError)
742 | if Acc_Error()
743 | throw Exception("Cannot access ChildPath Item", -1, "Item #" A_Index " -> " A_LoopField)
744 | return
745 | }
746 | Acc_Error(AccError)
747 | StringReplace, Cmd, Cmd, %A_Space%, , All
748 | properties.HasKey(Cmd)? Cmd:=properties[Cmd]:
749 | try {
750 | if (Cmd = "Location")
751 | AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
752 | , ret_val := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
753 | else if (Cmd = "Object")
754 | ret_val := AccObj
755 | else if Cmd in Role,State
756 | ret_val := Acc_%Cmd%(AccObj, ChildID+0)
757 | else if Cmd in ChildCount,Selection,Focus
758 | ret_val := AccObj["acc" Cmd]
759 | else
760 | ret_val := AccObj["acc" Cmd](ChildID+0)
761 | } catch {
762 | ErrorLevel := """" Cmd """ Cmd Not Implemented"
763 | if Acc_Error()
764 | throw Exception("Cmd Not Implemented", -1, Cmd)
765 | return
766 | }
767 | return ret_val, ErrorLevel:=0
768 | }
769 | if Acc_Error()
770 | throw Exception(ErrorLevel,-1)
771 | }
772 | Anchor(i, a = "", r = false) {
773 | static c, cs = 12, cx = 255, cl = 0, g, gs = 8, gl = 0, gpi, gw, gh, z = 0, k = 0xffff, ptr
774 | If z = 0
775 | VarSetCapacity(g, gs * 99, 0), VarSetCapacity(c, cs * cx, 0), ptr := A_PtrSize ? "Ptr" : "UInt", z := true
776 | If (!WinExist("ahk_id" . i)) {
777 | GuiControlGet, t, Hwnd, %i%
778 | If ErrorLevel = 0
779 | i := t
780 | Else ControlGet, i, Hwnd, , %i%
781 | }
782 | VarSetCapacity(gi, 68, 0), DllCall("GetWindowInfo", "UInt", gp := DllCall("GetParent", "UInt", i), ptr, &gi)
783 | , giw := NumGet(gi, 28, "Int") - NumGet(gi, 20, "Int"), gih := NumGet(gi, 32, "Int") - NumGet(gi, 24, "Int")
784 | If (gp != gpi) {
785 | gpi := gp
786 | Loop, %gl%
787 | If (NumGet(g, cb := gs * (A_Index - 1)) == gp, "UInt") {
788 | gw := NumGet(g, cb + 4, "Short"), gh := NumGet(g, cb + 6, "Short"), gf := 1
789 | Break
790 | }
791 | If (!gf)
792 | NumPut(gp, g, gl, "UInt"), NumPut(gw := giw, g, gl + 4, "Short"), NumPut(gh := gih, g, gl + 6, "Short"), gl += gs
793 | }
794 | ControlGetPos, dx, dy, dw, dh, , ahk_id %i%
795 | Loop, %cl%
796 | If (NumGet(c, cb := cs * (A_Index - 1), "UInt") == i) {
797 | If a =
798 | {
799 | cf = 1
800 | Break
801 | }
802 | giw -= gw, gih -= gh, as := 1, dx := NumGet(c, cb + 4, "Short"), dy := NumGet(c, cb + 6, "Short")
803 | , cw := dw, dw := NumGet(c, cb + 8, "Short"), ch := dh, dh := NumGet(c, cb + 10, "Short")
804 | Loop, Parse, a, xywh
805 | If A_Index > 1
806 | av := SubStr(a, as, 1), as += 1 + StrLen(A_LoopField)
807 | , d%av% += (InStr("yh", av) ? gih : giw) * (A_LoopField + 0 ? A_LoopField : 1)
808 | DllCall("SetWindowPos", "UInt", i, "UInt", 0, "Int", dx, "Int", dy
809 | , "Int", InStr(a, "w") ? dw : cw, "Int", InStr(a, "h") ? dh : ch, "Int", 4)
810 | If r != 0
811 | DllCall("RedrawWindow", "UInt", i, "UInt", 0, "UInt", 0, "UInt", 0x0101)
812 | Return
813 | }
814 | If cf != 1
815 | cb := cl, cl += cs
816 | bx := NumGet(gi, 48, "UInt"), by := NumGet(gi, 16, "Int") - NumGet(gi, 8, "Int") - gih - NumGet(gi, 52, "UInt")
817 | If cf = 1
818 | dw -= giw - gw, dh -= gih - gh
819 | NumPut(i, c, cb, "UInt"), NumPut(dx - bx, c, cb + 4, "Short"), NumPut(dy - by, c, cb + 6, "Short")
820 | , NumPut(dw, c, cb + 8, "Short"), NumPut(dh, c, cb + 10, "Short")
821 | Return, true
822 | }
823 |
--------------------------------------------------------------------------------
/Old/AhkSpy.ahk:
--------------------------------------------------------------------------------
1 | ; AhkSpy
2 |
3 | ; Автор - serzh82saratov
4 | ; E-Mail: serzh82saratov@mail.ru
5 |
6 | ; Спасибо wisgest за помощь в создании HTML интерфейса
7 | ; Также благодарность teadrinker, Malcev, YMP, Irbis за их решения
8 | ; Описание - http://forum.script-coding.com/viewtopic.php?pid=72459#p72459
9 | ; Обсуждение - http://forum.script-coding.com/viewtopic.php?pid=72244#p72244
10 | ; GitHub - https://github.com/serzh82saratov/AhkSpy/blob/master/AhkSpy.ahk
11 |
12 | #NoTrayIcon
13 | #SingleInstance Force
14 | #NoEnv
15 | SetBatchLines, -1
16 | ListLines, Off
17 | DetectHiddenWindows, On
18 | CoordMode, Pixel
19 |
20 | Global AhkSpyVersion := 2.52
21 | Gosub, CheckAhkVersion
22 | Menu, Tray, UseErrorLevel
23 | Menu, Tray, Icon, Shell32.dll, % A_OSVersion = "WIN_XP" ? 222 : 278
24 |
25 | Global ThisMode := "Mouse" ; Стартовый режим - Win|Mouse|Hotkey
26 | , MemoryFontSize := IniRead("MemoryFontSize", 0)
27 | , FontSize := MemoryFontSize ? IniRead("FontSize", "15") : 15 ; Размер шрифта
28 | , FontFamily := "Arial" ; Шрифт - Times New Roman | Georgia | Myriad Pro | Arial
29 | , ColorFont := "" ; Цвет шрифта
30 | , ColorBg := ColorBgOriginal := "F8F8F8" ; Цвет фона "F0F0F0" E4E4E4
31 | , ColorBgPaused := "F0F0F0" ; Цвет фона при паузе
32 | , ColorSelMouseHover := "#96C3DC" ; Цвет фона элемента при наведении мыши
33 | , ColorDelimiter := "E14B30" ; Цвет шрифта разделителя заголовков и параметров
34 | , ColorTitle := "27419B" ; Цвет шрифта заголовка
35 | , ColorParam := "189200" ; Цвет шрифта параметров
36 | , # := "▪" ; Символ разделителя заголовков - • | ▪
37 |
38 | , DP := " " # " ", D1, D2, DB
39 | , copy_button := ""
40 | , ThisMode := IniRead("StartMode", "Mouse"), ThisMode := ThisMode = "LastMode" ? IniRead("LastMode", "Mouse") : ThisMode
41 | , ActiveNoPause := IniRead("ActiveNoPause", 0), MemoryPos := IniRead("MemoryPos", 0), MemorySize := IniRead("MemorySize", 0)
42 | , MemoryZoomSize := IniRead("MemoryZoomSize", 0), MemoryStateZoom := IniRead("MemoryStateZoom", 0), StateLight := IniRead("StateLight", 1)
43 | , StateLightAcc := IniRead("StateLightAcc", 1), SendCode := IniRead("SendCode", "vk"), StateLightMarker := IniRead("StateLightMarker", 1)
44 | , StateUpdate := IniRead("StateUpdate", 1), SendMode := IniRead("SendMode", "send"), SendModeStr := Format("{:L}", SendMode)
45 | , StateAllwaysSpot := IniRead("AllwaysSpot", 0), ScrollPos := {}, AccCoord := [], oOther := {}, oFind := {}, Edits := [], oMS := {}
46 | , hGui, hActiveX, hMarkerGui, hMarkerAccGui, hFindGui, oDoc, ShowMarker, isFindView, isIE, isPaused, w_ShowStyles, MsgAhkSpyZoom, Sleep
47 | , HTML_Win, HTML_Mouse, HTML_Hotkey, o_edithotkey, o_editkeyname, rmCtrlX, rmCtrlY, widthTB, HeigtButton, FullScreenMode
48 | , pause_button := ""
49 | , set_button_pos := " w%WinWidth% h%WinHeight%%DP%%WinX%, %WinY%, %WinX2%, %WinY2%%DP%%WinX%, %WinY%, %WinWidth%, %WinHeight%
490 | Client area size: w%caW% h%caH%%DP%left %caX% top %caY% right %caWinRight% bottom %caWinBottom%
491 | %D1% ( Other ) %D2%
492 | PID: %WinPID%%DP%%ProcessBitSize%Window count this PID: %WinCountProcess%%DP%
627 | %D1% ( Mouse ) %DB% %pause_button%%m_run_AhkSpyZoom% %D2% 628 | %set_button_mouse_pos%Screen: x%MXS% y%MYS%%DP%%set_button_mouse_pos%Window: x%RWinX% y%RWinY%%DP%%set_button_mouse_pos%Client: x%MXC% y%MYC%%WithRespectWin%%DP%%WithRespectClient% 629 | Relative active window: x%MXWA% y%MYWA%%DP%exe %ProcessName_A% class %WinClass_A% hwnd %HWND_A% 630 | %D1% ( PixelGetColor ) %D2% 631 | RGB: %ColorRGB%%DP%#%sColorRGB%%DP%BGR: %ColorBGR%%DP%#%sColorBGR% 632 | %D1% ( Window: Class & Process & HWND ) %D2% 633 | ahk_class %WinClass% ahk_exe %ProcessName% ahk_id %WinID% 634 | %D1% ( Control ) %D2% 635 | Class NN: %ControlNN%%DP%Win class: %CtrlClass% 636 | %set_button_pos%Pos: x%CtrlX% y%CtrlY%%DP%x²%CtrlX2% y²%CtrlY2%%DP%%set_button_pos%Size: w%CtrlW% h%CtrlH%%DP%%CtrlX%, %CtrlY%, %CtrlX2%, %CtrlY2%%DP%%CtrlX%, %CtrlY%, %CtrlW%, %CtrlH% 637 | Pos relative client area: x%CtrlCAX% y%CtrlCAY%%DP%x²%CtrlCAX2% y²%CtrlCAY2%%DP%%CtrlCAX%, %CtrlCAY%, %CtrlCAX2%, %CtrlCAY2%%DP%%CtrlCAX%, %CtrlCAY%, %CtrlW%, %CtrlH% 638 | %set_button_mouse_pos%Mouse relative control: x%rmCtrlX% y%rmCtrlY%%WithRespectControl%%DP%Client area: x%caX% y%caY% w%caW% h%caH% 639 | HWND: %ControlID%%DP%Style: %CtrlStyle%%DP%ExStyle: %CtrlExStyle% 640 | %set_button_focus_ctrl%Focus control: %CtrlFocus%%DP%Cursor type: %A_Cursor%%DP%Caret pos: x%A_CaretX% y%A_CaretY%%CtrlInfo%%CtrlText%%AccText% 641 | %D2%642 | 643 | 653 | ) 654 | oOther.MouseControlID := ControlID 655 | oOther.MouseWinID := WinID 656 | Return 1 657 | } 658 | 659 | Write_Mouse() { 660 | oDoc.body.innerHTML := HTML_Mouse, oDoc.getElementById("pre").style.fontSize := FontSize 661 | oDoc.getElementById("pre").style.wordWrap := WordWrap ? "break-word" : "normal" 662 | Return 1 663 | } 664 | 665 | ; _________________________________________________ Get Info Control _________________________________________________ 666 | 667 | GetInfo_SysListView(hwnd, ByRef ClassNN) { 668 | ClassNN := "SysListView32" 669 | ControlGet, ListText, List,,, ahk_id %hwnd% 670 | ControlGet, RowCount, List, Count,, ahk_id %hwnd% 671 | ControlGet, ColCount, List, Count Col,, ahk_id %hwnd% 672 | ControlGet, SelectedCount, List, Count Selected,, ahk_id %hwnd% 673 | ControlGet, FocusedCount, List, Count Focused,, ahk_id %hwnd% 674 | Return "`nRow count: " RowCount "" DP 675 | . "Column count: " ColCount "`n" 676 | . "Selected count: " SelectedCount "" DP 677 | . "Focused row: " FocusedCount "" 678 | . "`n" D1 " ( Content ) " D2 "`n" TransformHTML(ListText) "" 679 | } 680 | 681 | GetInfo_SysTreeView(hwnd, ByRef ClassNN) { 682 | ClassNN := "SysTreeView32" 683 | SendMessage 0x1105, 0, 0, , ahk_id %hwnd% ; TVM_GETCOUNT 684 | ItemCount := ErrorLevel 685 | Return "`nItem count: " ItemCount "" 686 | } 687 | 688 | GetInfo_ListBox(hwnd, ByRef ClassNN) { 689 | ClassNN = ListBox 690 | Return GetInfo_ComboBox(hwnd, "") 691 | } 692 | GetInfo_TListBox(hwnd, ByRef ClassNN) { 693 | ClassNN = TListBox 694 | Return GetInfo_ComboBox(hwnd, "") 695 | } 696 | GetInfo_TComboBox(hwnd, ByRef ClassNN) { 697 | ClassNN = TComboBox 698 | Return GetInfo_ComboBox(hwnd, "") 699 | } 700 | GetInfo_ComboBox(hwnd, ByRef ClassNN) { 701 | ClassNN = ComboBox 702 | ControlGet, ListText, List,,, ahk_id %hwnd% 703 | SendMessage, 0x147, 0, 0, , ahk_id %hwnd% ; CB_GETCURSEL 704 | SelPos := ErrorLevel 705 | SelPos := SelPos = 0xffffffff || SelPos < 0 ? "NoSelect" : SelPos + 1 706 | RegExReplace(ListText, "m`a)$", "", RowCount) 707 | Return "`nRow count: " RowCount "" DP 708 | . "Row selected: " SelPos "" 709 | . "`n" D1 " ( Content ) " D2 "`n" TransformHTML(ListText) "" 710 | } 711 | 712 | GetInfo_CtrlNotifySink(hwnd, ByRef ClassNN) { 713 | ClassNN = CtrlNotifySink 714 | Return GetInfo_Scintilla(hwnd, "") 715 | } 716 | 717 | ; http://forum.script-coding.com/viewtopic.php?pid=117128#p117128 718 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms645478(v=vs.85).aspx 719 | 720 | GetInfo_Edit(hwnd, ByRef ClassNN) { 721 | ClassNN = Edit 722 | Return GetInfo_Scintilla(hwnd, "") "`nDlgCtrlID: " DllCall("GetDlgCtrlID", Ptr, hwnd) "" 723 | } 724 | 725 | GetInfo_Scintilla(hwnd, ByRef ClassNN) { 726 | ClassNN = Scintilla 727 | ControlGet, LineCount, LineCount,,, ahk_id %hwnd% 728 | ControlGet, CurrentCol, CurrentCol,,, ahk_id %hwnd% 729 | ControlGet, CurrentLine, CurrentLine,,, ahk_id %hwnd% 730 | ControlGet, Selected, Selected,,, ahk_id %hwnd% 731 | SendMessage, 0x00B0, , , , ahk_id %hwnd% ; EM_GETSEL 732 | EM_GETSEL := ErrorLevel >> 16 733 | SendMessage, 0x00CE, , , , ahk_id %hwnd% ; EM_GETFIRSTVISIBLELINE 734 | EM_GETFIRSTVISIBLELINE := ErrorLevel + 1 735 | ; Control_GetFont(hwnd, FName, FSize) 736 | Return "`nRow count: " LineCount "" DP 737 | . "Selected length: " StrLen(Selected) "" 738 | . "`nCurrent row: " CurrentLine "" DP 739 | . "Current column: " CurrentCol "" 740 | . "`nCurrent select: " EM_GETSEL "" DP 741 | . "First visible line: " EM_GETFIRSTVISIBLELINE "" 742 | ; . "`nFontSize: " FSize DP "FontName: " FName 743 | } 744 | 745 | Control_GetFont(hwnd, byref FontName, byref FontSize) { 746 | SendMessage 0x31, 0, 0, , ahk_id %hwnd% ; WM_GETFONT 747 | IfEqual, ErrorLevel, FAIL, Return 748 | hFont := Errorlevel, VarSetCapacity(LF, szLF := 60 * (A_IsUnicode ? 2 : 1)) 749 | DllCall("GetObject", UInt, hFont, Int, szLF, UInt, &LF) 750 | hDC := DllCall("GetDC", UInt,hwnd ), DPI := DllCall("GetDeviceCaps", UInt, hDC, Int, 90) 751 | DllCall("ReleaseDC", Int, 0, UInt, hDC), S := Round((-NumGet(LF, 0, "Int") * 72) / DPI) 752 | FontName := DllCall("MulDiv", Int, &LF + 28, Int, 1, Int, 1, Str) 753 | DllCall("SetLastError", UInt, S), FontSize := A_LastError 754 | } 755 | 756 | GetInfo_msctls_progress(hwnd, ByRef ClassNN) { 757 | ClassNN := "msctls_progress32" 758 | SendMessage, 0x0400+7,"TRUE",,, ahk_id %hwnd% ; PBM_GETRANGE 759 | PBM_GETRANGEMIN := ErrorLevel 760 | SendMessage, 0x0400+7,,,, ahk_id %hwnd% ; PBM_GETRANGE 761 | PBM_GETRANGEMAX := ErrorLevel 762 | SendMessage, 0x0400+8,,,, ahk_id %hwnd% ; PBM_GETPOS 763 | PBM_GETPOS := ErrorLevel 764 | Return "`nLevel: " PBM_GETPOS "" DP 765 | . "Range: Min: " PBM_GETRANGEMIN "" 766 | . " Max: " PBM_GETRANGEMAX "" 767 | } 768 | 769 | GetInfo_msctls_trackbar(hwnd, ByRef ClassNN) { 770 | ClassNN := "msctls_trackbar32" 771 | SendMessage, 0x0400+1,,,, ahk_id %hwnd% ; TBM_GETRANGEMIN 772 | TBM_GETRANGEMIN := ErrorLevel 773 | SendMessage, 0x0400+2,,,, ahk_id %hwnd% ; TBM_GETRANGEMAX 774 | TBM_GETRANGEMAX := ErrorLevel 775 | SendMessage, 0x0400,,,, ahk_id %hwnd% ; TBM_GETPOS 776 | TBM_GETPOS := ErrorLevel 777 | ControlGet, CtrlStyle, Style,,, ahk_id %hwnd% 778 | (!(CtrlStyle & 0x0200)) ? (TBS_REVERSED := "No") 779 | : (TBM_GETPOS := TBM_GETRANGEMAX - (TBM_GETPOS - TBM_GETRANGEMIN), TBS_REVERSED := "Yes") 780 | Return "`nLevel: " TBM_GETPOS "" DP 781 | . "Invert style:" TBS_REVERSED 782 | . "`nRange: Min: " TBM_GETRANGEMIN "" DP 783 | . "Max: " TBM_GETRANGEMAX "" 784 | } 785 | 786 | GetInfo_msctls_updown(hwnd, ByRef ClassNN) { 787 | ClassNN := "msctls_updown32" 788 | SendMessage, 0x0400+102,,,, ahk_id %hwnd% ; UDM_GETRANGE 789 | UDM_GETRANGE := ErrorLevel 790 | SendMessage, 0x400+114,,,, ahk_id %hwnd% ; UDM_GETPOS32 791 | UDM_GETPOS32 := ErrorLevel 792 | Return "`nLevel: " UDM_GETPOS32 "" DP 793 | . "Range: Min: " UDM_GETRANGE >> 16 "" 794 | . " Max: " UDM_GETRANGE & 0xFFFF "" 795 | } 796 | 797 | GetInfo_SysTabControl(hwnd, ByRef ClassNN) { 798 | ClassNN := "SysTabControl32" 799 | ControlGet, SelTab, Tab,,, ahk_id %hwnd% 800 | SendMessage, 0x1300+44,,,, ahk_id %hwnd% ; TCM_GETROWCOUNT 801 | TCM_GETROWCOUNT := ErrorLevel 802 | SendMessage, 0x1300+4,,,, ahk_id %hwnd% ; TCM_GETITEMCOUNT 803 | TCM_GETITEMCOUNT := ErrorLevel 804 | Return "`nItem count: " TCM_GETITEMCOUNT "" DP 805 | . "Row count: " TCM_GETROWCOUNT "" DP 806 | . "Selected item: " SelTab "" 807 | } 808 | 809 | GetInfo_ToolbarWindow(hwnd, ByRef ClassNN) { 810 | ClassNN := "ToolbarWindow32" 811 | SendMessage, 0x0418,,,, ahk_id %hwnd% ; TB_BUTTONCOUNT 812 | BUTTONCOUNT := ErrorLevel 813 | Return "`nButton count: " BUTTONCOUNT "" 814 | } 815 | 816 | ; _________________________________________________ Get Internet Explorer Info _________________________________________________ 817 | 818 | ; http://www.autohotkey.com/board/topic/84258-iwb2-learner-iwebbrowser2/ 819 | 820 | GetInfo_AtlAxWin(hwnd, ByRef ClassNN) { 821 | ClassNN = AtlAxWin 822 | Return GetInfo_InternetExplorer_Server(hwnd, "") 823 | } 824 | 825 | GetInfo_InternetExplorer_Server(hwnd, ByRef ClassNN) { 826 | Static IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}" 827 | , ratios := [], IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}" 828 | 829 | isIE := 1, ClassNN := "Internet Explorer_Server" 830 | MouseGetPos, , , , hwnd, 3 831 | If !(pwin := WBGet(hwnd)) 832 | Return 833 | If !ratios[hwnd] 834 | { 835 | ratio := pwin.window.screen.deviceXDPI / pwin.window.screen.logicalXDPI 836 | Sleep 10 ; при частом запросе deviceXDPI, возвращает пусто 837 | !ratio && (ratio := 1) 838 | ratios[hwnd] := ratio 839 | } 840 | ratio := ratios[hwnd] 841 | pelt := pwin.document.elementFromPoint(rmCtrlX / ratio, rmCtrlY / ratio) 842 | Tag := pelt.TagName 843 | If (Tag = "IFRAME" || Tag = "FRAME") { 844 | If pFrame := ComObjQuery(pwin.document.parentWindow.frames[pelt.id], IID_IHTMLWindow2, IID_IHTMLWindow2) 845 | iFrame := ComObject(9, pFrame, 1) 846 | Else 847 | iFrame := ComObj(9, ComObjQuery(pelt.contentWindow, IID_IHTMLWindow2, IID_IHTMLWindow2), 1) 848 | WB2 := ComObject(9, ComObjQuery(pelt.contentWindow, IID_IWebBrowserApp, IID_IWebBrowserApp), 1) 849 | If ((Var := WB2.LocationName) != "") 850 | Frame .= "`nTitle: " Var "" 851 | If ((Var := WB2.LocationURL) != "") 852 | Frame .= "`nURL: " Var "" 853 | If (iFrame.length) 854 | Frame .= "`nCount frames: " iFrame.length "" 855 | If (Tag != "") 856 | Frame .= "`nTagName: " Tag "" 857 | If ((Var := pelt.id) != "") 858 | Frame .= "`nID: " Var "" 859 | If ((Var := pelt.ClassName) != "") 860 | Frame .= "`nClass: " Var "" 861 | If ((Var := pelt.sourceIndex) != "") 862 | Frame .= "`nIndex: " Var "" 863 | If ((Var := pelt.name) != "") 864 | Frame .= "`nName: " TransformHTML(Var) "" 865 | 866 | If ((Var := pelt.OuterHtml) != "") { 867 | code = `n%D1% ( Outer HTML ) %D2%`n 868 | Frame .= code "" TransformHTML(Var) "" 869 | } 870 | If ((Var := pelt.OuterText) != "") { 871 | code = `n%D1% ( Outer Text ) %D2%`n 872 | Frame .= code "" TransformHTML(Var) "" 873 | } 874 | If Frame != 875 | Frame = `n%D1% ( FrameInfo ) %D2%%Frame% 876 | _pbrt := pelt.getBoundingClientRect() 877 | pelt := iFrame.document.elementFromPoint((rmCtrlX / ratio) - _pbrt.left, (rmCtrlY / ratio) - _pbrt.top) 878 | __pbrt := pelt.getBoundingClientRect(), pbrt := {} 879 | pbrt.left := __pbrt.left + _pbrt.left, pbrt.right := __pbrt.right + _pbrt.left 880 | pbrt.top := __pbrt.top + _pbrt.top, pbrt.bottom := __pbrt.bottom + _pbrt.top 881 | } 882 | Else 883 | pbrt := pelt.getBoundingClientRect() 884 | 885 | WB2 := ComObject(9, ComObjQuery(pwin, IID_IWebBrowserApp, IID_IWebBrowserApp), 1) 886 | If ((Location := WB2.LocationName) != "") 887 | Location = `nTitle: %Location% 888 | If ((URL := WB2.LocationURL) != "") 889 | URL = `nURL: %URL% 890 | If ((Var := pelt.id) != "") 891 | Info .= "`nID: " Var "" 892 | If ((Var := pelt.ClassName) != "") 893 | Info .= "`nClass: " Var "" 894 | If ((Var := pelt.sourceIndex) != "") 895 | Info .= "`nIndex: " Var "" 896 | If ((Var := pelt.name) != "") 897 | Info .= "`nName: " TransformHTML(Var) "" 898 | 899 | If ((Var := pelt.OuterHtml) != "") { 900 | code = `n%D1% ( Outer HTML ) %D2%`n 901 | Info .= code "" TransformHTML(Var) "" 902 | } 903 | If ((Var := pelt.OuterText) != "") { 904 | code = `n%D1% ( Outer Text ) %D2%`n 905 | Info .= code "" TransformHTML(Var) "" 906 | } 907 | x1 := pbrt.left * ratio, y1 := pbrt.top * ratio 908 | x2 := pbrt.right * ratio, y2 := pbrt.bottom * ratio 909 | If (ThisMode = "Mouse") && (StateLight = 1 || (StateLight = 3 && GetKeyState("Shift", "P"))) 910 | { 911 | WinGetPos, sX, sY, , , ahk_id %hwnd% 912 | StateLightMarker ? ShowMarker(sX + x1, sY + y1, x2 - x1, y2 - y1) : 0 913 | StateLightAcc ? ShowAccMarker(AccCoord[1], AccCoord[2], AccCoord[3], AccCoord[4]) : 0 914 | } 915 | If Info != 916 | Info := "`n" D1 " ( Tag name: " pelt.TagName " )" (Frame ? " " # " ( in frame )" : "") " " D2 917 | . "`nPos: x" Round(x1) " y" Round(y1) "" 918 | . DP "Size: w" Round(x2 - x1) " h" Round(y2 - y1) "" Info 919 | ObjRelease(pwin), ObjRelease(pelt), ObjRelease(WB2), ObjRelease(iFrame), ObjRelease(pbrt) 920 | Return Location URL Info Frame 921 | } 922 | 923 | WBGet(hwnd) { 924 | Static Msg := DllCall("RegisterWindowMessage", "Str", "WM_HTML_GETOBJECT") 925 | , IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}" 926 | SendMessage, Msg, , , , ahk_id %hwnd% 927 | DllCall("oleacc\ObjectFromLresult", "Ptr", ErrorLevel, "Ptr", 0, "Ptr", 0, PtrP, pdoc) 928 | Return ComObj(9, ComObjQuery(pdoc, IID_IHTMLWindow2, IID_IHTMLWindow2), 1), ObjRelease(pdoc) 929 | } 930 | 931 | ; _________________________________________________ Get Acc Info _________________________________________________ 932 | 933 | ; http://www.autohotkey.com/board/topic/77888-accessible-info-viewer-alpha-release-2012-09-20/ 934 | 935 | AccInfoUnderMouse(x, y, wx, wy, cx, cy) { 936 | Static h 937 | If Not h 938 | h := DllCall("LoadLibrary","Str","oleacc","Ptr") 939 | If DllCall("oleacc\AccessibleObjectFromPoint" 940 | , "Int64", x&0xFFFFFFFF|y<<32, "Ptr*", pacc 941 | , "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild) = 0 942 | Acc := ComObjEnwrap(9,pacc,1), child := NumGet(varChild,8,"UInt") 943 | If !IsObject(Acc) 944 | Return 945 | Type := child ? "Child" DP "Id: " child "" 946 | : "Parent" DP "ChildCount: " ((C := Acc.accChildCount) != "" ? "" C "" : "N/A") 947 | code = `nType: %Type% 948 | code = %code%`n%D1% ( Position relative ) %D2%`n 949 | code .= "Screen: " AccGetLocation(Acc, child) 950 | . "`nMouse: x" x - AccCoord[1] " y" y - AccCoord[2] "" 951 | . DP "Window: x" AccCoord[1] - wx " y" AccCoord[2] - wy "" 952 | . (cx != "" ? DP "Control: x" (AccCoord[1] - wx - cx) " y" (AccCoord[2] - wy - cy) "" : "") 953 | 954 | If ((Name := Acc.accName(child)) != "") { 955 | code = %code%`n%D1% ( Name ) %D2%`n 956 | code .= "" TransformHTML(Name) "" 957 | } 958 | If ((Value := Acc.accValue(child)) != "") { 959 | code = %code%`n%D1% ( Value ) %D2%`n 960 | code .= "" TransformHTML(Value) "" 961 | } 962 | If ((State := AccGetStateText(StateCode := Acc.accState(child))) != "") { 963 | code = %code%`n%D1% ( State ) %D2%`n 964 | code .= "" TransformHTML(State) "" 965 | . DP "code: " StateCode "" 966 | } 967 | If ((Role := AccRole(Acc, child)) != "") { 968 | code = %code%`n%D1% ( Role ) %D2%`n 969 | code .= "" TransformHTML(Role) "" 970 | . DP "code: " Acc.accRole(child) "" 971 | } 972 | If (child &&(ObjRole := AccRole(Acc)) != "") { 973 | code = %code%`n%D1% ( Role - parent ) %D2%`n 974 | code .= "" TransformHTML(ObjRole) "" 975 | . DP "code: " Acc.accRole(0) "" 976 | } 977 | If ((Action := Acc.accDefaultAction(child)) != "") { 978 | code = %code%`n%D1% ( Action ) %D2%`n 979 | code .= "" TransformHTML(Action) "" 980 | } 981 | If ((Selection := Acc.accSelection) > 0) { 982 | code = %code%`n%D1% ( Selection - parent ) %D2%`n 983 | code .= "" TransformHTML(Selection) "" 984 | } 985 | If ((Focus := Acc.accFocus) > 0) { 986 | code = %code%`n%D1% ( Focus - parent ) %D2%`n 987 | code .= "" TransformHTML(Focus) "" 988 | } 989 | If ((Description := Acc.accDescription(child)) != "") { 990 | code = %code%`n%D1% ( Description ) %D2%`n 991 | code .= "" TransformHTML(Description) "" 992 | } 993 | If ((ShortCut := Acc.accKeyboardShortCut(child)) != "") { 994 | code = %code%`n%D1% ( ShortCut ) %D2%`n 995 | code .= "" TransformHTML(ShortCut) "" 996 | } 997 | If ((Help := Acc.accHelp(child)) != "") { 998 | code = %code%`n%D1% ( Help ) %D2%`n 999 | code .= "" TransformHTML(Help) "" 1000 | } 1001 | If ((HelpTopic := Acc.AccHelpTopic(child))) { 1002 | code = %code%`n%D1% ( HelpTopic ) %D2%`n 1003 | code .= "" TransformHTML(HelpTopic) "" 1004 | } 1005 | Return code 1006 | } 1007 | 1008 | AccRole(Acc, ChildId=0) { 1009 | Return ComObjType(Acc, "Name") = "IAccessible" ? AccGetRoleText(Acc.accRole(ChildId)) : "" 1010 | } 1011 | 1012 | AccGetRoleText(nRole) { 1013 | nSize := DllCall("oleacc\GetRoleText", "UInt", nRole, "Ptr", 0, "UInt", 0) 1014 | VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize) 1015 | DllCall("oleacc\GetRoleText", "UInt", nRole, "str", sRole, "UInt", nSize+1) 1016 | Return sRole 1017 | } 1018 | 1019 | AccGetStateText(nState) { 1020 | nSize := DllCall("oleacc\GetStateText", "UInt", nState, "Ptr", 0, "UInt", 0) 1021 | VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize) 1022 | DllCall("oleacc\GetStateText", "UInt", nState, "str", sState, "UInt", nSize+1) 1023 | Return sState 1024 | } 1025 | 1026 | AccGetLocation(Acc, Child=0) { 1027 | Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), Child) 1028 | Return "x" (AccCoord[1]:=NumGet(x,0,"int")) " y" (AccCoord[2]:=NumGet(y,0,"int")) "" 1029 | . DP "Size: w" (AccCoord[3]:=NumGet(w,0,"int")) " h" (AccCoord[4]:=NumGet(h,0,"int")) "" 1030 | } 1031 | 1032 | ; _________________________________________________ Mode_Hotkey _________________________________________________ 1033 | 1034 | Mode_Hotkey: 1035 | Try SetTimer, Loop_%ThisMode%, Off 1036 | If ThisMode = Hotkey 1037 | oDoc.body.scrollLeft := 0 1038 | oDoc.body.createTextRange().execCommand("RemoveFormat") 1039 | ScrollPos[ThisMode,1] := oDoc.body.scrollLeft, ScrollPos[ThisMode,2] := oDoc.body.scrollTop 1040 | If ThisMode != Hotkey 1041 | HTML_%ThisMode% := oDoc.body.innerHTML 1042 | ThisMode := "Hotkey", Hotkey_Hook(!isPaused), TitleText := "AhkSpy - Button" TitleTextP2 1043 | oDoc.body.scrollLeft := ScrollPos[ThisMode,1], oDoc.body.scrollTop := ScrollPos[ThisMode,2] 1044 | ShowMarker ? (HideMarker(), HideAccMarker()) : 0 1045 | (HTML_Hotkey != "") ? Write_HotkeyHTML() : Write_Hotkey({Mods:"Waiting pushed buttons..."}) 1046 | SendMessage, 0xC, 0, &TitleText, , ahk_id %hGui% 1047 | GuiControl, TB: -0x0001, But3 1048 | WinActivate ahk_id %hGui% 1049 | GuiControl, 1:Focus, oDoc 1050 | IniWrite(ThisMode, "LastMode") 1051 | If isFindView 1052 | FindSearch(1) 1053 | Return 1054 | 1055 | Write_Hotkey(K) { 1056 | Static PrHK1, PrHK2, PrKeysComm, KeysComm, Name ; , PrKeys1, PrKeys2 1057 | 1058 | Mods := K.Mods, KeyName := K.Name 1059 | Prefix := K.Pref, Hotkey := K.HK 1060 | LRMods := K.LRMods, LRPref := TransformHTML(K.LRPref) 1061 | ThisKey := K.TK, VKCode := K.VK, SCCode := K.SC 1062 | 1063 | If (K.NFP && Mods KeyName != "") 1064 | NotPhysical := " " DP " Not a physical press " 1065 | 1066 | HK1 := K.IsCode ? Hotkey : ThisKey 1067 | HK2 := HK1 = PrHK1 ? PrHK2 : PrHK1, PrHK1 := HK1, PrHK2 := HK2 1068 | HKComm1 := " `; """ (StrLen(Name := GetKeyName(HK2)) = 1 ? Format("{:U}", Name) : Name) 1069 | HKComm2 := (StrLen(Name := GetKeyName(HK1)) = 1 ? Format("{:U}", Name) : Name) """" 1070 | 1071 | ; If ((Keys1 := Prefix Hotkey) != "" && Keys1 != PrKeys1) 1072 | ; Keys2 := PrKeys1, PrKeys1 := Keys1 1073 | ; , KeysComm := " `; """ PrKeysComm " >> " Mods KeyName """" 1074 | ; , PrKeysComm := Mods KeyName, PrKeys2 := Keys2 1075 | ; Else 1076 | ; Keys1 := PrKeys1, Keys2 := PrKeys2 1077 | 1078 | If K.IsCode 1079 | Comment := " `; """ KeyName """" 1080 | If (Hotkey != "") 1081 | FComment := " `; """ Mods KeyName """" 1082 | 1083 | If (LRMods != "") 1084 | { 1085 | LRMStr := "" LRMods KeyName "" 1086 | If (Hotkey != "") 1087 | LRPStr := " " DP " " LRPref Hotkey ":: `; """ LRMods KeyName """" 1088 | } 1089 | inp_hk := o_edithotkey.value, inp_kn := o_editkeyname.value 1090 | 1091 | If Prefix != 1092 | DUMods := (K.MLCtrl ? "{LCtrl Down}" : "") (K.MRCtrl ? "{RCtrl Down}" : "") 1093 | . (K.MLAlt ? "{LAlt Down}" : "") (K.MRAlt ? "{RAlt Down}" : "") 1094 | . (K.MLShift ? "{LShift Down}" : "") (K.MRShift ? "{RShift Down}" : "") 1095 | . (K.MLWin ? "{LWin Down}" : "") (K.MRWin ? "{RWin Down}" : "") . "{" Hotkey "}" 1096 | . (K.MLCtrl ? "{LCtrl Up}" : "") (K.MRCtrl ? "{RCtrl Up}" : "") 1097 | . (K.MLAlt ? "{LAlt Up}" : "") (K.MRAlt ? "{RAlt Up}" : "") 1098 | . (K.MLShift ? "{LShift Up}" : "") (K.MRShift ? "{RShift Up}" : "") 1099 | . (K.MLWin ? "{LWin Up}" : "") (K.MRWin ? "{RWin Up}" : "") 1100 | 1101 | SendHotkey := Hotkey = "" ? ThisKey : Hotkey 1102 | 1103 | ControlSend := DUMods = "" ? "{" SendHotkey "}" : DUMods 1104 | 1105 | If (DUMods != "") 1106 | LRSend := " " DP " " SendMode " " DUMods "" Comment "" 1107 | If SCCode != 1108 | ThisKeySC := " " DP " " VKCode " " DP " " SCCode " " 1109 | . DP " 0x" SubStr(VKCode, 3) " " DP " 0x" SubStr(SCCode, 3) "" 1110 | Else 1111 | ThisKeySC := " " DP " 0x" SubStr(VKCode, 3) "" 1112 | If WordWrap 1113 | Break := "word-wrap: break-word;" 1114 | 1115 | HTML_Hotkey = 1116 | ( Ltrim 1117 |
1118 | %D1% ( Pushed buttons ) %DB% %pause_button% %D2% 1119 | 1120 | %Mods%%KeyName%%NotPhysical% 1121 | 1122 | %LRMStr% 1123 | 1124 | %D1% ( Command syntax ) %DB%1145 | 1146 | 1158 | ) 1159 | ; %DB%%SendCode% code %DB%%SendModeStr% %D2% 1125 | 1126 | %Prefix%%Hotkey%::%FComment%%LRPStr% 1127 | 1128 | %SendMode% %Prefix%{%SendHotkey%}%Comment% %DP% ControlSend, ahk_parent, %ControlSend%, WinTitle%Comment% 1129 | 1130 | %Prefix%{%SendHotkey%}%Comment%%LRSend% 1131 | 1132 | GetKeyState("%SendHotkey%", "P")%Comment% %DP% KeyWait, %SendHotkey%, D T0.5%Comment% 1133 | 1134 | %HK2% & %HK1%::%HKComm1% & %HKComm2% %DP% %HK2%::%HK1%%HKComm1% >> %HKComm2% 1135 | 1136 | %D1% ( Key ) %DB%num scroll locale %D2% 1137 | 1138 | %ThisKey% %DP% %VKCode%%SCCode%%ThisKeySC% 1139 | 1140 | %D1% ( GetKeyNameOrCode ) %DB%paste %D2% 1141 | 1142 |› › › 1143 | 1144 | %D2%