Ctrl+c putting text on clipboard and ClipWait detection of it
Posted: 01 Jun 2020, 14:11
Hi Folks,
I wrote a hotkey with the following code:
When it gets to the "process text on clipboard" code, it may fail, because, apparently, ClipWait detects text that had already been on the clipboard before the hotkey fired. Furthermore, the contents of the clipboard at the "process text on clipboard" code is what was on the clipboard before the Send ^c. I find this really surprising.
To fix it, I added Clipboard:="" before the Send ^c. I then saw that this matches example #1 at the ClipWait doc and the "Using ClipWait to improve script reliability" example at the Clipboard doc.
Yes, that works, but it shows that Send ^c has not finished putting new text on the clipboard before it falls through to the next statement. This raises the question of how to know when Send ^c has placed ALL of the new text on the clipboard. In other words, when can we be certain that after success from ClipWait (i.e., ErrorLevel=0) that ALL of the new text is there, especially when the Ctrl+c is copying a large amount of text?
Thanks, Joe
I wrote a hotkey with the following code:
Code: Select all
Send ^c
ClipWait,1
If (ErrorLevel=1)
{
MsgBox,4144,Error,No text appeared on clipboard after Ctrl+c and waiting for one second
Return
}
; process text on clipboard
To fix it, I added Clipboard:="" before the Send ^c. I then saw that this matches example #1 at the ClipWait doc and the "Using ClipWait to improve script reliability" example at the Clipboard doc.
Yes, that works, but it shows that Send ^c has not finished putting new text on the clipboard before it falls through to the next statement. This raises the question of how to know when Send ^c has placed ALL of the new text on the clipboard. In other words, when can we be certain that after success from ClipWait (i.e., ErrorLevel=0) that ALL of the new text is there, especially when the Ctrl+c is copying a large amount of text?
Thanks, Joe