Trying to fill an "incrementor" (?) with a value

I am trying to create an AppleScript to automate a software called Eagle.

The idea is to open a file in Eagle and export it as a PNG file.

The script is more or less working.

At one point I invoke the export window…

https://i.imgur.com/hbMCM0y.png

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"

So, applescript is getting the correct control.

How in the hell do I set that with a value?

Thanks

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.

BRILLIANT GUYS!

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"


Working like silk.

Brilliant.

Thanks

What does the program Eagle do? I tried to find it on MacUpdate, but there are 3 programs named Eagle that do different things

I would like to download it and test…

I suspect it’s this software package:

https://www.autodesk.com/products/eagle/overview

But could be another one…

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. :confused: They are listed as commands when the dictionary’s viewed in Script Debugger.

That’s because “increment” is a cocoa action that incrementors can respond to ( ie. AXIncrement)
It is not a “System Events” command

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.