2017-12-08 8 views
0

これらの各色をループすると、最初にctr jを押すと「赤」の2回目の「青」などが表示されます。 これは私のものです遠く自動ホットキーでオブジェクトをループする

^j:: 
colors := Object("red","blue","green", "black") 
for key, in colors 
    s .= key 
Send, % s 
Return 

しかし、私が手に私はそれを実行し、出力が

greenredgreenredgreenredgreenredgreenred 

答えて

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 

https://autohotkey.com/docs/Objects.htm#Usage_Simple_Arrays

です
関連する問題