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 

Copy from Clipboard

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



Joined: 20 Sep 2005
Posts: 100

PostPosted: Tue Apr 08, 2008 1:35 pm    Post subject: Copy from Clipboard Reply with quote

I wonder if somebody could help me here please.

I'm trying to get all of an address off of a web page that is currently written as follows:

The House Name
The Street
The Locality
The Town
The Postcode

Tel No: 12345 67890

Into windows notepad but written as:

The House Name, The Street, The Locality, The Town, The Postcode, Tel No: 12345 67890

i.e. all in a single line and removing any spaces, as is between the postcode and tel no.

I have tried using:
StringReplace, Clipboard, Clipboard, `r`n, `n, All

but it doesn't seem to work, it just copies it straight off the clipboard

Full code:

Code:
Insert::
Clipboard =
SendInput ^c
ClipWait, 1 , 1
if ErrorLevel <> 0
{
   MsgBox, 4160, Error Message, No text has been selected!
   return
}
StringReplace, Clipboard, Clipboard, `r`n, `n, All
StringReplace, Clipboard, Clipboard, Show Map,, All
Loop, Parse, Clipboard, `n, `r
   {
   If !A_LoopField
      Continue
   Else
      Clipboard2 .= A_LoopField . "`n"
   }

      WinActivate, Untitled - Notepad
      ifWinExist, Untitled - Notepad
      Sleep, 200
       SendInput `r%Clipboard%
      Sleep, 500
      Clipboard =
   return
Back to top
View user's profile Send private message
Razlin



Joined: 05 Nov 2007
Posts: 434
Location: canada

PostPosted: Tue Apr 08, 2008 1:53 pm    Post subject: Reply with quote

Code:
StringReplace, Clipboard, Clipboard, `r`n, `n, All

;should be

StringReplace, Clipboard, Clipboard, `r`n, %A_SPACE%, All


Replace `r`n return and newline with A space.

hope this helps
_________________
-=Raz=-
Back to top
View user's profile Send private message
BradleyS



Joined: 20 Sep 2005
Posts: 100

PostPosted: Tue Apr 08, 2008 9:08 pm    Post subject: Reply with quote

That did the trick thank you.

However, how difficult would it be to include a comma after each paragraph return? so that it looks like:
The House Name, The Street, The Locality, The Town, The Postcode, Tel No: 12345 67890

Instead of:
The House Name The Street The Locality The Town The Postcode Tel No: 12345 67890

...or am I asking to much of AHK?
I'm not really quite sure how to start to tackle it either.
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 387
Location: Midwest, USA

PostPosted: Tue Apr 08, 2008 9:48 pm    Post subject: Reply with quote

Instead of
Code:
StringReplace, Clipboard, Clipboard, `r`n, %A_SPACE%, All

Try:
Code:
StringReplace, Clipboard, Clipboard, `r`n, `,%A_SPACE%, All

Not tested.
_________________
SilverEdge78
Back to top
View user's profile Send private message
BradleyS



Joined: 20 Sep 2005
Posts: 100

PostPosted: Tue Apr 08, 2008 11:11 pm    Post subject: Reply with quote

That will do me.

Thank you both very much
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   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