RegExReplace leaving only numbers in clipboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
aisvais
Posts: 4
Joined: 26 Sep 2017, 03:44

RegExReplace leaving only numbers in clipboard

17 Nov 2017, 07:09

Hello,

I need some help finding out what is wrong with my code or if any of the problems I get are my code's fault.

Basically, I have PDF file with number in it which I copy and paste to Outlook email, filling all the information to Outlook first.
The number looks like this: 012345-6789 and I wanted it pasted to Outlook as NR:0123456789.

So problems that I have now are:
1. Whenever I post the same outcome to Outlook, magical space gap appear making my string look like NR: 0123456789. I do not want that gap. Does not do that in any other programs.
2. Sometimes - is not removed. For some instances it gets removed, for others not. I can't tell the difference between - (gets copied) and - (doesn't get copied) just by looking at it. There is a possibility that my PDF is messed up, but is there any way to change it.
3. Sometimes the number is not pasted completely. But when the code is ran second time, all is good. At first it was a matter of sleep time, so I set it as 500 before and after the pasting moment.

The full code I use is

Code: Select all

^+O::
Send,^c
Clipboard := RegExReplace(clipboard,"\D")
StringReplace, clipboard, clipboard, -,, All
Send {F10}
Send F
Send {Down}{Down}{Down}{Down}{Down}
Send {enter}
Sleep 2000
Send, email
Send {enter}
Send {tab}
Send {tab}
Send subject
Send {tab}
Send {tab}
Send NR=
Sleep 500
Send ^v
Sleep 500
return
I select the number I want to copy and run the code. From the Adobe Acrobat it goes to the File>Send File and then inputs all the information in outlook.

Any ideas are welcome because I am out of ideas already. I can not see any differences between instances that get messed up by the code and instances that don't.

BR,
Aiste
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: RegExReplace leaving only numbers in clipboard

17 Nov 2017, 08:54

Perhaps use ClipWait.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo, Bing [Bot], metallizer, sjoumms and 143 guests