-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_elements.applescript
More file actions
43 lines (35 loc) · 1.37 KB
/
print_elements.applescript
File metadata and controls
43 lines (35 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
tell application "System Events"
-- Get frontmost application process
set frontApp to first application process whose frontmost is true
log "{"
log " \"application\": \"" & name of frontApp & "\","
tell frontApp
-- Get the frontmost window
set frontWindow to window 1
log " \"window\": {"
log " \"title\": \"" & name of frontWindow & "\","
log " \"position\": " & (position of frontWindow) & ","
log " \"size\": " & (size of frontWindow) & ","
-- Get all accessible elements
log " \"elements\": ["
set allElements to every UI element of frontWindow
repeat with i from 1 to count of allElements
set currentElement to item i of allElements
try
log " {"
log " \"role\": \"" & role of currentElement & "\","
log " \"description\": \"" & description of currentElement & "\","
log " \"position\": " & (position of currentElement) & ","
log " \"size\": " & (size of currentElement)
if i < count of allElements then
log " },"
else
log " }"
end if
end try
end repeat
log " ]"
log " }"
end tell
log "}"
end tell