Jump to content

Ask user for coordinates and wait for them to appear


adijian
 Share

Recommended Posts

Hi,

I'm developing an automation for my military base's program and I was wondering why does Autoit stop the Pixel() loop right after it's done?

Do the AskUser() coordinates get overruled?

#include <Array.au3>
#include <Misc.au3>
HotKeySet ("{F2}","myExit")

Global $win=WinList("Operation")

;functions control click
$left = "left"
$right = "right"
Global $minute=60000
GLOBAL $keyr=(Random(1,3))

func myExit()
    Exit
EndFunc

Func Click($coordx,$coordy)
    WinActivate($win[1][1])
    MouseMove(Random($coordx,$coordx+4),Random($coordy,$coordy+4))
    ControlClick($win[1][1],"","[CLASS:Canvas; INSTANCE:3]","",$keyr,Random($coordx,$coordx+4),Random($coordy,$coordy+4))
EndFunc

Func SendK($key)
    ControlSend($win[1][1],"","[CLASS:Canvas; INSTANCE:3]",$key)
EndFunc

Func Zzz ($random)
    Sleep(Random($random,$random+1000))
EndFunc

Func AskUser($Coords,$Color)
    MsgBox(0, "Coordinates", "Press OK and then move your mouse to coordinates and press TAB")
    Do
        Sleep(50)
    Until _IsPressed(09)
    $Coords = MouseGetPos()
    $Color = PixelGetColor($Coords[0], $Coords[1])

    MsgBox(0, "Info!", "Your coords and color have been stored for later use")
    Return $Coords
EndFunc   ;==>AskUser

Global $pixel
Global $Color
Global $Coords
Global $Color1
Global $Coords1
Global $Color2
Global $Coords2
Global $Color3
Global $Coords3

Func Pixel ($Coords, $Color)
    Click($Coords[0], $Coords[1])
        Do
            PixelSearch($Coords[0], $Coords[1],$Coords[0], $Coords[1],$Color)
        Until NOT @error
EndFunc
    
AskUser($Coords1,$Color1)
AskUser($Coords2,$Color2)
Local $i = 0
While $i <= 10
Pixel($Coords1, $Color1)
Pixel($Coords2, $Color2)
;~ Pixel(373, 775,$Color3)
WEnd

Thanks,

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