Random mouse clicks at random position

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Brunoire
Posts: 34
Joined: 25 Jun 2017, 16:44

Random mouse clicks at random position

27 Jun 2017, 06:07

I am trying to add random mouse clicks at random positions to my script.

I have been testing with windows spy and paint but some of them click outside the box, when I want the clickcs to be inside the box.

Code: Select all

F12::
ExitApp

^t::

IfWinExist, box - Paint
    WinActivate
else
    WinActivate, Nothing
Loop 1000
{
MouseClick, left, % Rand(217, 593), % Rand(448, 691)

}


randsleep(min, max) {
    sleep % rand(min, max)
}

rand(min, max) {
    Random, rand, % min, % max
    return rand
}
Brunoire
Posts: 34
Joined: 25 Jun 2017, 16:44

Re: Random mouse clicks at random position

27 Jun 2017, 07:02

CoorMode did nothing.

Something is wrong with the coordinates or maybe I am doing them wrong because the box the clicks are "drawing" is way bigger than the box in the paint.

The way I am checking the coordinates 217, 593 are from top left corner of the box and 448, 691 are from bottom right corner.

Probably is my fault because I have no idea how to check them...
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Random mouse clicks at random position

27 Jun 2017, 07:11

Use ControlGetPos and use an offset of the returned coordiantes for your mouse-events.
Brunoire
Posts: 34
Joined: 25 Jun 2017, 16:44

Re: Random mouse clicks at random position

27 Jun 2017, 14:59

Can you give a small example?
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Random mouse clicks at random position

27 Jun 2017, 15:46

Which Mouse Position Coords are you using from the Active Window Tool?

Absolute: 1923, 710 (less often used)
Relative: 320, 636 (default)
Client: 320, 636 (recommended)

This will determine how CoordMode should be set.

Example:

Code: Select all

CoordMode, Mouse, Screen    ; Absolute Coords
Brunoire
Posts: 34
Joined: 25 Jun 2017, 16:44

Re: Random mouse clicks at random position

27 Jun 2017, 17:01

I used client for mouse position coords.

Edit:

I used the mouse position coords of the rectangle but when I start the script is clicking outside of the rectangle as you can see on the image below.
Image
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Random mouse clicks at random position

27 Jun 2017, 18:14

Put this at the top of your script:

Code: Select all


CoordMode, Mouse, Client
And then try your script again.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, gsxr1300, HiSoKa and 273 guests