1

Enclosing a string would be particularly useful on message boards with no markdown shortcuts, instead of typing [quote] [/quote] I could use a hotkey to do so. Adding quotation marks (") or other characters around selected text would be useful as well.

2

Adding quotation marks (") around selected text:

F1::
ClipSaved := ClipboardAll   ; save the entire clipboard to the variable ClipSaved
clipboard := ""             ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
Send, ^c                    ; copy the selected text
ClipWait, 1                 ; wait for the clipboard to contain data 
if (!ErrorLevel)            ; if NOT ErrorLevel, clipwait found data on the clipboard
clipboard = "%clipboard%"   ; add the quotation marks
Sleep, 300
    Send, ^v
Sleep, 300
clipboard := ClipSaved      ; restore original clipboard
return

To enclose selected text between [quote] and [/quote], use another hotkey and the same procedure. Just replace clipboard = "%clipboard%" with clipboard = [quote]%clipboard%[/quote] in the above code.

For typing or pasting text between [quote] and [/quote] use this:

F2:: SendInput, [quote][/quote]{Left 8}
6
  • You could add some additional information (e.g. execute using F1 and F2), novice users aren't necessarily able to modify the code to better suit their needs or even understand it. I'd clear the comments a bit and move some parts out of the "code box". – user598527 Jun 11 '17 at 15:26
  • I would not mind explaining some part of the code, if someone has a question to it. Explaining all the details would be too extensive. It is also recommended for all users who want to gain an overview of the program, to read the more comprehensive manual, which also includes a tutorial and an index. As I said before, If you don't understand something, feel free to ask. – user3419297 Jun 11 '17 at 15:58
  • F2:: SendInput, [quote][/quote]{Left 8} script appears not to work, it replaces the selected text with [quote][/quote]. – user598527 Jul 1 '17 at 17:06
  • This code is only for typing or pasting text between [quote] and [/quote]. To enclose selected text use the first code with another hotkey. Just replace clipboard = "%clipboard%" with clipboard = [quote]%clipboard%[/quote] in it. – user3419297 Jul 1 '17 at 18:02
  • 1
    Can you edit your post and add complete script for enclosing with "[quote][/quote]"? I understand now, but some others may not. – user598527 Jul 1 '17 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.