Friday, November 16, 2018

#1 2018-10-29 03:41:16 pm

macos_boy
Member
Registered: 2005-07-26
Posts: 62

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

Applescript:



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

Applescript:


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

Applescript:


           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

Last edited by macos_boy (2018-10-29 05:23:45 pm)

Offline

 

#2 2018-10-29 09:50:01 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 358

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

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:

Applescript:


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:

Applescript:


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.

Last edited by t.spoon (2018-10-30 07:27:45 am)


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#3 2018-10-30 02:19:14 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4720

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

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?


NG

Offline

 

#4 2018-10-30 07:53:16 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 358

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

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.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#5 2018-10-30 08:57:34 am

macos_boy
Member
Registered: 2005-07-26
Posts: 62

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

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:

Applescript:


-- 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

Offline

 

#6 2018-10-30 12:37:53 pm

robertfern
Member
Registered: 2011-11-29
Posts: 31

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

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...

Offline

 

#7 2018-10-30 02:16:43 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 358

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

I suspect it's this software package:

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

But could be another one...


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#8 2018-11-07 12:32:32 pm

robertfern
Member
Registered: 2011-11-29
Posts: 31

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

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...

Applescript:


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.

Last edited by robertfern (2018-11-07 02:05:32 pm)

Offline

 

#9 2018-11-07 03:24:26 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4720

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

robertfern wrote:

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


NG

Offline

 

#10 2018-11-08 10:40:34 am

robertfern
Member
Registered: 2011-11-29
Posts: 31

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

Nigel Garvey wrote:

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.  hmm  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

Last edited by robertfern (2018-11-08 10:41:31 am)

Offline

 

#11 2018-11-08 02:43:11 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4720

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

robertfern wrote:

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.


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)