Quote Selected Text

Announcement and discussion of shortcuts available in the Online Gallery

Quote Selected Text

Postby gb2 » Wed Jan 06, 2010 2:57 pm

Adds quotes to selected text.

Click here to download

Scopes:  All Applications
Author:  gb2
 Added:  January 06, 2010
User avatar
gb2
Site Admin
 
Posts: 2878
Joined: Mon Feb 06, 2006 6:22 pm

Re: Quote Selected Text

Postby bakari45 » Thu Jan 07, 2010 2:59 am

Because I'm a writer, this macro is very handy for me. I've already used it four times today. But I really want to understand how it's put together. I've read up on the topic of variables in the QuicKeys manual, but the section simply does not help. I can see that two of the shortcut variables seem to be copying and pasting selected text and adding the quotation marks when the text is pasted. But I can't see how it's done. I'm missing it.

I know you guys are very busy, but if you do get some time, please break the macro down. I'll do a video tutorial of it once I understand it.
bakari45
 
Posts: 113
Joined: Mon Dec 14, 2009 2:00 am

Re: Quote Selected Text

Postby jim » Thu Jan 07, 2010 9:53 am

One of the things that a lot of people struggle with when first learning QuicKeys is understanding the application is just a stand-in for the user (more or less). True, QuicKeys can do a ton of stuff but for the most part, we're just issuing commands and watching for things to happen just like the user would. This shortcut is a great example of how something that seems really difficult to do isn't anything more than a couple of copy-n-paste commands.

Step #1 is simply saving the contents of the current Clipboard to a QuicKeys variable so we can restore it later. So in case you have your life's work on the clipboard (and nowhere else), we don't destroy it by putting some quotes around text.

Step #2 issues a Command-C, a plain old copy command. This sticks whatever's highlighted on the Clipboard (and since QuicKeys watches the Clipboard for changes, we immediately have access to whatever was copied via our "Clipboard" variable)

Step #3 pastes the result of the equation ["<Clipboard Variable>"] via a mechanism that's almost identical to a Command-V. Equations that have plain text in them simply shove that text into the output they generate. So you read the equation in Step #3 as 'Concatenate a double-quote, then the value of the Clipboard variable, then another double-quote'. The action of "insert value" is what does the actual pasting back into whatever application you're working with. Since the original text is still highlighted, our paste clears that value and replaces it with the new quoted string.

Step #4 is just putting back onto the system Clipboard what we originally found there in Step #1.

Does that help clear things up?
jim
Site Admin
 
Posts: 89
Joined: Mon Feb 06, 2006 6:38 pm

Re: Quote Selected Text

Postby bakari45 » Thu Jan 07, 2010 3:10 pm

Thanks for feedback. Well, yeah, some of this stuff should seem pretty obvious, but for many of us users, we just don't have the background in programming to see the obvious. That's why I try to breakdown what I understand by using screenshots and video tutorials.

Anyway, I just realized in working through the workflow that the 3rd shortcut included the quotation marks. I had previously overlooked them. This works similar to adding quotation marks using Typinator word expansion program. But I think my challenge is that I haven't quite grasped how to use Variable values in programs like QuicKeys and Automator. I'm sorta familiar with the concept of variables in JavaScript, but I lack skills in that program as well.

So yeah, your description helped some. My real understanding though will show if I can produce similar macros using different variables. I'll be working on that. thanks
bakari45
 
Posts: 113
Joined: Mon Dec 14, 2009 2:00 am

Re: Quote Selected Text

Postby bakari45 » Fri Feb 26, 2010 7:37 pm

For some reason, I’ve messed up this macro. I must of changed the variable thing or something, because now when I try to use it, it doesn’t re-paste the word selected with the quote, but instead pastes the same word with quotes each time. It’s weird, because it was working, but I may have done something to mess it up. Could someone tell me how to fix it. I tried re-downloading the macro, but it ends up doing the same thing.
bakari45
 
Posts: 113
Joined: Mon Dec 14, 2009 2:00 am

Re: Quote Selected Text

Postby gb2 » Mon Mar 01, 2010 10:53 am

if you have deleted it and downloaded it again it should work. I'm not clear what you are saying it isn't doing correctly.
it doesn’t re-paste the word selected with the quote, but instead pastes the same word with quotes each time.

please explain again what it is doing wrong. What it is suppose to do is you should select a word or a group of words that are not quoted and it pastes it back in with quotes around what was selected.
User avatar
gb2
Site Admin
 
Posts: 2878
Joined: Mon Feb 06, 2006 6:22 pm

Re: Quote Selected Text

Postby hujhax » Sat Dec 24, 2011 12:31 pm

I was really happy to see this shortcut, since I had something like this set up on my PC with AutoHotkey. But the AHK version had a couple of additional features I was looking to add to this QuicKeys shortcut.

First, my old AHK script does one of two things: (1) if there's text selected, it does exactly what this shortcut does; (2) if there's *no* text selected, it types out two quote marks and leaves the cursor between them. Is there any way to convince QuicKeys to do that sort of if/then logic?

Second, in AHK I could dump this whole shortcut into a function with the "pre" and "post" tag strings as parameters. So I could call it with quote marks for "quoted text", or I could call it with asterisks for *emphasized text*, or parentheses for (parenthesized text), and so on. Is there any way to parameterize a QuicKeys shortcut?

~ thanks ~
=-p-=
hujhax
 
Posts: 2
Joined: Sat Dec 24, 2011 12:29 pm

Re: Quote Selected Text

Postby gb2 » Tue Dec 27, 2011 11:29 am

change from this 4 step shortcut:
1) Assign Variable - savedClipboard = Clipboard
2) Type Keystroke - command-c
3) Insert Clipboard quoted
4) Restore Clipboard from variable savedClipboard

to this 7 step shortcut by adding new steps 2, 5 & 6:
1) Assign Variable - savedClipboard = Clipboard
2) Assign Variable - Clipboard = leaving the field under the pop-up blank
3) Type Keystroke - command-c
4) Insert Clipboard quoted
5) Compare Variable - Clipboard Is Empty - change the Step Results to Jump to Step 7
6) Type Keystroke - left arrow
7) Restore Clipboard from variable savedClipboard

you could replace the quotes in step 4 with two different variables and then you would have to make supporting shortcuts that would set those variables. I think the simplest thing would be to just duplicate the shortcuts and change the hot key on each and change the quotes to what you wanted in step 4.
User avatar
gb2
Site Admin
 
Posts: 2878
Joined: Mon Feb 06, 2006 6:22 pm

Re: Quote Selected Text

Postby hujhax » Tue Dec 27, 2011 10:43 pm

Thanks, gb2!  Implementing this will make the Mac a far friendlier place for me.
hujhax
 
Posts: 2
Joined: Sat Dec 24, 2011 12:29 pm


Return to Shortcut Gallery Submissions

Who is online

Users browsing this forum: No registered users and 1 guest