AHK 中的 if (expression) VS "Traditional If"

if (expression) VS "Traditional If" in AHK

下面的简单脚本先显示 Yes,然后显示 No。

我不明白。

根据我在 AHK 文档中阅读的内容,我怀疑这与 if (expression) VS "Traditional If" 有关。 但是我发现关于这个主题的文档不是很清楚。

有人可以解释一下吗?

#SingleInstance force
#NoEnv

Toto := "c"

If (Toto In a,b)
    MsgBox Yes
Else
    MsgBox No

If Toto In a,b
    MsgBox Yes
Else
    MsgBox No

您不能将 IN 与表达式一起使用。

您的第一个示例使用了一个不支持使用 IN 的表达式。因此语句的行为是未定义的。

你的第二个例子是正确的并产生了正确的结果。

来自https://autohotkey.com/docs/commands/IfIn.htm

The operators "between", "is", "in", and "contains" are not supported in expressions.