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 

Junk captured by clipboard or ControlSendText

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



Joined: 22 May 2007
Posts: 73

PostPosted: Thu Oct 22, 2009 10:41 pm    Post subject: Junk captured by clipboard or ControlSendText Reply with quote

Im copying data from a spreadsheet via ^c (OpenOffice currently), about 10 values, then sending the value using ControlSendText to another application. The values all go to the correct controls on the application, but there is always trailing garbage. For example, if I have it copy "123 Sesame Street" from the spreadsheet, ControlSetText sends "123 Sesame Street□□". If I paste into the browser or notepad it looks correct, so I dont think its happening in the clipboard. Any suggestions?

Thanks
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 1158
Location: San Diego, California

PostPosted: Thu Oct 22, 2009 10:59 pm    Post subject: Reply with quote

I suggest that the junk is CR/LF http://www.autohotkey.com/docs/misc/Clipboard.htm
Quote:
Each line of text on Clipboard typically ends with carriage return and linefeed (CR+LF), which can be expressed in the script as `r`n.

Ths script will illustrate and possibly give you an idea how to proceed.
Select a cell in the spreadsheet and then hit Win-q

Code:
#q:: ; win-q hotkey
Send ^c
clipwait, 1,1

msgbox before '%clipboard%'

StringReplace, clipboard, clipboard,`r`n,,all

msgbox after '%clipboard%'


An alternative is to use COM, which I have not explored
http://www.autohotkey.com/forum/viewtopic.php?t=22923&highlight=excel+com
Back to top
View user's profile Send private message
tekkie2412



Joined: 22 May 2007
Posts: 73

PostPosted: Thu Oct 22, 2009 11:12 pm    Post subject: Reply with quote

Ah yes, I forgot about string replace. I was trying all these and going nuts. The stringreplace works semi-perfectly Smile

Code:

ControlSetText, control, %Name%`r`n, WinName
ControlSend, control, %Name%, WinName
ControlSendRaw, control, %Name%, WinName
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 1158
Location: San Diego, California

PostPosted: Fri Oct 23, 2009 1:41 am    Post subject: Reply with quote

Quote:
The stringreplace works semi-perfectly

Ok, how do we get a higher score than "semi" ? Wink
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