Determining default button

Hello all, I need some help with applescript and I’m not finding much info through regular channels.

Basically I work for a company that develops software and we use applescript to automate a lot of our test cases. In this instance, when a specific dialog window is opened, I need to determine which button is the default button (ie. highlighted in blue). The window has an attribute called “AXDefaultButton” and I’ve accessed the properties like this:

get the properties of attribute "AXDefaultButton" of window "New Window"

Which returns the following values:

{settable:false, name:"AXDefaultButton", class:attribute}

I am confused since, even though there is no “value” property, UI Browser still shows me that the “value” of AXDefaultButton is ’ button “Continue” '. Any help would be greatly appreciated, thanks!

Try “text” or “title” of …

Hello

Using this script

property myApp : "TextEdit"

tell application myApp to activate
tell application "System Events" to tell application process myApp
	get properties of every button of UI element 4 of sheet 1 of window 1
end tell
end

I am able to get the properties of the buttons of the Print Dialog
[i]{position:{434, 332}, maximum value:missing value, name:missing value, size:{21, 18}, subrole:missing value, class:button, minimum value:missing value, enabled:true, selected:missing value, role:“AXButton”, help:missing value, title:missing value, value:missing value, entire contents:{}, description:“bouton”, focused:false, orientation:missing value},

{position:{898, 329}, maximum value:missing value, name:“Imprimer”, size:{79, 20}, subrole:missing value, class:button, minimum value:missing value, enabled:true, selected:missing value, role:“AXButton”, help:missing value, title:“Imprimer”, value:missing value, entire contents:{}, description:“bouton”, focused:false, orientation:missing value},

{position:{816, 329}, maximum value:missing value, name:“Annuler”, size:{71, 20}, subrole:missing value, class:button, minimum value:missing value, enabled:true, selected:missing value, role:“AXButton”, help:missing value, title:“Annuler”, value:missing value, entire contents:{}, description:“bouton”, focused:false, orientation:missing value},

{position:{547, 330}, maximum value:missing value, name:“Aperçu”, size:{76, 20}, subrole:missing value, class:button, minimum value:missing value, enabled:true, selected:missing value, role:“AXButton”, help:“Aide du bouton Aperçu”, title:“Aperçu”, value:missing value, entire contents:{}, description:“bouton”, focused:false, orientation:missing value}[/i]

but I can’t find any trace of an AXDefaultButton attribute.

Yvan KOENIG (from FRANCE mercredi 14 février 2007 16:46:56)

Yvan,

AXDefaultButton is an attribute of a window, not of a button

Exploring System Events with Script Debugger the value of AXDefaultButton is always displayed as empty,
so I assume you cannot work with it

Thanks StephanK

property myApp : "TextEdit"

tell application myApp to activate
tell application "System Events" to tell application process myApp
	get value of attribute "AXRoleDescription" of sheet 1 of window 1
	get value of attribute "AXChildren" of sheet 1 of window 1 (*
	{image 1 of sheet "Imprimer" of window "Sans titre" of application process "TextEdit", static text "Préréglages :" of sheet "Imprimer" of window "Sans titre" of application process "TextEdit", static text "Imprimante :" of sheet "Imprimer" of window "Sans titre" of application process "TextEdit", UI element 4 of sheet "Imprimer" of window "Sans titre" of application process "TextEdit", UI element 5 of sheet "Imprimer" of window "Sans titre" of application process "TextEdit", pop up button 1 of sheet "Imprimer" of window "Sans titre" of application process "TextEdit", pop up button 2 of sheet "Imprimer" of window "Sans titre" of application process "TextEdit", pop up button 3 of sheet "Imprimer" of window "Sans titre" of application process "TextEdit"} *)
	get value of attribute "AXParent" of sheet 1 of window 1 (* empty 
	but UI Element Inspector display  "<AXApplication: "TextEdit">" *)
	get value of attribute "AXMain" of sheet 1 of window 1 (* true *)
	get value of attribute "AXSize" of sheet 1 of window 1 (* {583, 284} *)
	get value of attribute "AXDefaultButton" of sheet 1 of window 1 (* empty 
	but UI Element Inspector display "<AXButton: "Imprimer">" *)
end tell

As UI Element Inspector is able to return the description of AXDefaultButton, I assumes that something is missing in the calling instruction (maybe something to ask for ?? ).

Yvan KOENIG (from FRANCE mercredi 14 février 2007 18:09:26)

I’ve been pulling my hair out over this for a day now so I think I’m going to move on and maybe the answer will come to me later in a vision. :wink:

Thanks for all your help, I appreciate it.