This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 General Action Scripts
 Remove the space from the copied text
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

chandisciple

75 Posts

Posted - 03/21/2016 :  02:54:27  Show Profile
Greetings Rob,

Hope everything is rocking there.

May i please request for some time, Just was stuck with editing a copied string. Need your expertise please.

I copy using a gesture and paste using another gesture, before i paste the copied text i want to remove the empty space IF there are any at the end of the text.

Went through 3di post and still could not crack it. :( what change would i have to do here,

acSendKeys("^c")
acDelay(50)
acSetClipboardText(acGetClipboardText():gsub(" ", "_"))

3di

Germany
26 Posts

Posted - 03/21/2016 :  08:22:59  Show Profile
Hi,

I use this one - it works like a charm.

Copy:

acSendKeys("^c")
acDelay(50)
local clip = acGetClipboardText()
clip = clip:gsub(" ", "")
acSetClipboardText(clip)

Paste:
acSendKeys("^v")


Best Regards
3di
Go to Top of Page

chandisciple

75 Posts

Posted - 03/21/2016 :  21:53:26  Show Profile
Hey 3di,

Thanks for the script . But i am sorry if i dint make my point clear earlier.

I want to delete empty space ONLY from the end of the string and only if there are any.

Thanks. :)
Go to Top of Page

chandisciple

75 Posts

Posted - 03/22/2016 :  21:53:53  Show Profile
Rob : Can i please request your expertise here too ?
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/22/2016 :  22:05:51  Show Profile  Visit Rob's Homepage
Try this:
acSendKeys("^c")
acDelay(50)
local clip = acGetClipboardText()
local parse = #clip
while parse > 0 and clip:find("^%s", parse) do parse = parse - 1 end
clip = clip:sub(1, parse)
acSetClipboardText(clip)
Modified from here: http://lua-users.org/wiki/CommonFunctions
Go to Top of Page

chandisciple

75 Posts

Posted - 03/23/2016 :  01:33:02  Show Profile


its so much fun when the scripts work the way you want. I tried the other options too and i modified your script to trim both leading and trailing. it works superb.

clip = (clip:gsub("^%s*(.-)%s*$", "%1"))

thanks again Genie
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000