Jump to content
Sign in to follow this  
Lentil

Pixel searching

Recommended Posts

Lentil
; Find a pure lime green pixel or a green pixel within 10 shades variations of pure green
$coord = PixelSearch( 0, 0, 20, 300, 0x32CD32, 10 )
If Not @error Then
    MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf

 

I need this script modified to perform these actions

1. When the color is found, have script to begin again at a certain line

2. Get the script to pixel search every 30 seconds (if possible)

 

So It'd running part 1

line 1-100

Part 2 would be the pixel search, but I'd like the script to return to line 1 once the color is found

I'm sorry if this has been asked before.  I'm trying to figure it out myself, but I'm having a hard time piecing everything together.

Much appreciated.

Share this post


Link to post
Share on other sites
MouseSpotter

Something like:

While true

DoSearch()

wend

Func DoSearch()

local $coord = PixelSearch( 0, 0, 20, 300, 0x32CD32, 10 )

If Not @error Then
    MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf

EndFunc

Share this post


Link to post
Share on other sites
Divine

EDIT: It automatically makes the variable an array if it isn't so, that's why you are getting an error. Just fixing up MouseSpotter's code ^_^

 
While true
Call("DoSearch")
WEnd
 
Func DoSearch()
Local $Coord = PixelSearch(0,0,20,300,0x32CD32,10)
If IsArray($Coord) = True Then
     MsgBox(0,"X and Y are", $Coord[0] & "," & $Coord1)
EndIf
EndFunc
 
Edited by Divine

Share this post


Link to post
Share on other sites
MouseSpotter

Not so fast Oh mighty Divine.

All I did was wrap a function around Lentil's code - which works fine and checks the @error code (a better option than checking for an array IMHO).

BTW The Call statement is not required - I only use it for calling functions when I do not know if the function exists or not.

While True
    DoSearch()
WEnd

Func DoSearch()
    Local $coord = PixelSearch(0, 0, 20, 300, 0x32CD32, 10)
    If Not @error Then
        MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
    EndIf
EndFunc

Share this post


Link to post
Share on other sites
Divine

 

Not so fast Oh mighty Divine.

All I did was wrap a function around Lentil's code - which works fine and checks the @error code (a better option than checking for an array IMHO).

BTW The Call statement is not required - I only use it for calling functions when I do not know if the function exists or not.

While True
    DoSearch()
WEnd

Func DoSearch()
    Local $coord = PixelSearch(0, 0, 20, 300, 0x32CD32, 10)
    If Not @error Then
        MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
    EndIf
EndFunc

Very true, but I grew into the habit of Calling my function, looks better :>

Anyway, to answer your question, I recommend creating two functions, one to part one, and another is part two.

 
Func PART_ONE()
; Blah Blah Blah
EndFunc
 
Func PART_TWO() ;Aka DoSearch
; Blah Blah Blah, PixelSearch here. If you want the PixelSearch to keep repeating after 30 seconds, just put it
; in a separate function, slap a 30 second sleep on there, and call it here. I.E:
_PixelSearch()
EndFunc
 
Func _PixelSearch()
Sleep(30000) ; 30 second sleep!
Local $coord = PixelSearch(0, 0, 20, 300, 0x32CD32, 10)
    If Not @error Then
        MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
    Else
        MsgBox(0,"Error","Couldn't find the requested Pixel, :(.")
    EndIf
EndFunc
Edited by Divine

Share this post


Link to post
Share on other sites
Lentil

Global $Paused, $counter = 0
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{delete}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

While 1
sleep(2000)
SEND("{k}")
sleep(1050)
MouseMove ( 486, 468)
sleep(350)
MouseClick("left")
sleep(250)
SEND("{esc}")
sleep(250)
SEND("{v}")
sleep(5000)
SEND("{v}")
;;
;;
;;
;;
;;
MouseMove ( 825, 660)
sleep(550)
MouseClick("left")
sleep(20550)
MouseMove (62, 42)
MouseClick("right")
MouseMove (100, 90)
MouseClick("left")
sleep(5550)
MouseClick("left")
sleep(1550)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0, $counter, 1)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

So this is what I'm using atm...I tried throwing it together with yours devine.  I can't seem to get it to work.

Sorry I'm really new at this...can you try to merge yours and mine and get part 1 to reset when the color is found?

Also do I just throw the x n y coords of the color in there?  or is it better to search an area?  because the color I want to search for is about this size =============

Share this post


Link to post
Share on other sites
JLogan3o13

Lentil, what application are you trying to manipulate? Judging by your code, there is probably a much easier way to do what you want to accomplish, without all of the MouseClicks, etc.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

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  

×