Sign in to follow this  
Followers 0
Qiman

Need help with my script please

8 posts in this topic

#1 ·  Posted (edited)

I am trying to get my gotten pixel cords to increase by X amount and loop my 'IF Then".

I have no idea how to get this to work. Here is the code I have been working on.

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit 0
EndFunc

sleep (2000)


$var1 = PixelGetColor (580, 352)
$var2 = PixelSearch (580, 352, 580, 352, $var1)
$var3 = PixelSearch (580, 352, 580, 352, $var1)
$var4 = "0, 0 "


While 1

If $var1 = $var2 Then
    If $var2 = $var3 Then
    MouseMove($var3[0], $var3[1])
    sleep(50)
    MouseMove($var4[0], $var4[1])
EndIf
EndIf

$var1 = ($var1[0], [1]+59) 
$var2 = ($var2[0], [1]+59) 
$var3 = ($var3[0], [1]+59) 
$var4 = ($var4[0], [1]+59) 

WEnd

Thanks in advance.

Edited by Qiman

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

These are not valid ways to set array values:

$var4 = "0, 0 "

; ...

$var1 = ($var1[0], [1]+59)
$var2 = ($var2[0], [1]+59)
$var3 = ($var3[0], [1]+59)
$var4 = ($var4[0], [1]+59)

The PixelSearche() for $var2 and $var3 are the same, so why two?

And, these array compares are invalid. If you try to treat an entire array as a string you get "", and as a number you get 0. So the following code is just "If $var1 = 0" and "If 0 = 0 Then":

If $var1 = $var2 Then
    If $var2 = $var3 Then

      ; ...

    EndIf
EndIf

It's hard to tell from the fractured logic what you want to do. Incrementing the pixel coord is the easy part:

$iColor = PixelGetColor (580, 352)
$avPos1 = PixelSearch (580, 352, 580, 352, $iColor)

$iOffset = 0
While 1
    MouseMove($avPos1[0], $avPos1[1] + $iOffset)
    $iOffset += 59
    sleep(50)
WEnd

Think it through more carefully. Once you can accurately say what you want, you'll be able to accurately code it.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you agian. I need help with this one part of my script.

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit 0
EndFunc

sleep (2000)


$iColor = PixelGetColor (580, 295)
$avPos1 = PixelSearch (580, 352, 580, 352, $iColor)
$avPos3 = PixelSearch (580, 409, 580, 409, $iColor, 255)

IF not @error Then
$avPos2 = PixelSearch (637, 409, 637, 409, $iColor)

IF not @error Then
    MouseMove($avPos2[0], $avPos2[1])
    MouseDown ("Left")
    sleep (50)
    MouseMove($avPos3[0], $avPos3[1])
    MouseUp ("Left")
    EndIf
EndIf

   ;<~~~This is where I need help. I want to repeat the pixel matching as above, but I want the cords of the pixels
   ;that are matched to increase every time. ie. PixelGetColor here(xxx,xxx) and PixelSearch here (xxx,xxx), Check If @ error.
   ;Then, PixelGetColor here(xxx,xxx +59) and PixelSearch here (xxx,xxx +59), Check If @ error. Then, continue the matching while adding
   ;(xxx,xxx +59) every time.


$iOffset = 0
While 1

    MouseMove($avPos1[0], $avPos1[1] + $iOffset)
    $iOffset += 59
    MouseDown ("Left")
    sleep (50)
    MouseMove($avPos1[0], $avPos1[1] + $iOffset)
    $iOffset += 59
    MouseUp ("Left")
    sleep (50)


WEnd

I have tried differnt ways to try to loop If @error, while increasing the cords each time, but I always get error messges.

Please help.

Edited by Qiman

Share this post


Link to post
Share on other sites

well if you want the pixel matching to be repeated then you need to have the pixel matching in the while loop.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

well if you want the pixel matching to be repeated then you need to have the pixel matching in the while loop.

But then it will just repeat the the color matching on the original colors. I want the the cords of the PixelGetColor and PixelSearch to change after the clicks.

ie. Searches for pixels matches here (xxx, xxx) then It will start over, but search for pixel matches here (xxx, xxx +59), and continue to add (xxx, xxx +59) each time.

Edited by Qiman

Share this post


Link to post
Share on other sites

make the pixel search cord variables and add to the variable every time like you have with mouse move.

Share this post


Link to post
Share on other sites

make the pixel search cord variables and add to the variable every time like you have with mouse move.

How do I do that? Can you please give an example?

Thank you.

Share this post


Link to post
Share on other sites

Well im not totally sure wat you are trying to do. But to make the cords of the pixel search shift 59 pixels every time:

While 1
Pixelsearch ($var[0], $var[1], $var[2], $var[3], color)
If @error then exitloop
$var[1] = $var[1] + 59
$var[3] = $var[3] + 59
Wend

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0