如何在Autohotkey中发送数组变量的值?

如何在Autohotkey中发送数组变量的值?

问题描述:

我正在写一个需要显示数组变量的值的AutoHotkey脚本,但它似乎没有正常工作。如何在Autohotkey中发送数组变量的值?

MyArray := ["one", "two", "three"] 

send MyArray[1]  ; "MyArray[1]" 
send MyArray%1%  ; "MyArray" 
send %MyArray1%  ; <empty> 
send % MyArray%1% ; <empty> 
;send %MyArray%1% ; 'Error: Variable name missing its ending percent sign' 
;send %MyArray%1%% ; 'Error: Empty variable reference (%%)' 
;send %MyArray[1]% ; 'Error: Variable name contains an illegal character' 

我发现posts on the AHK forums声称我可以使用send %MyArray1%send % MyArray %1%,但是这两个命令只是参考变量空。

如何在AutoHotkey脚本中发送数组值?

使用单个%来强制单个参数的表达模式。

MyArray := ["one", "two", "three"] ; initialize array 
Send, % MyArray[1]     ; send "one" 

这可以使用常规的文本引号""

Send, % "The first value in my array is " MyArray[1] 

表达模式进行组合可以与任何命令一起使用,包括MsgBoxTrayTip

MsgBox, % MyArray[1] 
Traytip, , % "The first value is " MyArray[1] 

参见