adijian Posted October 16, 2020 Share Posted October 16, 2020 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? expandcollapse popup#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 More sharing options...
Danp2 Posted October 16, 2020 Share Posted October 16, 2020 You would need to change your AskUser function so that the parameters are passed by reference (add byRef to each one). Otherwise, the variables are local and don't get passed back to the calling routine. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
adijian Posted October 16, 2020 Author Share Posted October 16, 2020 Thanks a lot! Works like a charm! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now