Jump to content

I need help with pixel search and mouse click.


Recommended Posts

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

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

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

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

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

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

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.

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

Au3Record.exe

Link to comment
Share on other sites

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

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

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

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...