Jump to content

Confused with pixel search


dre111
 Share

Recommended Posts

hey im trying to make a script that sends numpad3 every like half a second, while searching for a yellow color, and when it gets this yellow color in the certain area, itll stop. i can make it send the numpad3 and stuff, but im a little sketchy with the do until and pixelsearch functions, any1 wanna help a newb out?

Link to comment
Share on other sites

hey im trying to make a script that sends numpad3 every like half a second, while searching for a yellow color, and when it gets this yellow color in the certain area, itll stop. i can make it send the numpad3 and stuff, but im a little sketchy with the do until and pixelsearch functions, any1 wanna help a newb out?

always glad to help. welcome to the forums. what do you have already?
Link to comment
Share on other sites

i have really little done, and im completely stumped cause this is my first/second time doing something like this. (i know im a really big newb :P )

HotKeySet("{ESC}", "Terminate")

;;;;;
Do
    Sleep("500")
    Send("{NUMPAD3}")
Until ***CONFUSED HERE***
;;;;;;;;

Func Terminate()
       Exit 0
EndFunc

i need to know what to use, i need it to keep hitting numpad3 and then when it detects this yellow color, then itll stop, and i can make it send the numpad3, but im so confused with the do until and if i am even supposed to use this, sorry for being so bad. lol

Edited by dre111
Link to comment
Share on other sites

  • Moderators

HotKeySet("{ESC}", "Terminate")
Dim $Topx = 0
Dim $Topy = 0
Dim $Bottomx = 300
Dim $Bottomy = 200
Dim $Color = 0xFFFF00
;;;;;
Do
    $Pix = PixelSearch($Topx, $Topy, $Bottomx, $Bottomy, $Color)
    Sleep("500")
    Send("{NUMPAD3}")
Until $Pix <> 1
;;;;;;;;

Func Terminate()
       Exit 0
EndFunc

Edit:

['/code] would have been nice for me!! :P

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

How about this-

$send = 1
Local $Pix1 = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0xE0ECE8, 10)
While 1
if $send = 1
    Send("{Num1}")
Sleep(500)
endif
If $Pix1 <> 1  Then
    If IsArray($Pix1) Then 
$send = 0
 Else

    endif
Wend

It's slopy, but hopefully helpful.

Edited by =sinister=
Link to comment
Share on other sites

i entered it correctly, it runs with no errors, but its not detecting the color when it passes by, heres my code

HotKeySet("{ESC}", "Terminate")
Dim $Topx = 440
Dim $Topy = 297
Dim $Bottomx = 496
Dim $Bottomy = 317
Dim $Color = 0xDAB966
;;;;;
Do
    $Pix = PixelSearch($Topx, $Topy, $Bottomx, $Bottomy, $Color)
    Sleep("500")
    Send("{NUMPAD3}")
Until $Pix <> 1
;;;;;;;;

Func Terminate()
       Exit 0
EndFunc

EDIT: i didnt see urs sinister, lemme try that.

i used toe window information thing but it still isnt finding it, ill try to fix it

Edited by dre111
Link to comment
Share on other sites

uh, the color is correct in my script. Your on your own there. sry. BUT, I have a script that can get the color. I need to fix it, so when it's fixed, I will post it.

**edit**

There was an error in my script, edited and fixed. So if theres in error, try recopying it.

Edited by =sinister=
Link to comment
Share on other sites

  • Moderators

i entered it correctly, it runs with no errors, but its not detecting the color when it passes by, heres my code

HotKeySet("{ESC}", "Terminate")
Dim $Topx = 440
Dim $Topy = 297
Dim $Bottomx = 496
Dim $Bottomy = 317
Dim $Color = 0xDAB966
;;;;;
Do
    $Pix = PixelSearch($Topx, $Topy, $Bottomx, $Bottomy, $Color)
    Sleep("500")
    Send("{NUMPAD3}")
Until $Pix <> 1
;;;;;;;;

Func Terminate()
       Exit 0
EndFunc

EDIT: i didnt see urs sinister, lemme try that.

i used toe window information thing but it still isnt finding it, ill try to fix it

I thought you might run into a problem here, my apologies for not point something out.

Using AutoInfo Tool, there are 2 options you have to look at:

1. Options\Coord Mode - I generally will use Client Coords - So when using an Opt("CoordMode") option... I would set my coord paramater to 2, but window coords would be 0, and screen is default at 1.

2. Options\Color Mode - Default is RGB, make sure it is on the Default when trying to locate your colour Hex or Dec.

Opt("PixelCoordMode", 2); Step 1 above, may need to change the 2
Opt("SendKeyDelay", 1); Just incase you need to send quickly, you may want to send slower

HotKeySet("{ESC}", "Terminate")
Dim $Topx = 440
Dim $Topy = 297
Dim $Bottomx = 496
Dim $Bottomy = 317
Dim $Color = 0xDAB966
;;;;;
Do
    $Pix = PixelSearch($Topx, $Topy, $Bottomx, $Bottomy, $Color)
    Sleep("500")
    Send("{NUMPAD3}")
Until IsArray($Pix)
;;;;;;;;

Func Terminate()
       Exit 0
EndFunc

Good Luck!

@=sinister= ; you could have just showed the pixel portion, with a simple #include at the top :P

Edit:

@Larry - Wonderful idea...>> Until IsArray($Pix) --- Changed it in script above to that.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...