AHK switch 语句的语法不起作用

Syntax for AHK switch statement not working

出现错误:

Line Text: switch %randNumber%

"Error: This line does not contain a recognized action"

;switches between one of the 6 user tabs

RandomizeTabSwitcher(){
    Random, randNumber, 1, 6
    
    switch %randNumber%
    {
        case 1:
        
        return
        
        case 2:
        
        return 
        
        case 3:
        
        return 
        
        . . .
    }
}

当我按照 switch doc 示例

时,不确定这里的问题是什么

https://www.autohotkey.com/docs/commands/Switch.htm

您使用的是过时的 AHK 版本。
通过从官方页面下载安装程序并 运行 进行更新。

这是添加 Switch 时的变更日志。 https://www.autohotkey.com/docs/AHKL_ChangeLog.htm#v1.1.31.00

此外,由于 Switch 命令相当新,谢天谢地它不支持遗留语法。
我建议您尝试摆脱使用旧语法。
所以,不要将变量定义包装在 %s.
中 正确的语法例如是:

Random, randNumber, 1, 3
    
Switch, randNumber
{
    case 1: MsgBox, 1
    case 2: MsgBox, 2
    case 3: MsgBox, 3
}