cheek
Joined: 01 Apr 2009 Posts: 68
|
Posted: Wed Apr 01, 2009 7:58 pm Post subject: 'send ^v' does not always paste correct clipboard contents |
|
|
Im seeing some strange behavior trying to automate a paste operation to send a large volume of text at once. I am using essentially
| Code: |
Clipboard = [LARGE TEXT]
Send ^v
|
and seeing the text that is pasted is not the text I assigned to clipboard, rather the previous contents of the clipboard. To clarify, more code; I have created the following method included in my library:
| Code: |
SendClip(output)
{
ClipBackup = %ClipboardAll%
clipboard =
success = 0
Sleep 100
clipboard = %output%
;ClipWait, 2
;if (ErrorLevel = 0)
;{
; success = 1
;}
Loop
{
Sleep 100
if (clipboard = output)
{
success = 1
break
}
if (A_Index > 20)
{
break
}
}
if (success)
SendInput ^v
clipboard = %ClipBackup%
ClipBackup =
return %success%
}
|
You can see that I had originally tried using the recommended ClipWait, but switched to a loop process to try ensure that the contents of the clipboard are the text i intend to send. This loop is breaking with success = 1, despite the fact that when I 'Send ^v' the wrong text is pasted. Every once in a while, i'll get the correct paste. I've tried to 'FileAppend' the current contents of the clipboard to a file just before sending ^v to manually double check the value, and it always seems correct.
It looks like windows isn't being given the latest value of the clipboard at assignment time, but internally 'clipboard' evaluates to its correct assigned value. This would explain why AHK thinks everything is correct, but when i try to do a system paste, the value is incorrect.
Has anyone run into this or have any ideas? Are there any better methods for sending large volumes of text at once, without using the clipboard and without waiting for 'Send' to send the keystrokes individually? |
|