• 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: AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript


  • Subject: Re: AppleScript
  • From: Luther Fuller <email@hidden>
  • Date: Fri, 28 May 2010 13:01:36 -0500

On May 28, 2010, at 12:17 PM, Mark J. Reed wrote:

Regular scripting requires that the app be scriptable.  GUI scripting
doesn't - it fakes mouse clicks and keypresses so the app thinks a
human is driving it.

Something to keep in mind ... GUI scripts are fragile.

I'm currently using a script with just two lines of GUI code within a loop. Like this ...

repeat with msg in msgList
-- lots of script here
tell application "System Events"
tell process "Mail"
repeat
if exists window 1 then exit repeat
delay 1
end repeat
keystroke "p" using {command down}
delay 1
repeat
if exists sheet 1 of window 1 then exit repeat
delay 1
end repeat
click button "Print" of sheet 1 of window 1
delay 1
end tell
-- lots more script here
end repeat

If I forget that it's running and click the desktop at just the right moment, it hangs. Why? Because GUI commands aren't directed at a particular application (no 'tell application' with GUI), but to the screen. If Mail is not frontmost, the script waits for something that can't happen. I suppose I could fix this with a more complicated script, but is it worth it?

The real problem is that both the user and the script are trying operate the same computer at the same time. If two humans were trying to do this, there would be negotiations leading to one waiting until the other had finished.

A script needs to be able to take possession of an application or computer and lock-out other users (or scripts) until it is finished. Too bad this feature does not exist.

 _______________________________________________
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: 
 >AppleScript (From: Charlie Dickman <email@hidden>)
 >Re: AppleScript (From: Bruce Brown <email@hidden>)
 >Re: AppleScript (From: Charlie Dickman <email@hidden>)
 >Re: AppleScript (From: "Mark J. Reed" <email@hidden>)
 >Re: AppleScript (From: Charlie Dickman <email@hidden>)
 >Re: AppleScript (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: AppleScript
  • Next by Date: Re: AppleScript
  • Previous by thread: Re: AppleScript
  • Next by thread: Re: AppleScript
  • Index(es):
    • Date
    • Thread