AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Prefix clipboard lines with quote >> character for ema

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
caveatrob



Joined: 28 Oct 2006
Posts: 188

PostPosted: Sun May 13, 2007 12:04 am    Post subject: Prefix clipboard lines with quote >> character for ema Reply with quote

Hi all,

I'm trying to figure out how to make a script that prepends each line of the clipboard with a quote marker ">>" for email.

I'm trying to turn off the automatic quoting feature in gmail so I can selectively copy and paste that which I want to quote and indicate that the material was quoted.

Thanks!

Rob
Back to top
View user's profile Send private message
*MsgBox
Guest





PostPosted: Sun May 13, 2007 12:34 am    Post subject: Reply with quote

This does it. Smile
Code:
Loop parse, clipboard, `n
{
   l:=A_LoopField
   a = %a%>>%l%`n
   }
StringTrimRight a, a, 1
clipboard := a
MsgBox % a
Back to top
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun May 13, 2007 3:18 pm    Post subject: Reply with quote

Code:
StringReplace c, ClipBoard, `n, `n>>%A_Space% , All
ClipBoard := ">> " . (SubStr(c,-2)=">> " ? SubStr(c,1,StrLen(c)-4) : c)
With RegExReplace you can do it in one line, but it is somewhat slower. [Bugfixed]

Last edited by Laszlo on Mon May 14, 2007 12:01 am; edited 1 time in total
Back to top
View user's profile Send private message
Lazslo
Guest





PostPosted: Sun May 13, 2007 6:43 pm    Post subject: Reply with quote

Laszlo, I see that yours is the nicer solution, but why the SubStr and StrLen functions? As far as I can see, this works just as well:
Code:
StringReplace c, ClipBoard, `n, `n>>%A_Space%, All
ClipBoard = >>%A_Space%%c%


Also I have just noticed that using caveatrob's post as the text, your code leaves out his name. Smile ....I'm confused!
Back to top
*MsgBox
Guest





PostPosted: Sun May 13, 2007 6:44 pm    Post subject: Reply with quote

Sorry, that was me.
Back to top
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun May 13, 2007 10:04 pm    Post subject: Reply with quote

*MsgBox alias Lazslo wrote:
why the SubStr and StrLen functions?
They just remove the trailing ">> " in a new line. If you don't mind having this extra three characters in the last line, drop the last expression out, as you did.

The script did not leave out anything, when I tried it in my XP SP2 laptop. Could you make sure, the name was properly selected?
Back to top
View user's profile Send private message
MsgBox



Joined: 17 Nov 2005
Posts: 181
Location: Leicester, UK

PostPosted: Sun May 13, 2007 10:55 pm    Post subject: Reply with quote

Your code replaces `n with `n>>%A_Space%. There isn't a `n after the word Rob, therefore no trailing >>.

I tested both again (just to be sure), mine worked and yours didn't. :p

but...

if there is a new line selected AFTER the word Rob, then my version has a trailing >> and your version works. Smile
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun May 13, 2007 11:51 pm    Post subject: Reply with quote

I see. Try this:
Code:
StringReplace c, ClipBoard, `n, `n>>%A_Space% , All
ClipBoard := ">> " . (SubStr(c,-2)=">> " ? SubStr(c,1,StrLen(c)-4) : c)
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun May 13, 2007 11:59 pm    Post subject: Reply with quote

...and here is the single line version:
Code:
ClipBoard := ">> " . RegExReplace(ClipBoard,"`n([^$])","`n>> $1")
Back to top
View user's profile Send private message
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Mon May 14, 2007 4:44 pm    Post subject: Reply with quote

...which could be simplified to:

Code:
clipboard := RegExReplace(clipboard, "m)^", ">> ")

_________________
GitHubScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group