2015-11-01 148 views
0

在AutoHotkey的陣列中,我定義一個全局數組:AutoHotkey的:訪問座標

BuildTabIndexArray() 
{ 
    global 

    ; coords of each of the 8 selectable tabs on screen 
    tab_index_array.Push(332,490) 
    tab_index_array.Push(378,490) 
    tab_index_array.Push(433,490) 
    tab_index_array.Push(486,490) 
    tab_index_array.Push(557,490) 
    tab_index_array.Push(611,490) 
    tab_index_array.Push(685,490) 
    tab_index_array.Push(745,490) 
} 

tab_index_array := [] 

在腳本中,我調用一個函數來建表再往下這看起來很直截了當,但是,當我試圖訪問這個表時,我所得到的只有空白(空)值。

ClickTab(which_tab) 
{ 
    global 

    coords_ := [] 
    tab_str := tab_index_array[which_tab] 

    stringsplit, coords_, tab_str, "," 

    x_ := coords_[1] 
    y_ := coords_[2] 

    SplashTextOn,,, %x_% "`n" %y_% 
    SetTimer, KillSplashText, -5000 

    ;SetMouseDelay, slow_click_wait_time 
    ;SendEvent {click, %x_%, %y_%} 
    ;SetMouseDelay, click_wait_time 
} 

我在做什麼錯?我想要做的就是從數組中獲取座標並將它們提供給SendEvent命令。任何幫助你可以給予將不勝感激,因爲我已經打了一段時間了。

感謝,

回答

1

既然你想爲一個字符串存儲在每個tab_index_array的領域,你需要把它放在引號,像

tab_index_array.Push("332,490") 

函數調用和定義,其中包括if().push(),strLen()等等,就像其他編程語言中的函數一樣工作。您只能在大多數AutoHotkey命令中留下引號,這些命令有時很舒服但很混亂。

更多相關信息,請參閱http://ahkscript.org/docs/Variables.htm