AutoHotkey Community

It is currently May 25th, 2012, 4:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: May 13th, 2007, 1:04 am 
Offline

Joined: October 28th, 2006, 11:36 pm
Posts: 191
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 1:34 am 
This does it. :)
Code:
Loop parse, clipboard, `n
{
   l:=A_LoopField
   a = %a%>>%l%`n
   }
StringTrimRight a, a, 1
clipboard := a
MsgBox % a


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 4:18 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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 May 14th, 2007, 1:01 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 7:43 pm 
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. :) ....I'm confused!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 7:44 pm 
Sorry, that was me.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 11:04 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
*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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 11:55 pm 
Offline

Joined: November 17th, 2005, 10:14 pm
Posts: 196
Location: Leicester, UK
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2007, 12:51 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I see. Try this:
Code:
StringReplace c, ClipBoard, `n, `n>>%A_Space% , All
ClipBoard := ">> " . (SubStr(c,-2)=">> " ? SubStr(c,1,StrLen(c)-4) : c)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2007, 12:59 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
...and here is the single line version:
Code:
ClipBoard := ">> " . RegExReplace(ClipBoard,"`n([^$])","`n>> $1")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2007, 5:44 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
...which could be simplified to:

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

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], poserpro, Yahoo [Bot] and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group