I need help with pixel search and mouse click.

06/07/2013 11:58 alex05ok#1
Code:
#region HotKeySet
HotKeySet("{F4}","PIXELREAD")
HotKeySet("{F2}","PIXELFIND")
HotKeySet("{f3}","ExitProg")
#ENDREGION

#region variables
dim $pos[2]
dim $color
Global $counter=0
Global $searchfor = 12059395
Global $on=0
#ENDREGION

Func ExitProg()
   Exit
EndFunc
   
#region Functions
Func PIXELREAD()
   $pos = MouseGetPos()
   $color = PixelGetColor($pos[0],$pos[1])
   MsgBox(0,"Color",$color&@CRLF&$pos[0]&","&$pos[1])
EndFunc

Func PIXELFIND()
   $on=1
   While $on=1
	  $pos = PixelSearch(133,231,1155,936,$searchfor)
	  if not @error Then
		 MouseMove($pos[0],$pos[1],0)
		 Sleep(500)
		 MouseClick("left")
	  EndIf
	  If @error Then
		 $counter=$counter+1
	  EndIf
	  if $counter>5 Then
		 $on=0
	  EndIf
   WEnd
   MouseUp("left")
   MsgBox(0,"It's Colored","We colored it.")
EndFunc

#ENDREGION

While 1
   Sleep(100)
WEnd
when i press F2 it search for pixel color and left click on it. Works fine.

I want to search pixels in a small area in the center of the screen (200 x 200 px)
If no pixel find then make area larger and larger until pixel is find and left click on it,
then sleep 4 sec and make area small again instant (200 x 200 px)

thank you

how to make to search from center of the screen?
06/07/2013 16:01 Croco™#2
Code:
$Area = 200								
$X		=	@DesktopWidth/2-$Area/2	
$Y		=	@DesktopHeight/2-$Area/2
$ToX	        =	@DesktopWidth/2+$Area/2
$ToY	        =	@DesktopHeight/2+$Area/2
With this code you get the 4 cords you need for PixelSearch.
Now you can increase or decrease $Area each loop.
06/07/2013 16:25 alex05ok#3
Quote:
Originally Posted by Croco™ View Post
Code:
$Area = 200								
$X		=	@DesktopWidth/2-$Area/2	
$Y		=	@DesktopHeight/2-$Area/2
$ToX	        =	@DesktopWidth/2+$Area/2
$ToY	        =	@DesktopHeight/2+$Area/2
With this code you get the 4 cords you need for PixelSearch.
Now you can increase or decrease $Area each loop.
pls tell me were do i put this in my code.
06/07/2013 16:54 omer36#4
Quote:
Originally Posted by alex05ok View Post
pls tell me were do i put this in my code.
...-.-

PHP Code:

Func PIXELFIND
()
    
$on 1
    $Area 
200

    
While $on 1
        $X 
= @DesktopWidth $Area 2
        $Y 
= @DesktopHeight $Area 2
        $ToX 
= @DesktopWidth $Area 2
        $ToY 
= @DesktopHeight $Area 2

        $pos 
PixelSearch($X$Y$ToX$ToY$searchfor)
        If 
Not @error Then
            MouseMove
($pos[0], $pos[1], 0)
            
Sleep(500)
            
MouseClick("left")
            
Sleep(4000)
            
$Area 200
        
EndIf
        If @
error Then
            $counter 
$counter 1
            $Area 
= +200
        
EndIf
        If 
$counter 5 Then
            $on 
0
        
EndIf
    
WEnd
    MouseUp
("left")
    
MsgBox(0"It's Colored""We colored it.")
EndFunc 
06/07/2013 17:26 alex05ok#5
$Area = +200
should be
$Area += 200 ?
06/07/2013 17:31 Shishidump#6
if its not work then
$Area = $Area + 200