Sign in to follow this  
Followers 0
EwfwrTtrr

I need help with pixel search and mouse click.

14 posts in this topic

I have this script:

#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)
         MouseDown("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

Share this post


Link to post
Share on other sites



I would grab the screen size, and then would increase the coords to search in percentage, each time pixelsearch gives out an error.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

how to make pixel search to start from center?

Share this post


Link to post
Share on other sites

is center a must be ?

$w = 0

$h = 0

start from top left ($w, $h) and every time you get an error $w+1, $h+1

Share this post


Link to post
Share on other sites

What do you need this script for ?


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

What do you need this script for ?

school project

Share this post


Link to post
Share on other sites

I won't pick on you with my questions. I let the mods decide about your topic.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I think what FireFox is getting at is, what is the name of the application you're trying to manipulate - or how about a more detailed description of what you're trying to accomplish? 90% of the time there is an easier way to do what you want without having to resort to things like pixelsearch.


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

Share this post


Link to post
Share on other sites

It is the same program like this 

Share this post


Link to post
Share on other sites

You are not answering JLogan3o13's question (about the program you're trying to manipulate).

I hoped that this video was dated, but it's not (2013) and he's still using the Dim keyword and some other bad stuff. Ewwww.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
$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 I get the 4 cords I need for PixelSearch.

Now I can increase or decrease $Area each loop.
 
Can someone help me introducing this in my code?

Share this post


Link to post
Share on other sites

Something like this I think

While $on=1
      $pos = PixelSearch($x,$y,$tox,$toy,$searchfor)
      if not @error Then
         MouseMove($pos[0],$pos[1],0)
         Sleep(500)
         MouseDown("left")
     ElseIf @error Then
         $x = $x - $area
         $y = $y - $area
         $tox = $tox + $area
         $toy = $toy + $area
         $counter=$counter+1
      EndIf
      if $counter>5 Then
         $on=0
      EndIf
   WEnd

But don't forget to add your variables to the top of the script


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Func PIXELFIND() 
    $on = 1 
    $Area = 200 

    While $on = 1 
        $X = @DesktopWidth / 2 - $Area / 2 
        $Y = @DesktopHeight / 2 - $Area / 2 
        $ToX = @DesktopWidth / 2 + $Area / 2 
        $ToY = @DesktopHeight / 2 + $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

i think this code is good too.

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