Select part of window with UI scripting

Hi All,

I have a need to be able to set the focus of a window using UI scripting. The window is similar to iTunes in the fact that it has a list section at the left and then a main area to the right. I have scripting that brings the window to the front but if the window’s focus is not in the right section the script doesn’t work correctly. The app remembers where the last focus was for that window. Here is info for the left section of the window from UI Element Inspector

<AXApplication: “Capture One PRO”>
<AXWindow: “Captures”>



Attributes:
AXRole: “AXTable”
AXRoleDescription: “table”
AXHelp: “(null)”
AXFocused (W): “1”
AXParent: “”
AXChildren: “<array of size 9>”
AXWindow: “<AXWindow: “Captures”>”
AXTopLevelUIElement: “<AXWindow: “Captures”>”
AXPosition: “x=14 y=129”
AXSize: “w=236 h=765”
AXEnabled: “1”
AXRows: “<array of size 6>”
AXVisibleRows: “<array of size 6>”
AXSelectedRows (W): “<array of size 1>”
AXColumns: “<array of size 3>”
AXVisibleColumns: “<array of size 3>”
AXSelectedColumns: “<array of size 0>”
AXHeader: “(null)”

Actions:
AXShowMenu - show menu

The part of the window that I need to be sure is in focus has this info.

<AXApplication: “Capture One PRO”>
<AXWindow: “Captures”>

Attributes:
AXRole: “AXScrollArea”
AXRoleDescription: “scroll area”
AXHelp: “(null)”
AXFocused (W): “0”
AXParent: “”
AXChildren: “<array of size 0>”
AXWindow: “<AXWindow: “Captures”>”
AXTopLevelUIElement: “<AXWindow: “Captures”>”
AXPosition: “x=278 y=84”
AXSize: “w=1643 h=1064”
AXHorizontalScrollBar: “(null)”
AXVerticalScrollBar: “(null)”
AXContents: “<array of size 0>”

The main difference that I see is the AXRoleDescription which is “table” for the left area and “scroll area” for the section that I need to set the focus to.

Here is a snip of my script


--Bring app to front
tell application "System Events" to tell process "Capture One PRO" to set frontmost to true

(* I need to set the focus to the correct part of the window here *)

		--Switch to thumbnail view
		tell application "System Events" to tell process "Capture One PRO" to keystroke "2" using command down
		--Go to first image
		tell application "System Events" to tell process "Capture One PRO" to key code 115 using command down

How can I set the focus of the window to the “scroll area”?
Any thoughts?

Thanks,
Mark

Model: G5 2.0gHz DualCore Power PC
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

I don’t have your version, but did you try setting the ‘focused’ property of the ui element?

gl,

Hi Kel,

I’m unsure of the syntax to address a UI element in this manner. The only unique info I have of the window is

AXApplication: “Capture One PRO” – The application I’m calling
AXWindow: “Captures” – The name of the window
AXRole: “AXScrollArea” --The role of the UI element
and the AXFocused attribute which is “1” when the element is focused

I have scripting to bring the app to the front and open the correct window so I know that the window “Captures” of the application “Capture One Pro” is the frontmost but how can I set the focused property of the role “AXScrollArea” to “1”?

Here is the section I need to add to


tell application "Capture One PRO"
			activate
			open (sessionPath)
			-- the session we're working on
			set mySession to session jobName
			-- get the images to process
			set myImages to every image of capture favorite folder of mySession
			-- set process target
			set myTarget to process destination "Web Proof"
		end tell
-- Make sure app is in front
		tell application "System Events" to tell process "Capture One PRO" to set frontmost to true
		
		--Switch to thumbnail view
		tell application "System Events" to tell process "Capture One PRO" to keystroke "2" using command down
--Here is where I need to set the focus of the window that was opened in the line above
--Something like
tell application "System Events" to tell process "Capture One PRO" to set focused of window "Captures" of  AXRole "AXScrollArea" to "1"
end tell

That obviously doesn’t work. I’m new to UI scripting so I’m not sure how to call to the elements. I’ll do some more digging.

Thanks,
Mark

Usinga trial copy PreFab UI Browser, and looking at some example scripts, helped make more sense of it. I have found that the following works in case anyone else finds it useful.


activate application "Capture One PRO"
tell application "System Events"
	tell process "Capture One PRO"
		tell group 1 of window "Captures"
			set value of attribute "AXFocused" of scroll area 1 to true
		end tell
	end tell
end tell

Cheers,
Mark