• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: checking GUI action status
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking GUI action status


  • Subject: Re: checking GUI action status
  • From: Bill Cheeseman <email@hidden>
  • Date: Thu, 8 Jul 2010 15:30:40 -0400


On Jul 7, 2010, at 11:21 AM, Jim Brandt wrote:

My question is:
is there a way to perform an action in System Events (in this case, the click UI element) and test to see if the action happens sucessfully?

As far as I know, the only straightforward way to test it is to see whether it works. That usually involves discovering that some step further along in the script generates an unexpected result. So, examine the Web site to determine what change (if any) takes place when you click that UI element manually, then see whether you can add some statements to your script that test whether the change occurred.

GUI Scripting is based on Apple's accessibility API, which does generate a variety of errors in appropriate circumstances. I don't recall ever seeing an 'on error' statement triggered by an accessibility error in the GUI Scripting context, but it might happen if any of the accessibility errors do get passed on to the AppleScript 'on error' handler in a GUI Scripting script. Enclose the offending statement in a 'try'/'on error' block and see what happens.

Another possibility is to change the offending line so that it performs an "AXPress" action, instead of using the 'click' command. Theoretically, they should be the same, but in the past it has sometimes made a difference to perform an "AXPress" action.

As a last resort, it is sometimes useful to see whether a keyboard shortcut can be used to accomplish the same thing as a click. If so, then you can send a GUI Scripting 'keystroke' or 'keycode' command to Safari.

A longshot possibility is to see whether Safari posts an accessibility notification when you click that UI element. You can learn whether it does this by using UI Browser's Notifications Drawer to register for an appropriate notification, then monitor UI Browser's Notification Log window while you perform the action manually in Safari. This is a longshot, because it isn't clear to me which accessibility notification you would want to register for. But you might be able to hit on some appropriate notification by looking at the changes that occur in the Safari interface when you click the target UI element. If UI Browser does confirm that a notification is issued as a result of clicking that UI element, you might be able to watch for that notification in a companion script. GUI Scripting doesn't have this capability, but my UI Actions product does (or rather, it will once again when I release the next version in a couple of weeks). Watch this Web site for news about UI Actions: <http://pfiddlesoft.com/uiactions/>.

A couple of comments:

1. You should upgrade to the current version of Ui Browser, version 2.1.0. It's at a new URL now: <http://pfiddlesoft.com/uibrowser/>.

2. At one point in your script, you use the GUI Scripting 'click at' command. You should be aware that, under the hood, GUI Scripting simply translates the specified location into a standard UI element reference and then clicks that UI element. It might be more reliable or at least a shade faster if you rewrote that line to click the UI element itself using the simple form of the 'click' command.

--

Bill Cheeseman - email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >checking GUI action status (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: text to aiff audio script step
  • Next by Date: Re: checking GUI action status
  • Previous by thread: checking GUI action status
  • Next by thread: Re: checking GUI action status
  • Index(es):
    • Date
    • Thread