I just downloaded AutoHotkey and modified a script I found online, but the problem is that it works consistently only in notepad. In a Windows program, such as an HTML editor or in a textarea in Firefox, it rarely works (it seems to work once only after the 2nd try).
The script functionality is really simple: Copy the selected text to the clipboard, insert the the text that I specify at the beginning of it, along with a new line, and at the end of it, a new line, and the text that I specify.
This is the original script, which also doesn't work consistently in the other programs I mentioned. What it does is similar to what I want to do above, except that it doesn't insert any new lines, and it asks for what text to insert before and after the text.
Original Script:
#i::
clipsaved:= ClipboardAll
Send, ^c
WinGetTitle, CurrentWinTitle
InputBox, inputVar, Input character, Input character wHich will surround the text.
clip := Clipboard
clip = %inputVar%%clip%%inputVar%
Clipboard := clip
WinActivate, %CurrentWinTitle%
Send, ^v
Clipboard := clipsaved
return
Modified Script: The one I want to work
#+c::
clipsaved:= ClipboardAll
Send, ^c
WinGetTitle, CurrentWinTitle
; InputBox, inputVar, Input character, Input character wHich will surround the text.
clip := Clipboard
; clip = %inputVar%%clip%%inputVar%
clip = /*`r`n%clip%`r`n*/
Clipboard := clip
WinActivate, %CurrentWinTitle%
Send, ^v
Clipboard := clipsaved
return
So, what's wrong here? Also, why is it capturing something initially to the clipboard rather than Ctrl+C, and what is it doing at the end? Also, what's the purpose of it knowing where to activate (WinActivate) using the Windows Current Title (%CurrentWinTitle%).