Jump to content

MouseMove / PixelSearch


Recommended Posts

Hi guys,

I'm new here... Total n00b to AutoIt and I've decided to post on the forums as a last resort!

Anyway, straight to the 'problem'...

Here is my code:

#include <GUIConstants.au3>

Opt("GUICloseOnESC", 1)

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("._.", 105, 73, 193, 115)

$Button1 = GUICtrlCreateButton("Begin", 8, 8, 89, 57, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

case $Button1

winactivate("????","")

DO

$go = PixelSearch (130,145,640,480,0xB0C047)

MouseMove ($go[0],$go[1],2)

mouseclick("left")

UNTIL

case $GUI_EVENT_CLOSE

EndSwitch

wend

Yes, very n00berish indeed ;)

ANYWAY, what I'm TRYING to do is this:

1. When the user clicks 'Begin', the specified window is scanned for said colour.

2. The mouse is moved to the x and y location of the found colour!

3. The mouse click is sent!

4. The app waits a few seconds and repeats the process, scanning for new occurences of the colour until a user defined loop amount is reached!

If ANYONE can show me how to do this, I will be eternally greatful! :evil:

Thanks alot in advance! :lmao:

Link to comment
Share on other sites

Here is something to get your started...

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

HotKeySet("{F8}", "CloseApp")

$Form1 = GUICreate("._.", 105, 73, 193, 115)
$Button1 = GUICtrlCreateButton("Begin", 8, 8, 89, 57, 0)
GUISetState()

GUISetOnEvent(-3, "CloseApp")
GUICtrlSetOnEvent($Button1, "PixelLocate")

While 1
    Sleep(100)
WEnd

Func PixelLocate()
    GUIDelete()
    While 1
        WinActivate("????", "")
        $go = PixelSearch (130, 145, 640, 480, 0xB0C047)
        If IsArray($go) Then
            MouseClick("left", $go[0], $go[1])
            Sleep(2000)
        Else
            MsgBox(0, "No pixels found", "No pixels were found in the searched area")
            Sleep(2000)
        EndIf
    WEnd
EndFunc ;==> PixelLocate

Func CloseApp()
    Exit
EndFunc
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...