MACSCRPT Archives

May 2009

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Kozmenko, Valeriy" <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Tue, 26 May 2009 19:16:08 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (1 lines)
I am using UI Browser on the regular basis since 2004, and I can assure that it is worth every penny of its cost.

I am curious if a new update or upgrade is coming. I am not sure if I have a feature request - the software is already perfect (from my stand point)

Valeriy Kozmenko, MD



----- Original Message -----

From: Macintosh Scripting Systems <[log in to unmask]>

To: [log in to unmask] <[log in to unmask]>

Sent: Tue May 26 16:45:15 2009

Subject: Re: Image Events click



On May 26, 2009, at 4:36 PM, Bill Steele wrote:



> For applications that don't enable UI events it is apparently  

> possible to get System Events to click a button by giving it the XY  

> coordinates.

>

> OK, coordinates from where?  The top corner of the app's window,   

> the position on the entire screen?

> In the former case, how do we find the exact position of, say, a  

> radio button other than looking at the app's source code?

>

> I've been poking around the web for sample System Events code and  

> all I've found so far are articles saying that you can do this or  

> that with System Events, isn't that handy?



It isn't quite clear what you're asking, but I'll try to help you out.



When you refer to applications that "don't enable UI events," do you  

mean applications that don't support AppleScript? If so, yes, you can  

use Apple's System Events application, which is built in to Mac OS X,  

to control user interface elements like buttons. This only works if  

you first turn on the "Enable access for assistive devices" setting in  

the Universal Access pane of System Preferences.



The technology for doing this is called "GUI Scripting," and it works  

by sending AppleScript commands to the System Events application. That  

application implements a bunch of AppleScript commands that know how  

to control the user interface elements in running processes. One of  

those commands is called 'click.' One of the parameters of the 'click'  

command is 'at.' According to the System Events application's  

AppleScript terminology dictionary, when you use the AppleScript GUI  

Scripting command 'click at', you should use "the { x, y } location at  

which to click, in global coordinates." This means you should use the  

screen coordinates, where the origin {0, 0} is at the bottom left  

corner of your main screen.



The only way to know where a button is located is to ask the  

application that owns the button where it is right now. Application  

windows can be moved around, and only the application knows where a  

button in one of its windows is currently located. You can find this  

out with GUI Scripting by asking the System Events application to tell  

you where the target application's window is currently located, and  

where in that window the button is located. Then you can convert that  

location to the global coordinates of the button and use the 'click  

at' command.



But it is much easier to just use GUI Scripting to tell the target  

application to 'click' the button. All that the 'click at' command  

does is to find the button that is located there, then send it the  

'click' command. You might as well short-circuit the process by  

telling System Events to tell the target application process to  

'click' the button.



If you don't already know anything about GUI Scripting, you didn't  

understand what I just wrote, so you have to do some studying. One way  

to start is to download the free 30-day trial version of my  

application "PreFab UI Browser." Its help files contain a lot of  

information about GUI Scripting, and it helps you compose AppleScript  

commands directed to the System Events application.



--



Bill Cheeseman - [log in to unmask]

Quechee Software, Quechee, Vermont, USA

www.quecheesoftware.com



PreFab Software - www.prefabsoftware.com


ATOM RSS1 RSS2