Jump to content

Apply Hotkey to Selection and Keep Clipboard?

Recommended Posts

Hi all! --
This may be a dumb question.
I am trying out Derick Fay's "case converter" workflow, and I noticed that if I selected (say) "foo" and uppercased it, then whatever I had on my clipboard got thrown out and changed to "foo".
So I tried making this simple hotkey that wasn't hooked up to anything:
And I noticed that this, too, was wiping out my clipboard.
I have two questions about this:
1. Is there any way to pass the "Selection in OS X" to a script *without* obliterating the clipboard?
2. Failing that, is there some way to access the *original* clipboard contents in my script, so that I can put that back on the clipboard when I'm done?
~ thanks! ~



Edited by hujhax
Link to comment

Yeah you're probably right. I've subsequently rewritten the whole case converter in Python but never released it. Saving/restoring the clipboard should be easy to add to that version. I'll try to get to it soon.

But....I am so used to relying on Alfred's clipboard history that I rarely worry about wiping out the clipboard myself...

Link to comment

So...I spoke too soon (and didn't catch every detail of the discussion above - I realize now that hujhax actually made this point...).  Alfred apparently uses the clipboard when a hotkey is set up to act on Selection in OS X.  


In principle one could use a hotkey with no arguments to call a script which 1) caches the clipboard, 2) does something with Applescript UI scripting / System Events like this: http://macscripter.net/viewtopic.php?id=33575 , 3) does the conversion, and 4) restores the clipboard.  

Link to comment
Awesome -- thanks for the info!  I'll use that strategy in future.


(Or actually I'll probably save off the clipboard, set the clipboard to some weird sentinel value, and *then* send the command-C, so I can verify that there's actually something selected.)


~ excelsior! ~


Edited by hujhax
Link to comment
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...