Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
How to spread a variable in AutoHotkey?

In JavaScript, we use the spread operator to spread an array of items, e.g.

const arr = [1, 2, 3]

console.log(...arr) // 1 2 3

And I want to achieve a similar effect in AHK:

Position := [A_ScreenWidth / 2, A_ScreenHeight]

MouseMove Position ; ๐Ÿ‘ˆ how to spread it?
about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

AFAIK, there's no spread syntax in AHK, but there are some alternatives:

For big arrays you can use:

position := [A_ScreenWidth / 2, A_ScreenHeight]
Loop,% position.Count()
    MsgBox % position[A_Index] ; show a message box with the content of any value

or

position := [A_ScreenWidth / 2, A_ScreenHeight]
For index, value in position
    MsgBox % value ; show a message box with the content of any value

In your example, can be:

position := [A_ScreenWidth / 2, A_ScreenHeight]
MouseMove, position[1], position[2]

This will move your mouse to the bottom middle of your screen.

To avoid decimals, you may use Floor(), Round(), Ceil() functions for example, like:

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
about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!