Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUI TextEdit



Philip Aker wrote on Sat, 2 Jun 2007 00:50:29 -0700:

>The problems I had with this script is that it seemed to run too fast  
>for TE to handle. So I had to pepper it with calls to 'delay'.

>on TESaveAs(theKind, theTitle)
>	tell application "TextEdit" to activate
>	tell application "System Events" to tell application process  
>"TextEdit" to tell window 1
>		keystroke "s" using {command down, shift down}
>		tell sheet 1
>			keystroke theTitle
>			delay 1
>			tell group 1 to tell pop up button 1
>				click
>				click menu item theKind of menu 1
>				delay 1
>			end tell
>			click button "Save"
>		end tell
>	end tell
>end TESaveAs
>
>TESaveAs("HTML", "Acme-Sales-2007-05")

When I'm obliged to use GUI Scripting, I try to tighten up any inserted
delays by using conditional repeats rather than "blind" delay amounts.
Also, if a field value can be 'set' rather than typed in (as it can be
here), that helps too.

  on TESaveAs(theKind, theTitle)
    tell application "TextEdit" to activate
    tell application "System Events" to tell application process
"TextEdit" to tell window 1
      keystroke "s" using {command down, shift down}
      repeat until (sheet 1 exists)
        delay 0.2
      end repeat
      tell sheet 1
        set value of text field 1 to (theTitle & ".rtf")
        tell group 1 to tell pop up button 1
          click
          repeat until (menu 1 exists)
            delay 0.2
          end repeat
          click menu item theKind of menu 1
          repeat while (menu 1 exists)
            delay 0.2
          end repeat
        end tell
        click button "Save"
      end tell
    end tell
  end TESaveAs
  
  TESaveAs("HTML", "Acme-Sales-2007-05")


NG

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

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.