[AutoIt SciTe] Problem with PixelSearch command.

12/30/2017 23:32 DynamicRookie#1
Hi.

I want to make a bot that can play a game called Piano Tiles 2

But the problem is that when it gets too fast, the mouse miss the tile and touchs the border

I use the variable $DELAYED_TILE_ESTIMATE in my script

I use PixelSearch command to check if a tile is detected
If is detected a black pixel in the region of PixelSearch command,
I use MouseMove(*cords*) to move the mouse and
MouseClick to click the tile

I want to do a code after MouseMove that can "imagine" a line at the top of the mouse position and check how much pixels of that line are off the tile, after it checks for the position, move the mouse to a place where it can touch the tile and not the border.

Graphic explanation here: [Only registered and activated users can see links. Click Here To Register...]

$DELAYED_TILE_ESTIMATE is the variable that i want to assign to store the value that the imaginary red line calculated and add it to the Y coordinate
of MouseMove(*Cords*) command

Example: 50 pixels off the tile:

$_NEGATIVE_PIXELS is the amount of pixels of the red line that are off the tile

$DELAYED_TILE_ESTIMATE = $_NEGATIVE_PIXELS

then

MouseMove(*cord1*, *cord2 + $DELAYED_TILE_ESTIMATE*, *cord3*)

So after moving the mouse once, the red line will calculate, and move the mouse inside the tile so it wont miss it




Thanks a lot for reading :)
12/31/2017 01:57 elmarcia#2
Use control click instead of mousemove, u don't have the delay of simulated mousemove, also, when you search for a pixel it will always return the top left corner, since the scan goes TOP LEFT to RIGHT BOTTOM, u need some offset for the click based on tile size.
Control click won't work on bluestacks, in nox works.
12/31/2017 13:45 Moneypulation#3
You can just use MouseMove(x,y,0) as well to get rid of the delay. If you don't want to click near the borders, just use an offset as already mentioned
12/31/2017 16:33 DynamicRookie#4
Thanks a lot for our answers!

But yes, i do use MouseMove and ControlClick but it still lags when searching for pixels

The real problem is that when it gets too fast, the bot doesn't have enough time to scan and touch the tile in time, so i thought about moving the mouse to the certain position where the tile was detected and using MouseGetPos statement to check -15 Y up the mouse, and if a blue tile is detected, use MouseMove again to move the mouse inside the tile.

The code of detecting tiles is this
Func pixs()
While 1
$pix1 = PixelSearch(400, 600, 500, 600, 0x000000, 100, 1)
If IsArray("$pix1") = True Then
MouseMove(450, 600, p)
MouseClick("left")




I thought about doing this code but it doesn't work



$pos = MouseGetPos()
$negative_tiles = PixelSearch($pos[0] -15, $pos[1] -15, $pos[0] + 15, $pos[1] +15, 0x(Color blue hex code), 100, 1)
If IsArray($negative_tiles) = True Then
MouseMove($pos[0], $pos[1] + 15, 0)
MouseClick("left")
Else
MouseClick("left")
Endif
Endif
WEnd
EndFunc

Anyone knows how i could improve that code?

Thanks