AutoHotKey:访问坐标数组

AutoHotKey: Accessing an array of coordinates

在 AutoHotKey 中,我将全局数组定义为:

tab_index_array := []

在脚本的更下方,我调用了一个函数来构建 table:

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)
}

这对我来说似乎很简单,但是,当我尝试访问此 table 时,我得到的只是空白(空)值。

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 命令。您能提供的任何帮助将不胜感激,因为我已经为此奋斗了一段时间。

谢谢,

由于要在tab_index_array的每个字段中存储一个字符串,所以需要将其放在引号中,如

tab_index_array.Push("332,490")

函数调用和定义,包括 if().push()strLen() 等,其工作方式也与其他编程语言中的函数一样。您只能在大多数 AutoHotkey 命令中保留引号,这很舒服但有时会造成混淆。

更多信息也可以在 http://ahkscript.org/docs/Variables.htm

找到