问题
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.
回答1:
While loops expect expressions, clipboard =
is no expression. Try this one:
clipboard := ""
while( StrLen(clipboard) < 1 )
{
Send, ^{ins}
Sleep, 50
}
MsgBox % ClipBoard
来源:https://stackoverflow.com/questions/18176217/looping-clipboard-and-errorlevel-evaluation-not-working-as-expected