Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.7: Finding Control and Menu Items for use in AppleScript User Interface Scripting' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Finding Control and Menu Items for use in AppleScript User Interface Scripting
Authored by: scottbayes on Dec 12, '11 11:58:25AM
Munging the output: To clean up the text of the output, you can use TextWrangler (or other free text processors, probably including TextEdit).

In TextWrangler, select the Find... menu item under the Search menu, and enter , in the Find: field and \n in the Replace: field. Make sure Grep is checked.

Hit the Next button to highlight the first ",", then Replace & Find. You'll see the first item split off making it easy(er) to read. Once you're happy the replacements are working as expected hit Replace All to get the rest.

This is not perfect: in Safari, for example, the History menu may contribute huge numbers of elements, some of which may contain "," internally, messing this up, but for most uses it works pretty well. You also may need to remove some "{" and "}" characters, etc.

I opened the resulting file in Numbers, making it easy to insert a descriptive column if I wish.

NB: MUNG is a "recursive" acronym. It stands for Mung Until No Good. It sometimes confuses civilians and Muggles.

[ Reply to This | # ]

Re: 10.7: Finding Control and Menu Items for use in AppleScript User Interface Scripting
Authored by: Uncle Asad on Dec 12, '11 02:08:58PM
In TextWrangler, select the Find... menu item under the Search menu, and enter , in the Find: field and \n in the Replace: field. Make sure Grep is checked.

Hit the Next button to highlight the first ",", then Replace & Find. You'll see the first item split off making it easy(er) to read. Once you're happy the replacements are working as expected hit Replace All to get the rest.

This is not perfect: in Safari, for example, the History menu may contribute huge numbers of elements, some of which may contain "," internally, messing this up, but for most uses it works pretty well.

Since all the items seem to end with 'of application "System Events", ', you can use something like '"System Events", ' as your find term and '"System Events"\n' as your replace term and avoid the "commas-in-item-titles" problem.

[ Reply to This | # ]