I'm posting here my version of a script that toggles between Flex Search and Exact Search in the Preferences. It is scripting the user interface of the Preferences pane in Accordance 10, so you can actually see the script doing it's work. As much as anything, this script may give some of you some help getting started at scripting the preferences yourself:
-- This script will toggle Flex/Exact search in Accordance preferences
tell application "Accordance" to activate
tell application "System Events"
tell process "acord"
click menu item "Preferences…" of menu 1 of menu bar item "Accordance" of menu bar 1
delay 0.2
-- select "Search Tabs" panel
set selected of row 12 of outline 1 of scroll area 1 of window "Preferences" to true
delay 0.2
-- toggle a checkbox to enable the "OK" button
-- necessary because clicking radio button does not enable "OK" button
click checkbox 1 of window "Preferences"
click checkbox 1 of window "Preferences"
set v to value of radio button "Flex Search" of radio group 1 of window "Preferences"
if v = 0 then
-- click to appropriate radio button
click radio button "Flex Search" of radio group 1 of window "Preferences"
else
click radio button "Exact Search" of radio group 1 of window "Preferences"
end if
delay 0.2 -- make this delay 1 or 2 seconds if you want longer to see what was switched.
-- dismiss Preferences
click button "OK" of window "Preferences"
end tell
end tell
Thanks a lot, Joe!
ReplyDeleteJoe,
ReplyDeleteOne thing I find so cumbersome is having to switch on and off unicode copying from the preferences (unicode for Greek, but legacy fonts for Hebrew copy and paste). Could this script be modified to toggle that?
Danny,
ReplyDeleteOf course you can. The script is enough code to figure it out. Just change the selected row from 12 to 5 and then you only need one click on checkbox 3, as it turns out, or you can refer to it by name. Then click the OK button. So, the whole meat of the script inside the tell blocks would be:
click menu item "Preferences…" of menu 1 of menu bar item "Accordance" of menu bar 1
delay 0.2
-- select "Search Tabs" panel
set selected of row 5 of outline 1 of scroll area 1 of window "Preferences" to true
delay 0.2
-- toggle a checkbox
click checkbox "Export all characters with Unicode format" of window "Preferences"
-- dismiss Preferences
click button "OK" of window "Preferences"
Thanks Joe, I did it ! (Well you did it, I followed directions!)
ReplyDeleteLast question - do you know of a way to make a shortcut for a script?
Google is your friend. Lots of ways to make an Applescript readily available at the touch of a keyboard combo or menu selection. Just search to find them.
ReplyDeleteAlso, http://www.macosxautomation.com is your friend.
Options include:
1. If you use Quicksilver or another launcher, that's a cinch.
2. You can wrap it in an OSX Service.
3. You can enable the OSX Script menu from the Applescript Editor.
4. You can use a third party utility like Fast scripts, where the first 10 keyboard shortcuts are free.