I apologize but “It’s not working” give no useful information.
Which behavior are you getting ?
Here, when I clicked on “Open this script in your editor” I got extraneous characters at the beginning or/and at the end of several lines. When it refused to compile, the editor was polite enough to show the offending extraneous characters.
It was easy to remove them and get a compiled script.
I made tests with TextWrangler.
tell application "TextWrangler" to activate -- with a Word document already open¨
tell application "System Events"
get name of every application process
log result
(*loginwindow, Script Editor, Numbers, Pages, Activity Monitor, Wacom Desktop Center, Dock, SystemUIServer, universalaccessd, AirPlayUIAgent, Finder, com.apple.internetaccounts, sharingd, com.apple.dock.extra, CoreServicesUIAgent, Spotlight, iTunesHelper, ASObjC Runner, FastScripts, TISwitcher, Keychain Circle Notification, Folder Actions Dispatcher, Shady, NotificationCenter, SMARTReporter, WacomTabletDriver, WacomTouchDriver, WiFiAgent, System Events, TabletDriver, storeuid, Safari, com.apple.WebKit.Networking, Mail, AppleSpell, com.apple.WebKit.WebContent, com.apple.MailServiceAgent, com.apple.WebKit.WebContent, com.apple.WebKit.WebContent, Preview, Image Capture Extension, TextWrangler*)
tell process "TextWrangler"
keystroke "f" using {command down}
delay 1
set windowName to "Find" # "Find/Change" for Quark Xpress
class of UI elements of window windowName
log result
--> {static text, grow area, button, button, button, UI element}
class of UI elements of UI element -1 of window windowName
log result
--> {checkbox, checkbox, checkbox, checkbox, checkbox, UI element, UI element, button, button, button, button, button, button, scroll bar, scroll bar}
name of UI elements of UI element -1 of window windowName
-->{"Entire word", "Case sensitive", "Grep", "Wrap around", "Selected text only", missing value, missing value, "Replace & Find", "Replace All", "Replace", "Find All", "Previous", "Next", missing value, missing value}
end tell
end tell
In this application, as I assumed in my late message, the text boxes are not at the root of the UI arborescence.
Worse, TextWrangler doesn’t put them in a group but in a “unknown structure”.
Happily, as you may see, triggering this structure as “UI element -1” gave access to the checkboxes.
As you may see, I added an instruction listing the available processes.
I did that so that you may check if the QuarkXpress process is really named “QuarkXpress”.
Some applications add some complementary infos at the end of their process’s name.
I also inserted an instruction opening the Find dialog to be sure that it will be available when the script will try to trigger it.
At last, I defined the window name in a variable so that a single change would be sufficient when switching from TextWrangled whose dialog is named “Find” to QuarkXpress which, according to what you wrote, name its dialog “Find/Replace”
So, to test under QuarkXpress, you may use :
tell application "QuarkXpress" to activate -- with a Word document already open¨
tell application "System Events"
get name of every application process
log result
tell process "QuarkXpress"
keystroke "f" using {command down}
delay 1
set windowName to "Find/Change"
class of UI elements of window windowName
log result
class of UI elements of UI element -1 of window windowName
log result
name of UI elements of UI element -1 of window windowName
end tell
end tell
Of course, if this time there are again extraneous characters when you click “Open this script in your editor”.
Be patient and remove them carefully.
If it fails, check in the list of processes names that the correct one is really “QuarkXpress”. If it’s not, edit the script accordingly.
Of course, with QuarkXpress, if there is one, the structure hosting the check boxes may be at a different location in the list of first level UI elements.
Edit the instruction triggering it accordingly. Maybe QuarkXpress is fair enough to use an official group structure.
If at the very last it continue to fail, post the exact error message, not a useless “it’s not working”.
Yvan KOENIG (VALLAURIS, France) lundi 17 novembre 2014 10:30:27