如何循环显示这些颜色,以便在第一次按ctr j时显示"红色"第二次"蓝"等等 这就是我到目前为止所拥有的
^j::
colors := Object("red","blue","green", "black")
for key, in colors
s .= key
Send, % s
Return
但是,当我运行它时,我得到的输出是
greenredgreenredgreenredgreenredgreenred
答案 0 :(得分:1)
; Creating an array:
colors := ["red","blue","green","black"]
; or:
; colors := Array("red","blue","green", "black")
; MaxIndex returns the number of items:
MaxIndex := colors.MaxIndex()
^j::
Index++ ; increases the number in the variable "Index" by 1, each time you press ^j.
Send, % colors[Index]
If (Index = MaxIndex)
Index = 0 ; reset
return