I need to fill the text field “resolution” with 2400 but Applescript call this a “incrementor”.
This is the list of all controls on that pane
group 1 of window "Export Image" of application process "eagle"
button "OK" of group 1 of window "Export Image" of application process "eagle"
button "Cancel" of group 1 of window "Export Image" of application process "eagle"
text field "File" of window "Export Image" of application process "eagle"
static text "File" of window "Export Image" of application process "eagle"
button "Browse..." of window "Export Image" of application process "eagle"
checkbox "Clipboard" of window "Export Image" of application process "eagle"
checkbox "Monochrome" of window "Export Image" of application process "eagle"
incrementor "Resolution" of window "Export Image" of application process "eagle"
static text "Resolution" of window "Export Image" of application process "eagle"
static text "dpi" of window "Export Image" of application process "eagle"
static text "Image Size" of window "Export Image" of application process "eagle"
text field 2 of window "Export Image" of application process "eagle"
static text "pixel" of window "Export Image" of application process "eagle"
pop up button "Full" of window "Export Image" of application process "eagle"
list 1 of pop up button "Full" of window "Export Image" of application process "eagle"
static text 1 of list 1 of pop up button "Full" of window "Export Image" of application process "eagle"
static text 2 of list 1 of pop up button "Full" of window "Export Image" of application process "eagle"
static text "Area" of window "Export Image" of application process "eagle"
button 2 of window "Export Image" of application process "eagle"
button 3 of window "Export Image" of application process "eagle"
button 4 of window "Export Image" of application process "eagle"
image "Export Image" of window "Export Image" of application process "eagle"
static text "Export Image" of window "Export Image" of application process "eagle"
The problem is that there is no text field called “Resolution”. There is an “incrementor” called “Resolution”.
How do I set this “incrementor” to be 2400?
I have tried
tell process "eagle"
set value of incrementor "Resolution" of window "Export Image" to 2400
end tell
and also the same line with 2400 between quotes but there is no error and the field does not change.
I have squeezed google and nothing.
I can get the value on the incrementor by doing
set x to value of incrementor "Resolution" of window "Export Image"
I’ve never seen an “incrementor” in UI scripting, so I don’t have a direct answer. And I don’t have Eagle, so I can’t play around with it. But I’m guessing nobody else here has that software either…
Here are some things I’d take a look at:
set theProps to the properties of incrementor "Resolution" of window "Export Image" of application process "eagle"
return theProps
Just in case there’s anything useful in there…
Also, possible an “incriminator” has sub-UI elements? If you can retrieve the value you filled in via “value of incrementor,” probably not, but you might try:
set subElements to every UI element of incrementor "Resolution" of window "Export Image" of application process "eagle"
return subElements
If nothing else can be found to allow you access to set that value, you can probably locate the location of the text field on screen by getting the element’s properties by UI scripting, then simulate a mouseclick within the text field to activate it, and then either simulate the keystrokes you need, or set the clipboard to the value you need and paste.
Is the process called “eagle” or “Eagle”? Process names are case-sensitive.
Otherwise, I see from System Events’s dictionary that besides a value, incrementors have maximum value and minimum value properties which can’t be changed. Is 2400 within the range allowed by yours?
Nigel - That’s great to know the the System Events dictionary lists all the properties of the UI elements, I didn’t know that.
According to the dictionary, the access to incrementor’s “value” property is “get/set,” so I’d think it should be working.
In my experience with UI scripting, with some programs it just doesn’t work and I can’t find any explanation. In those cases, I resort to the clunkier method of getting the UI element’s position on screen and simulating the mouse click.
The idea of putting the control in focus gave me the idea of sending keystrokes to it.
So I have solved the problem by doing this:
-- focus the incrementor
set the value of attribute "AXFocused" of incrementor "Resolution" to true
-- send 4 backspaces to clean the field
key code 51 using {command down}
key code 51 using {command down}
key code 51 using {command down}
key code 51 using {command down}
-- type 2400
keystroke "2400"
I noticed that the resolution 2400 is the max value the incrementor will allow.
So here is a small script to set the incrementor to the max…
tell application "System Events"
set myInc to incrementor "Resolution" of window "Export Image" of application process "EAGLE"
set maxVal to maximum value of myInc
repeat while (value of myInc as number) < maxVal
increment myInc
end repeat
end tell
This will loop using the increment action until the value is at the max.
Interesting! There’s no ‘increment’ command listed in System Events’s dictionary when you look at it in Script Editor, but both ‘increment’ and ‘decrement’ compile as System Events terms and are listed as things to which UI elements respond. They are listed as commands when the dictionary’s viewed in Script Debugger.
Well. It’s a System Events command in that it’s a term which compiles only in System Events and which looks and behaves like a command. But no doubt it sends the appropriate Cocoa signal to target objects.