@@ -9,51 +9,59 @@ ListLines Off
9
9
#include ..\
10
10
#include Main.ahk
11
11
12
- ; std := ImportTypeLib("C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\StdOle2.Tlb")
13
- ; picDisp := ComObjCreate("StdPicture")
12
+ try {
13
+ ; std := ImportTypeLib("C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\StdOle2.Tlb")
14
+ ; picDisp := ComObjCreate("StdPicture")
14
15
15
- ; MsgBox % "Return value: " ITL_FormatError(std.StdFunctions.SavePicture("Ptr", ComObjUnwrap(picDisp), "Str", A_Desktop "\test.jpg", "Int")) " - " ErrorLevel " - " A_LastError
16
+ ; MsgBox % "Return value: " ITL_FormatError(std.StdFunctions.SavePicture("Ptr", ComObjUnwrap(picDisp), "Str", A_Desktop "\test.jpg", "Int")) " - " ErrorLevel " - " A_LastError
16
17
17
- UIAutomation := ImportTypeLib(A_WinDir " \System32\UIAutomationCore.dll" )
18
+ UIAutomation := ImportTypeLib(A_WinDir " \System32\UIAutomationCore.dll" )
18
19
19
- myArray := UIAutomation.tagRECT[3 ]
20
+ myArray := UIAutomation.tagRECT[3 ]
20
21
21
- struct := myArray[0 ]
22
- struct.left := 16
22
+ struct := myArray[0 ]
23
+ struct.left := 16
23
24
24
- rect := struct.Clone ()
25
- rect.bottom := 42
26
- struct.top := 9
25
+ rect := struct.Clone ()
26
+ rect.bottom := 42
27
+ struct.top := 9
27
28
28
- list := " TreeScope:`n"
29
- for field, value in UIAutomation.TreeScope
30
- list .= " `tTreeScope." field " = " value " `n"
31
- list .= " `nOrientationType:`n"
32
- for field, value in UIAutomation.OrientationType
33
- list .= " `tOrientationType." field " = " value " `n"
34
- list .= " `nstruct (tagRECT):`n"
35
- for field, value in struct
36
- list .= " `tstruct." field " = " value " `n"
37
- list .= " `nrect (tagRECT):`n"
38
- for field, value in rect
39
- list .= " `trect." field " = " value " `n"
40
- MsgBox % " Enumeration and structure fields:`n`n" list
29
+ list := " TreeScope:`n"
30
+ for field, value in UIAutomation.TreeScope
31
+ list .= " `tTreeScope." field " = " value " `n"
32
+ list .= " `nOrientationType:`n"
33
+ for field, value in UIAutomation.OrientationType
34
+ list .= " `tOrientationType." field " = " value " `n"
35
+ list .= " `nstruct (tagRECT):`n"
36
+ for field, value in struct
37
+ list .= " `tstruct." field " = " value " `n"
38
+ list .= " `nrect (tagRECT):`n"
39
+ for field, value in rect
40
+ list .= " `trect." field " = " value " `n"
41
+ MsgBox % " Enumeration and structure fields:`n`n" list
41
42
42
- automation := new UIAutomation.IUIAutomation(new UIAutomation.CUIAutomation())
43
+ automation := new UIAutomation.IUIAutomation(new UIAutomation.CUIAutomation())
43
44
44
- desktop := new UIAutomation.IUIAutomationElement(automation.GetRootElement())
45
+ desktop := new UIAutomation.IUIAutomationElement(automation.GetRootElement())
46
+ MsgBox % " The desktop:`n`n" GetElementInfo(desktop) " `n`nClick [OK] and wait 3 seconds."
45
47
46
- MsgBox % " The desktop:`n`n " GetElementInfo(desktop) " `n`nClick [OK] and wait 3 seconds. "
48
+ sleep 3000
47
49
48
- sleep 3000
50
+ MouseGetPos ,,,hwin
49
51
50
- MouseGetPos ,,,hwin
52
+ request := new UIAutomation.IUIAutomationCacheRequest(automation.CreateCacheRequest())
53
+ request.TreeScope := UIAutomation.TreeScope.Element| UIAutomation.TreeScope.Children
51
54
52
- request := new UIAutomation.IUIAutomationCacheRequest (automation.CreateCacheRequest( ))
53
- request.TreeScope := UIAutomation.TreeScope.Element | UIAutomation.TreeScope.Children
55
+ elem := new UIAutomation.IUIAutomationElement (automation.ElementFromHandleBuildCache( ComObjParameter ( 0x4000 , hwin), request ))
56
+ MsgBox % " The window under the mouse:`n`n " GetElementInfo(elem)
54
57
55
- elem := new UIAutomation.IUIAutomationElement(automation.ElementFromHandleBuildCache(ComObjParameter (0x4000 , hwin), request))
56
- MsgBox % " The window under the mouse:`n`n" GetElementInfo(elem)
58
+ pt := new UIAutomation.tagPOINT(), pt.x := 400 , pt.y := 400
59
+ elem2 := automation.ElementFromPoint(pt)
60
+ MsgBox % " The element at 400,400:`n`n" GetElementInfo(elem2)
61
+
62
+ } catch ex {
63
+ MsgBox 4112 , Exception! , % " An exception occured`n`tin "" " ex.What " "" `n`tin file "" " ex.File " "" `n`tat line " ex.Line " !`n`nMessage: " ex.Message " `n`nDetails: " ex.Extra
64
+ }
57
65
58
66
GetElementInfo(elem)
59
67
{
0 commit comments