Why using Keyboard Maestro if you do it all in AppleScript? :)
It's very easy to do in "pure KM":
- If condition met execute action
all of the following are true
the front window
title is
"Scratchpad"
execute the following actions:
- type the cmd-w keystroke
- use variable "FrontApp"
to set the front application by name
otherwise execute the following actions
- set variable "FrontApp"
to %CurrentApplication%
- activate BBEdit.app
- pause until condition met
all of the following are true
a menu
with this name
Show Scratchpad
is enabled
- select a menu item
in BBEdit.app
Menu title "Window"
Menu item "Show Scratchpad"
Assign it a hot key and you're done.
All the best,
Philippe
On 29 août 2011, at 07:19, Christopher Stone wrote:
> On Aug 28, 2011, at 18:33, Christopher Stone wrote:
>> I'm sort of ticked with the irregularities, so I'll probably rewrite the
>> script tomorrow.
>
> ______________________________________________________________________
>
> Hey Gary,
>
> Okay. This script bypasses all but BBEdit and Keyboard Maestro. It runs a
> trifle faster if you run it as a compiled script rather than as text.
>
> --
> Best Regards,
> Chris
>
> -----------------------------------------------------------------------------
> ## OPEN BBEDIT SCRATCHPAD ##
> -----------------------------------------------------------------------------
> on openScratchpad()
> tell application "BBEdit"
> open scratchpad window
> activate
> set index of window "Scratchpad" to 1 # Workaround for hidden apps issue.
> end tell
> end openScratchpad
> -----------------------------------------------------------------------------
> ## RESTORE NAMED APPLICATION ##
> -----------------------------------------------------------------------------
> on kmRestoreApp()
> tell application "Keyboard Maestro Engine"
> do script "<dict>
> <key>Action</key>
> <string>SetApplicationByNameMatches</string>
> <key>IsActive</key>
> <true/>
> <key>IsDisclosed</key>
> <true/>
> <key>MacroActionType</key>
> <string>UseVariable</string>
> <key>Variable</key>
> <string>restoreAppKM</string>
> </dict>"
> set value of variable "restoreAppKM" to "FALSE"
> end tell
> end kmRestoreApp
> -----------------------------------------------------------------------------
> try
> tell application "Keyboard Maestro Engine"
> set currentApp to process tokens "%CurrentApplication%"
> try
> set restoreApp to value of variable "restoreAppKM"
> on error
> make new variable with properties {name:"restoreAppKM", value:"FALSE"}
> end try
> if currentApp ≠ "BBEdit" then
> set value of variable "restoreAppKM" to currentApp
> openScratchpad() of me
> else if currentApp = "BBEdit" then
> if value of variable "restoreAppKM" = "FALSE" then
> openScratchpad() of me
> else
> kmRestoreApp() of me
> end if
> end if
> end tell
> on error errMsg number errNum
> set sep to "=============================="
> set e to sep & return & "Error: " & errMsg & return & sep & return ¬
> & "Error Number: " & errNum & return & sep
> beep
> tell application "System Events" to display dialog e
> end try
> -----------------------------------------------------------------------------
>
>
> --
> 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>
______________________________________________________________________
Philippe MARTIN
http://flip.macrobyte.net
--
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>