LisHawj Posted May 4, 2016 Posted May 4, 2016 I wrote an image search routine using the ImageSearch2015.au3 and the script by itself does work normally. However, when I call the function from a larger script it does not work. The script just seems to hang and does not move the mouse cursor to the update button on screen. I have spent 2 hours banging my head and cannot seem to figure out why it's not working. Your assistance is greatly appreciated and thank you. Standalone imagesearch function(working): ; Script Start - Add your code below here #include <imagesearch2015.au3> HotKeySet("{End}", "Stop") HotKeySet("{Home}", "Start") While 1 Sleep(1000) WEnd Func Start() $x1 = 0 $y1 = 0 $image = "C:\Reports\addnotes.png" _ImageSearch($image, 1, $x1, $y1, 0, 0) MouseMove($x1, $y1, 1) Sleep(2000) MouseClick("Left") MsgBox(0, "", "Found update button!") Call("stop") EndFunc ;==>Start Func stop() Exit EndFunc ;==>stop Section of a larger script calling the Imagesearch function (not working): Func Run_Cases() RunAsWait("username", "domain", "password", $RUN_LOGON_NOPROFILE, $sCases_Website & $sTicket) WinWaitActive("Case Management System - Internet Explorer") WinActivate("Case Management System - Internet Explorer") WinSetState("Case Management System - Internet Explorer", "", @SW_MAXIMIZE) $x1 = 0 $y1 = 0 $picture = "C:\Reports\addnotes.png" _ImageSearch($picture, 1, $x1, $y1, 0, 0) MouseMove($x1, $y1, 1) Sleep(2000) MouseClick("Left") MsgBox(0, "", "Found update button") Call("stop") EndFunc ;==>Run_Cases
AutoBert Posted May 4, 2016 Posted May 4, 2016 Your program makes what you told him to do: Quote RunAsWait Runs an external program under the context of a different user and pauses script execution until the program finishes. after external program is finished, script will waiting for the Case Management System -Internet Explorer window.
LisHawj Posted May 5, 2016 Author Posted May 5, 2016 Thanks for alerting me to the "RunasWait" command. I corrected that and the script proceeds to completion, but I am still unable to successfully perform an image search, but the same exact image search codes as a standalone search works. I am at a lost here so any additional advice is much appreciated. Below is the full section of the script and maybe it will help to determine where I am screwing up. Thanks in advance. expandcollapse popupFunc Run_Cases() AutoItSetOption("Mousecoordmode", 0) $sTicket = GUICtrlRead($sTicket_number) ;Open Cases Management System RunAs($sUsername, $sDomain, $sPassword, $RUN_LOGON_NOPROFILE, $sCases_Website & $sTicket) WinWaitActive("Case Management - Ticket Detail - Internet Explorer") Sleep(100) WinActivate("Case Management - Ticket Detail - Internet Explorer") Sleep(100) WinSetState("Case Management - Ticket Detail - Internet Explorer", "", @SW_SHOWNORMAL) Sleep(100) WinMove("Case Management - Ticket Detail - Internet Explorer", "", 0, 0) Sleep(100) WinSetState("Case Management - Ticket Detail - Internet Explorer", "", @SW_MAXIMIZE) Sleep(100) MsgBox(0, "", "Click the Add Activity button in your opened ticket to continue.") ;Start Image Search routine MouseClick("LEft", 30, 169) While 1 $x1 = "" $y1 = "" $picture = "C:\Reports\addnotes.png" $hFind_Button = _ImageSearch($picture, 1, $x1, $y1, 0, 0) If $hFind_Button <> $picture Then MouseWheel($MOUSE_WHEEL_DOWN, 15) Sleep(2000) ElseIf $hFind_Button = $picture Then MsgBox(0, "X and Y coords", $x1 & " , " & $y1); debug msgbox to show x and y coords if button is found. MouseMove($x1, $y1, 1) Sleep(2000) MouseClick("LEFT") EndIf WEnd ; End Image Search routine ;Waiting for user input to Add Activity notes WinWaitActive(" -- Webpage Dialog") WinActivate(" -- Webpage Dialog") BlockInput(1);Prevent user interaction until update is completed! Sleep(500) MouseClick("left", 397, 114, 1) Sleep(500) Send("{DOWN 3}{ENTER}") Sleep(5000) WinActivate(" -- Webpage Dialog") MouseClick("left", 397, 170, 4) ;Read terminal and copy security details $Terminal_Data = GUICtrlRead($sTerminal) & @CRLF $Header1 = ("Result for security check:") $EndPoint_Data = FileRead($sPCCHECK_log) GUICtrlSetData($sTerminal, $Terminal_Data & $Header1 & $EndPoint_Data & @CRLF) ClipPut($EndPoint_Data) Sleep(1000) Send("^v") ;End terminal and copy security details ;MouseClick("Left", 546,75, 1) MouseMove(546, 75, 1) BlockInput(0) EndFunc ;==>Run_Cases
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