hujhax Posted February 21, 2015 Share Posted February 21, 2015 (edited) 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: http://screencast.com/t/HI2Y6JicAx 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! ~ =-peter Edited February 21, 2015 by hujhax Link to comment
RodgerWW Posted February 22, 2015 Share Posted February 22, 2015 You could set a variable in the script: using the contents of the clipboard as that variable. Run whatever scripting needs to be done normally. Then place the original variable back to the clipboard. Or, use a clipboard manager Link to comment
hujhax Posted February 22, 2015 Author Share Posted February 22, 2015 Hmm -- except by the time I get to the script, my clipboard contents are already gone. If I put the contents of the clipboard into a variable, I'm just getting the current OSX selection. Link to comment
RodgerWW Posted February 22, 2015 Share Posted February 22, 2015 My suggestion would require that the original workflow be edited so that the FIRST step of the script would be to grab the contents of the clipboard as a variable ... and the last step to put it back. Link to comment
dfay Posted February 22, 2015 Share Posted February 22, 2015 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
dfay Posted February 22, 2015 Share Posted February 22, 2015 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
hujhax Posted February 23, 2015 Author Share Posted February 23, 2015 (edited) 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! ~ =-Peter Edited February 23, 2015 by hujhax Link to comment
hujhax Posted March 22, 2015 Author Share Posted March 22, 2015 Thanks for your help, folks! Here's what I've got so far. It's a workflow that sets up lots of hotkeys for processing the selected text. So far I've got hotkeys for: *adding asterisk tags* (adding parens) _adding underscores_ interspersing-with-hyphens #makingahashtag TOGGLING CASE ... and shortening the selected URL. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now