循环剪贴板和错误级别评估无法正常工作 [英] Looping clipboard and errorlevel evaluation not working as expected
问题描述
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
}
问题:ErrorLevel仍然被评估为true,而除非剪贴板中有东西,否则循环不会结束.这怎么可能? 澄清:进行此构造是为了尝试回答以下问题: SendEvent ^ {ins}是' t将内容复制到剪贴板 因此,是的,我知道循环剪贴板不是一种可靠的做法.但是除了采用这种结构,我别无选择.
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.
推荐答案
虽然循环需要表达式,但clipboard =
不是表达式.试试这个:
While loops expect expressions, clipboard =
is no expression. Try this one:
clipboard := ""
while( StrLen(clipboard) < 1 )
{
Send, ^{ins}
Sleep, 50
}
MsgBox % ClipBoard
这篇关于循环剪贴板和错误级别评估无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!