【问题标题】:Getting variable type in Autohotkey在 Autohotkey 中获取变量类型
【发布时间】:2013-03-27 09:53:25
【问题描述】:

为什么这对确定类型起作用

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    
}

两个sn-ps都是用来检查输入框的结果。该脚本旨在帮助提取电影或某事。虽然你在完成第一部分后仍在下载并已经观看它..

这是完整的脚本,以防有人感兴趣。

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

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    我认为 autohotkey If var is [not] type 文档中的这句话将回答您的问题:

    注意:表达式中不支持运算符“between”、“is”、“in”和“contains”。

    请注意,无论这条规则如何,第二个示例对我来说都可以正常工作。

    【讨论】:

      猜你喜欢
      • 2015-08-18
      • 2015-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-27
      • 2016-06-03
      • 2018-07-30
      • 1970-01-01
      相关资源
      最近更新 更多