Hello,
Here's code that I used and there is result. Thanks to @careca.
#include<Misc.au3>
WinActivate("[CLASS:MSPaintApp]")
Global $WPos = [5,143,823,630]
Global $dot = 0, $h = $WPos[1]
While 1
If _IsPressed('1B') Then
Exit
EndIf
For $i = 1 To 2
If $i = 1 Then
For $w = $WPos[0] + 15 To $WPos[2] Step 10
$dot = PixelSearch($w, $h, $w+10, $WPos[3], 0x000000, 0, 2)
If Not @error Then
MouseMove($dot[0], $dot[1], 5)
EndIf
Next
Else
For $w = $WPos[2] To $WPos[0] + 15 Step -10
$dot = PixelSearch($w, $h, $w-10, $WPos[3], 0x000000, 0, 2)
If Not @error Then
MouseMove($dot[0], $dot[1], 5)
EndIf
Next
EndIf
Next
WEnd
I've got another task and need a little more help ^^ . I do not want to start new thread so I will ask question here.
I have to measure the distance from one dot to another and write the result. But it couldn't be so easy, so here is a catch! If the distance from mouse cord is less than 1, do not click this dot. Look for another that is further. I have an idea, that I will show to you guys.
To calculate the distance we can use this:
Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem for 2D
Local $a, $b, $c
If $x2 = $x1 And $y2 = $y1 Then
Return 0
Else
$a = $y2 - $y1
$b = $x2 - $x1
$c = Sqrt($a * $a + $b * $B)
Return $c
EndIf
EndFunc ;==>Pixel_Distance
The credits goes to @UEZ. I did not write it.
To get the mouse cords, I can use:
MouseGetPos
Now I don't know exacly how to glue it into one. Script looks for dots and it's great. I definitly use it for finding dots, but now I have to calculate distance betwen this dots.
@Edit
Please look at this pseudocode, is my way of thinking right?
$BlackDotCord
$RedDotCord
$OrangeDotCord
;First calculate distance black to orange. So xy,x1y1 should be
$x = $BlackDotCord[0]
$y = $BlackDotCord[1]
$x1 = $OrangeDotCord[0]
$y1 = $OrangeDotCord[1]
$dist = Pixel_Distance($x,$y,$x1,$y1)
If $dist < 1 Then
MouseMove(~~?
I have to store every distance in table?