Do you really need the window ID.
I tried on non-scriptable app. But you canât get the âidâ
Thereâs many other properties you can access, including all the sub-elements.
This script shows how you can get the first window and access itâs properties:
use AppleScript version "2.5" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
--use scripting additions
property windowInfo : missing value
set windowInfo to my getWindowDebugInfoForProcessName:"Notes"
on getWindowDebugInfoForProcessName:aProcessName
tell application "System Events"
tell application process aProcessName
set aProceessProperties to its properties
log {"aProceessProperties is:", aProceessProperties}
set aWindow to its first window
log {"aWindow is:", aWindow}
set aWindowName to (name of aWindow)
log {"aWindowName is:", aWindowName}
set aWindowProperties to (properties of aWindow)
log {"aWindowProperties is:", aWindowProperties}
set aWindowAttributes to (attributes of aWindow)
log {"aWindowAttributes is:", aWindowAttributes}
set aWindowIdentifier to (value of attribute "AXIdentifier" of aWindow)
log {"aWindowIdentifier is:", aWindowIdentifier}
--set aWindowID to (id of aWindow)
--log {"aWindowID is:", aWindowID}
end tell
end tell
return {aProceessProperties, aWindowProperties, aWindowAttributes}
end getWindowDebugInfoForProcessName:
And the results:
{
{
*class* :*application process* ,
has scripting terminology:***true***,
bundle identifier:"com.apple.Notes",
*file*:*alias* "Kaptin:Applications:Notes.app:",
creator type:"????",
subrole:*missing value* ,
entire contents:{},
selected:*missing value* ,
*application file*:*alias* "Kaptin:Applications:Notes.app:",
orientation:*missing value* ,
role:"AXApplication",
accepts high level events:***true***,
file type:"APPL",
value:*missing value* ,
position:*missing value* ,
id:**167977** ,
displayed name:"Notes",
name:"Notes",
background only:***false***,
frontmost:***false***,
size:*missing value* ,
visible:***true***,
Classic:***false***,
role description:"application",
maximum value:*missing value*,
architecture:"x86_64",
partition space used:**0**,
short name:"Notes",
focused:*missing value* ,
minimum value:*missing value*,
help:*missing value* ,
title:"Notes",
accepts remote events:***false***,
total partition size:**0**,
description:"application",
accessibility description:*missing value*,
enabled:*missing value* ,
unix id:**579**
},
{
*class* :*window* ,
minimum value:*missing value*,
orientation:*missing value* ,
position:{
**22**,
**22**
},
accessibility description:*missing value*,
role description:"standard window",
focused:***false***,
title:"Notes",
size:{
**1188**,
**778**
},
help:*missing value* ,
entire contents:{},
enabled:*missing value* ,
maximum value:*missing value*,
role:"AXWindow",
value:*missing value* ,
subrole:"AXStandardWindow",
selected:*missing value* ,
name:"Notes",
description:"standard window"
},
{
*attribute* "AXFocused" of *window* "Notes" of *application process* "Notes",
*attribute* "AXFullScreen" of *window* "Notes" of *application process* "Notes",
*attribute* "AXTitle" of *window* "Notes" of *application process* "Notes",
*attribute* "AXChildrenInNavigationOrder" of *window* "Notes" of *application process* "Notes",
*attribute* "AXPosition" of *window* "Notes" of *application process* "Notes",
*attribute* "AXGrowArea" of *window* "Notes" of *application process* "Notes",
*attribute* "AXMinimizeButton" of *window* "Notes" of *application process* "Notes",
*attribute* "AXDocument" of *window* "Notes" of *application process* "Notes",
*attribute* "AXSections" of *window* "Notes" of *application process* "Notes",
*attribute* "AXCloseButton" of *window* "Notes" of *application process* "Notes",
*attribute* "AXMain" of *window* "Notes" of *application process* "Notes",
*attribute* "AXFullScreenButton" of *window* "Notes" of *application process* "Notes",
*attribute* "AXProxy" of *window* "Notes" of *application process* "Notes",
*attribute* "AXDefaultButton" of *window* "Notes" of *application process* "Notes",
*attribute* "AXMinimized" of *window* "Notes" of *application process* "Notes",
*attribute* "AXChildren" of *window* "Notes" of *application process* "Notes",
*attribute* "AXRole" of *window* "Notes" of *application process* "Notes",
*attribute* "AXParent" of *window* "Notes" of *application process* "Notes",
*attribute* "AXTitleUIElement" of *window* "Notes" of *application process* "Notes",
*attribute* "AXCancelButton" of *window* "Notes" of *application process* "Notes",
*attribute* "AXModal" of *window* "Notes" of *application process* "Notes",
*attribute* "AXSubrole" of *window* "Notes" of *application process* "Notes",
*attribute* "AXZoomButton" of *window* "Notes" of *application process* "Notes",
*attribute* "AXRoleDescription" of *window* "Notes" of *application process* "Notes",
*attribute* "AXSize" of *window* "Notes" of *application process* "Notes",
*attribute* "AXToolbarButton" of *window* "Notes" of *application process* "Notes",
*attribute* "AXFrame" of *window* "Notes" of *application process* "Notes",
*attribute* "AXIdentifier" of *window* "Notes" of *application process* "Notes"
}
}