Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Tinderbox applications >> Using Tinderbox with Keyboard Maestro
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1221603103

Message started by greg ibendahl on Sep 16th, 2008, 6:11pm

Title: Using Tinderbox with Keyboard Maestro
Post by greg ibendahl on Sep 16th, 2008, 6:11pm

Anyone else try using TB with Keyboard Maestro? While Tinderbox has very limited Apple Script and Automator support, it does have a lot of shortcut keystrokes. This lends itself fairly well to a program like Keyboard Maestro or similar program to record keyboard and mouse actions.

Here's what I'm doing with it. I often copy text out of Safari to save for later. Lots of programs can do this but they often just save the whole page which is more than I need. I now have a system where I can highlight my desired text in safari and then press a keyboard shortcut to put this text into a new note with the URL field set to the current Safari page and with a title auto generated from the first 10 words of what I've selected.

Here's the commands you need in KM

Activate Safari.app
Copy to clipboard ‘Clipboard #2’
Execute ‘Copy URL to clipboard.scpt’ AppleScript
Pause For 0 Seconds
Filter Clipboard: Remove Styles
Activate Tinderbox.app
Pause For 1 Seconds
Type the ⌘K Keystroke
Pause For 0.1 Seconds
Type the ⌘V Keystroke
Pause For 0.1 Seconds
Type the Return Keystroke
Pause For 0.1 Seconds
Set Clipboard To Named Clipboard ‘Clipboard #2’
Pause For 0 Seconds
Filter Clipboard: Remove Styles
Pause For 0.1 Seconds
Type the ⌘V Keystroke
Pause For 0.1 Seconds
Type the ⌘W Keystroke
Pause For 0.1 Seconds
Activate Safari.app

there's also an Applescript that goes along with this and you need an agent in your TB file to generate the title and move the URL to the URL field. I'll post that later if there is interest.


Title: Re: Using Tinderbox with Keyboard Maestro
Post by rtalexander on Sep 17th, 2008, 12:09am

Yes, please post the rest!

Title: Re: Using Tinderbox with Keyboard Maestro
Post by greg ibendahl on Sep 17th, 2008, 11:34am

I have a top level note called "Notes" with all the clipped notes from Safari as children. Before running the Keyboard script, be sure to have one of the children highlighted. Otherwise, I have a user attribute called "updateURL" that can be either true or false and I have a prototype called "Note prototype" that just sets the font and color.

The major element is an agent that has this for a query:
updateURL=false & #descendedFrom(Notes)

The action for this agent is:
Prototype = "Note prototype";  URL = $Name; Name = ^text( this, 10 )^; if($Name != "") {updateURL = true}

That's it on the Tinderbox side. You'll notice that the Keyboard script refers to an Applescript that I've copied below. Sorry, I can't find the reference for the script.

tell application "Safari"
     tell document 1
           set the clipboard to my escapeURL(URL)
     end tell
end tell
on escapeURL(aURL)
     set newURL to ""
     set savedDelimiters to AppleScript's text item delimiters
     set AppleScript's text item delimiters to {"&"}
     
     set aCount to count text item of aURL
     repeat with index from 1 to (aCount - 1)
           set newURL to newURL & (text item index of aURL) & "&"
     end repeat
     set newURL to newURL & last text item of aURL
     
     set AppleScript's text item delimiters to savedDelimiters
     return newURL
end escapeURL

The overall effect is pretty good. On some computers you might need to adjust the pause times for the Keyboard script as sometimes the computer might not react as quick as the script runs. The only really downside to the process is that you must keep Keyboard Maestro up and running. It would be nice if Tinderbox had a broader Applescript dictionary (hint hint), but I would rather see TB become a native Intel application first.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.