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:
Bill Steele <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 27 May 2009 09:56:36 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (74 lines)
>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?
>

The few examples of System Events scripting I have found wrap the 
commands in "if UI events enabled."  From this I infer that some 
applications don't. In those that do I gather I can use

click radio button "Yes" of (bladiblah)

But otherwise I have to click on {x,y]

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

Knew all that. My question was, How to find X and Y.

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

And the syntax for asking that question would be? Can't find anything 
in the System Events dictionary that looks like it.

>
>--
>
>Bill Cheeseman - [log in to unmask]
>Quechee Software, Quechee, Vermont, USA
>www.quecheesoftware.com
>
>PreFab Software - http://www.prefabsoftware.com


-- 

Bill Steele
[log in to unmask]

ATOM RSS1 RSS2