• 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: How to find the menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to find the menu


  • Subject: Re: How to find the menu
  • From: "koenig.yvan" <email@hidden>
  • Date: Tue, 02 Aug 2011 12:09:11 +0200

I revised my switcher handlers for 10.7

The changes don't hurt on 'old' systems.

After switching to Rtf, it appears that a delay is required.
I'm wondering if it's related to the AutoSave feature.

--[SCRIPT]
--=====

on switch_to_text()
tell application "TextEdit"
activate
(*
need_Return = true if the doc is not empty
need_Return = false if the doc is empty *)
set need_Return to (count of characters of document 1) > 0
end tell
tell application "System Events" to tell process "TextEdit" to tell menu bar 1
tell menu bar item 5 to tell menu 1
set maybe to (enabled of last menu item is true)
if maybe then click menu item 4
end tell
(*
If the document is empty, switching from Rtf to Text will not display a dialog
so there is no need to issue a return. *)
if maybe and need_Return then keystroke return
end tell
end switch_to_text

--=====

on switch_to_rtf()
tell application "TextEdit" to activate
tell application "System Events" to tell process "TextEdit" to tell menu bar 1
tell menu bar item 5 to tell menu 1
set maybe to (enabled of last menu item is false)
if maybe then click menu item 4
end tell
end tell
end switch_to_rtf

--=====

my switch_to_rtf()
delay 1 -- REQUIRED under 10.7, maybe linked to AutoSave
my switch_to_text()

--[/SCRIPT]

You will see that the menu item are correctly identified.

Yvan KOENIG (VALLAURIS, France) mardi 2 août 2011 12:09:03


 _______________________________________________
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: 
 >How to find the menu (From: "Adolf.Peter" <email@hidden>)
 >Re: How to find the menu (From: KOENIG Yvan <email@hidden>)

  • Prev by Date: Re: Can't find the menu item of the context menu.
  • Next by Date: Very Old Books
  • Previous by thread: Re: How to find the menu
  • Next by thread: Can't find the menu item of the context menu.
  • Index(es):
    • Date
    • Thread