<MBPC2D running OS X 10.6.8 and BBEdit 9.6.3 (2890)>
The issue of running scripts from the BBEdit script menu has reared up
again and any advice would be greatly appreciated! Appended below is
the script that I am using to toggle the line indentation; it runs
fine from iKey and the AS Editor, but not from the BBEdit scripts menu
(where I would prefer it to be) unless I halt it after the shell
script calls.
(But first, please allow me to offer thanks to both Gribnif and to
Steve for the replies! The plist was the first place I checked, but I
didn’t know that switching apps would update it. It does! Thank you!)
Blessings and thanks again to all!!
Richard Fairbanks
########
-- The data changed is on line 325 of /Users/<me>/Library/Preferences/
com.barebones.bbedit.plist
tell application "BBEdit"
-- activate -- for testing purposes from the AS Editor
open the preferences window
end tell
-- get the coordinates of the Preferences window
tell application "System Events" to tell process "BBEdit" to set {x,
y} to (item 1 of (the position of window "BBEdit Preferences" as
list)) & (item 2 of (the position of window "BBEdit Preferences" as
list))
-- the script will not run any of the following "do shell script"
calls if the subsequent "return" is commented out. The AS calls will
still run.
-- cliclick is available at: http://www.bluem.net/en/mac/cliclick/ and
is great!
do shell script "/usr/local/bin/cliclick -r " & (x + 46) & " " & (y +
118) -- this selects the "Editing: General" pane
set z to (do shell script "defaults read com.barebones.bbedit
Editor:SoftWrapIndentMode")
if z is "SWIo" then
say "Flush left"
do shell script "/usr/local/bin/cliclick -r " & (x + 473) & " " & (y
+ 363) -- this clicks the "Reverse" button
else if z is "SWIh" then
say "Reverse"
do shell script "/usr/local/bin/cliclick -r " & (x + 236) & " " & (y
+ 363) -- this clicks the "Flush left" button
else if z is "SWIf" then
say "First line"
do shell script "/usr/local/bin/cliclick -r " & (x + 473) & " " & (y
+ 363) -- this clicks the "Reverse" button
else
say "we have an error!"
do shell script "/usr/local/bin/cliclick -r " & (x + 473) & " " & (y
+ 363) -- this clicks the "Reverse" button
end if
-- return -- when called from the BBEdit Scripts menu, the script
fails unless this return is enabled, but of course none of the
following lines run; if called from iKey or the AS Editor, the script
runs fine
-- BBEdit will display the above changes immediately, but the plist
only updates after another app becomes frontmost
tell application "System Events" to activate -- even switching to
background apps updates the plist!
tell application "BBEdit" to activate
tell application "BBEdit" to close the preferences window
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>