0
while clipboard =
    {
        SendEvent, ^{ins}                                   ;^c doesn't work
        sleep 50
    }
    clipWait, 2                                     ; Wait for the clipboard to contain text.
    if ErrorLevel
    {
        ;endEvent, ^{ins}
        MsgBox Failed to save the selection: %clipboard%
        ;exit
    }

Problem: ErrorLevel still gets evaluated as true, whereas the loop shouldn't finish unless something came inside the clipboard. How is this possible? Clarification: This construction was made as an attempt to answer question: SendEvent ^{ins} isn't copying content to the clipboard As such, yes I am aware that looping the clipboard is not regarded as a reliable practice. But I have no other alternative than employing such a construction.

Community
  • 1
  • 1
Khalil
  • 311
  • 5
  • 16

1 Answers1

1

While loops expect expressions, clipboard = is no expression. Try this one:

clipboard := ""
while( StrLen(clipboard) < 1 )
{
    Send, ^{ins}
    Sleep, 50
}
MsgBox % ClipBoard
MCL
  • 3,985
  • 3
  • 27
  • 39
  • Your code is working for me, thanks. However, the actual problem is still standing. This is further being discussed in my previous post: [SendEvent ^{ins} not working properly](http://stackoverflow.com/questions/18175903/sendevent-ins-isnt-copying-content-to-the-clipboard) – Khalil Aug 14 '13 at 14:02