En JavaScript, usamos el operador de propagación para distribuir una serie de elementos, por ejemplo
const arr = [1, 2, 3] console.log(...arr) // 1 2 3Y quiero lograr un efecto similar en AHK:
Position := [A_ScreenWidth / 2, A_ScreenHeight] MouseMove Position ; 👈 how to spread it?AFAIK, no hay sintaxis extendida en AHK, pero hay algunas alternativas:
Para arreglos grandes puedes usar:
position := [A_ScreenWidth / 2, A_ScreenHeight] Loop,% position.Count() MsgBox % position[A_Index] ; show a message box with the content of any valueo
position := [A_ScreenWidth / 2, A_ScreenHeight] For index, value in position MsgBox % value ; show a message box with the content of any valueEn tu ejemplo, puede ser:
position := [A_ScreenWidth / 2, A_ScreenHeight] MouseMove, position[1], position[2]Esto moverá el mouse a la mitad inferior de la pantalla.
Para evitar decimales, puede usar las funciones Floor() , Round() , Ceil() por ejemplo, como:
position := [ Floor( A_ScreenWidth / 2 ), Round( A_ScreenHeight ) ] Loop,% position.Count() MsgBox % position[A_Index] ; show a message box with the content of any value