Looping clipboard and errorlevel evaluation not working as expected

瘦欲@ 提交于 2019-12-13 06:51:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!