1

タイプを判別するためにこれが機能するのはなぜですか

if delay is integer
{
    MsgBox You set delay = %delay% seconds
    return
}
else
{
    MsgBox "%delay%" is not a valid number.
    goSub, input    
}

しかし、これではありません-これは、0より大きい限り、整数以外の値も許可します

if (delay is integer and delay > 0)
{
    MsgBox You set delay = %delay% seconds
    return
}
else
{
    MsgBox "%delay%" is not a valid number.
    goSub, input    
}

どちらのスニペットも、入力ボックスの結果をチェックするためのものです。このスクリプトは、映画やsthの抽出を支援することを目的としています。あなたがまだダウンロードして、最初の部分かそこらを終えた後にすでにそれを見ている間..

誰かが興味を持った場合に備えて、完全なスクリプトを次に示します。

delay := 120
help = Help - Unzip Auto Extractor`nF1: Help`nF2: Get Unzip Window`n(must be in foreground)`nF3: Set unpack delay (seconds, default 120)`nF4: Start or stop unpacking`nF5: Exit
MsgBox %help%
F1::
MsgBox %help%
return

F2::
WinGetTitle, title, A
MsgBox Selected window "%title%"
return

F3::
input:
InputBox, delay, Set extraction timeout in seconds..,Use numbers only,,,,,,,,%delay%
;InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default] 
if delay is integer
{
    MsgBox You set delay = %delay% seconds
    return
}
else
{
    MsgBox "%delay%" is not a valid number.
    goSub, input    
}

#MaxThreadsPerHotkey 3
F4::
#MaxThreadsPerHotkey 1
if KeepWinZRunning
{
    KeepWinZRunning := 0
    return
}
else
{
KeepWinZRunning := 1
}
Loop
{   
    Loop %delay%
    {
        sleep 1000
        if not KeepWinZRunning
        {
            break   
        }
    }
    if not KeepWinZRunning
    {
        break           
    }   
    ControlSend,,{Enter},%title%    
}
KeepWinZRunning := 0
return

F5::
ExitApp
return
4

1 に答える 1

0

私はautohotkeyからのこの引用がvarが[ではない]タイプのドキュメントがあなたの質問に答えると思います:

注:演算子「between」、「is」、「in」、および「contains」は、式ではサポートされていません。

このルールに関係なく、2番目の例は問題なく機能することに注意してください。

于 2013-03-27T01:53:25.170 に答える