BatMan22 Posted January 17, 2020 Share Posted January 17, 2020 (edited) Hey guys, so my main program that assists with all my work is missing one thing, I want it to automatically log me in when a logon window appears. The WinExists loop works great seperately, but if possible I would like it to be part of my existing program.. Is this possible without re-writing massive amounts of the work that I've done? Help I included just the gui portion of the program below, the bulk of the code is in a seperate file with all the functions. expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Crome Icons\Google Black.ico #AutoIt3Wrapper_Res_Fileversion=0.0.0.460 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #AutoIt3Wrapper_Run_Stop_OnError=y #AutoIt3Wrapper_Run_Tidy=y ;~ #Tidy_Parameters=/kv 0 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/rm /rsln /pe /sf /sv /tl #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ #Au3Stripper_Parameters=/MO /RSLN ; Put me BACK IN IF YOU ARE HAVING STRIPPER ISSUES! #include "SingleScript.au3" _SingleScript(0) Global $analytical, $cD = 0 Global $program = "M O_Me - [onnection=Yes;APP=Microsoft Offi]" Global $tcb = 0 Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Global $g_hListView, $chosenone Global $sIDBP[1] = ["SampleID's"] Global $chosen = 0 Global $vRemoteDir = "\\ASH-DEV\Public\MacroShare\" ;Remote Directory for saving of Loader Files Global $vRemoteDirUpOne = "\\ASH-DEV\Public\" Global $TestCodesForPrepBatch[21] = ["", "PR300.0_S", "PR218.6_W", "PR218.6_DW", "PRCr6LL_TTLC", "PR314_W", "PRSULFITE300_W", "PR300.1SPE_W", "PR218.7_W", "PR300.1LL_W", "PRCR6_N7605", "PRSulfite300_S", "PRORGANICACID_IC_W", "PR300.0_Wipe", "PRCr6_TTLCWipe", "PR218.6_DISTLC", "PR300.1_DISTLC", "PR546", "PR314_S", "PR218.6_DISPLP", "PR218.6_DITCLP"] Global $WhichMachine = "0" ; Assign Dummy Value Global $sFileName = $vRemoteDir & "IC3.txt" ; FileToWorkOn Global $Verbose = 0 #include "UIAWrappers.au3" #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <ButtonConstants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Clipboard.au3> #include <ComboConstants.au3> #include "SampleDueLoaderFunctionsv2.2.au3" #include "SendEx.au3" #include "ExcelQuanterv3.au3" ; For Testing Duplicate Deleter #include "CUIAutomation2.au3" #include <GuiImageList.au3> #include <GuiListView.au3> #include <Misc.au3> #include <StringConstants.au3> #include <TrayConstants.au3> ; Required For the $TRAY_EVENT_PRIMARYDOUBLE, $TRAY_EVENT_SECONDARYUP And $TRAY_ICONSTATE_SHOW constants. #include "ImageSearch.au3" #include <GDIPlus.au3> #include <Date.au3> #include <WinAPI.au3> #include "Parser.au3" Global $oGlobalCOMErrorHandler = ObjEvent("AutoIt.Error", "_ErrFuncGlobal") ; Global COM error handler HotKeySet("+!r", "_restart") ; Restart Func EmergencyCrash() Exit EndFunc ;==>EmergencyCrash Func _restart() If @Compiled = 1 Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==>_restart Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Func TrayEvent() Switch @TRAY_ID ; Check the last tray item identifier. Case $TRAY_EVENT_PRIMARYDOUBLE WinActivate("OHelper") Case $TRAY_EVENT_PRIMARYUP WinActivate("OHelper") Case $TRAY_EVENT_SECONDARYUP WinActivate("OHelper") EndSwitch EndFunc ;==>TrayEvent TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TrayEvent") TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. Func ExitScript() Exit EndFunc ;==>ExitScript #Region ### START Koda GUI section ### Form=c:\users\ash\documents\sampleduesheetexports\Ohelper.kxf $vRemoteDirorm1_1 = GUICreate("OHelper", 221, 382, 200, 124) Local $menuELISA = GUICtrlCreateMenu("&Elisa") Local $MakeMeANewElisaBatch = GUICtrlCreateMenuItem("Make a Elisa 546 Batch For Me", $menuELISA) Local $vRemoteDirixElisaBatchForMe = GUICtrlCreateMenuItem("Fix Elisa 546 Batch For Me", $menuELISA) Local $ClipToTemplate = GUICtrlCreateMenuItem("Clipboard to ElisaMachineTemplate", $menuELISA) Local $ExcelElisa = GUICtrlCreateMenuItem("Excel Elisa Helper", $menuELISA) Local $testmenu = GUICtrlCreateMenu("&TestingMenu") Local $UseMeForTest = GUICtrlCreateMenuItem("Use Me For Testing!", $testmenu) ; Just change name Local $ClearTest = GUICtrlCreateMenuItem("Clear All My Files", $testmenu) ; Just change name $btnLoadAllFromSampleDue = GUICtrlCreateButton("Load All Samples from Due Sheet", 8, 8, 209, 41) $btnLoadFromScreen = GUICtrlCreateButton("Load From Already Open Sample Due Sheet / No Reload", 8, 58, 209, 41, $BS_MULTILINE) $Button3 = GUICtrlCreateButton("ICReportChecker!", 8, 104, 209, 41) ; Replaced by ICReporterChecker.exe $Button4 = GUICtrlCreateButton("Prep Batch Loader", 8, 152, 209, 41) $Button5 = GUICtrlCreateButton("Go to Prep Batch", 8, 232, 209, 41) $Button6 = GUICtrlCreateButton("Make New Prep Batch", 8, 280, 209, 41) $Combo1 = GUICtrlCreateCombo("PR300.1_W", 8, 200, 209, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) For $i = 1 To UBound($TestCodesForPrepBatch) - 1 GUICtrlSetData($Combo1, $TestCodesForPrepBatch[$i]) Next $Button7 = GUICtrlCreateButton("Source", 8, 328, 41, 25) $Button8 = GUICtrlCreateButton(".txt Files", 56, 328, 49, 25) $Button9 = GUICtrlCreateButton("LaunchLims", 112, 328, 49, 25) $Button10 = GUICtrlCreateButton("Kill LIMS / TEST", 168, 328, 49, 25) $pos = WinGetPos($vRemoteDirorm1_1) WinMove($vRemoteDirorm1_1, "", @DesktopWidth - $pos[2], @DesktopHeight - $pos[3] - 30) ;30 = START task/tray menu GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $UseMeForTest Case $ClearTest ClearAllMyFiles() Case $vRemoteDirixElisaBatchForMe FixElisaBatchInLIMS() WinActivate("OHelper") Case $MakeMeANewElisaBatch MakeMeANewElisaBatchInLIMS() WinActivate("OHelper") Case $ClipToTemplate ElisaPlateTemplateFixAndExport() Case $ExcelElisa MsgBox(0, 0, "replaced by FIx Eliza Macro!") Case $btnLoadAllFromSampleDue ; Load All Samples from Due Sheet ClearAllMyFiles() Isitrunning() ; First - Checks to see if LIMS is running, goes to main screen if it is. GoToSampleDueSheet() ;Second - Get to SampleDueSheet ExcelLoadAndSum() ; Load the Data From Columns One and Two and Display Both ConsoleWrite(@CRLF & "Close Crap" & @CRLF) AddAllTestCodes() ConsoleWrite(@CRLF & "Add All TestCodes" & @CRLF) Knownornot() ConsoleWrite(@CRLF & "Known Or Not" & @CRLF) Addtolistifknownfunction() ConsoleWrite(@CRLF & "Add to list if known" & @CRLF) ReplacementAndClean() ; Is this still all needed? ConsoleWrite(@CRLF & "ReplacementAndClean Finished") SortEverything() ConsoleWrite(@CRLF & "Sort") MakeWorkingCopies() TrayTip("Samples Loaded", "Samples Loaded From Due Sheet!", 5) WinActivate("OHelper") ;~ ParseAllfile() ;~ TrayTip("Parsing Finished!", "Parsing Finished!", 5) Case $btnLoadFromScreen ExcelLoadAndSum() ; Load the Data From Columns One and Two and Display Both ConsoleWrite(@CRLF & "Close Crap" & @CRLF) AddAllTestCodes() ConsoleWrite(@CRLF & "Add All TestCodes" & @CRLF) Knownornot() ConsoleWrite(@CRLF & "Known Or Not" & @CRLF) Addtolistifknownfunction() ConsoleWrite(@CRLF & "Add to list if known" & @CRLF) ReplacementAndClean() ; Is this still all needed? ConsoleWrite(@CRLF & "ReplacementAndClean Finished") SortEverything() ConsoleWrite(@CRLF & "Sort") MakeWorkingCopies() TrayTip("Samples Loaded", "Samples Loaded From Due Sheet!", 5) WinActivate("OHelper") Case $Button3 ; Clear My Files Run("C:\Users\Ash\Documents\SampleDueSheetExports\ICReporter3.exe") ;;NEEDS TO BE ON LOCAL PC! If @error Then Exit MsgBox(0, 0, "Couldn't launch IC3Reporter3.exe" & @error & "See Line 184 of SampleDueLoaderScript") Case $Button4 ; Prep Batch Loader TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Isitrunning() AddAllTestCodes() LoadPrepBatchOnly() SortEverything() MakeWorkingCopies() TrayTip("Prep Batch Loaded!", "Batch Loaded!", 5) WinActivate("OHelper") Case $Button5 ; Go to prep batch but don't load TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Isitrunning() $PrepBatchForMe = GUICtrlRead($Combo1) Gotopreponly($PrepBatchForMe) TrayTip("Ready to load prep batch", "Ready to load prep batch", 5) WinActivate("OHelper") Case $Button6 ; Open New Batch Removed Line 592? SortAndCompareToExisting($WhichMachine) TrayTip("toQuit", "Alt-Shift-S to exit!", 1) Isitrunning() AddAllTestCodes() $PrepBatchForMe = GUICtrlRead($Combo1) PrepBatch($PrepBatchForMe) TrayTip("New Batch Loaded!", "New Batch Loaded: " & $PrepBatchForMe, 1) LoadMyMSMSD() LoadPrepBatchOnly() SortEverything() MakeWorkingCopies() WinActivate("OHelper") Case $Button7 ; Source Code TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Run(@ComSpec & ' /c start ' & @ScriptFullPath) Run("Explorer.exe " & @ScriptDir) WinActivate("OHelper") Case $Button8 ; Text Files TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Run("Explorer.exe " & "\\ASH-DEV\Public\MacroShare") WinActivate("OHelper") Case $Button9 TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Isitrunning() WinActivate("OHelper") Case $Button10 ;For Testing Mainly. ProcessClose("MSACCESS.exe") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; Global COM error handler Func _ErrFuncGlobal($oError) ; Do anything here. MsgBox(0, 0, @ScriptName & " (" & $oError.scriptline & ") : ==> Global COM error handler - COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFuncGlobal Edited January 17, 2020 by BatMan22 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 17, 2020 Moderators Share Posted January 17, 2020 When you say "log me in when a logon window appears" are you talking to an application, a windows system, webpage, what? "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 More sharing options...
BatMan22 Posted January 18, 2020 Author Share Posted January 18, 2020 (edited) Sorry, a application, Microsoft Access 2010 (customized) to be exact. A window pops up asking for your login for your login for far too many actions (in my opinion). WinActivate/WinExist both work great and I can type in my password automatically.. but I just can't loop the above GUI with a loop for checking for the existing window (see below). While 1 ;~ AutoItSetOption("MouseCoordMode", 1) Sleep(100) If WinExists("Enter Initial") Then local $c = WinActivate("Enter Initial") WinWaitActive($c) Sleep(200) If $c = 0 then Exit MsgBox(0,0,"errpr") Local $aPos = WinGetPos("Enter Initial") If @error Then Exit MsgBox(0, 0, 0) ConsoleWrite(@CRLF & $aPos[0] & " " & $aPos[1] & " " & $aPos[2] & " " & @CRLF) MouseClick("Primary", $aPos[0] + 25, $aPos[1] + 25, 1, 1) Send("password") Send("{Enter}") EndIf WEnd Edited January 18, 2020 by BatMan22 dox'd myself :P Link to comment Share on other sites More sharing options...
gamerman2360 Posted January 18, 2020 Share Posted January 18, 2020 GUIGetMsg() returns pretty quickly. Just move your WinExists code into the while loop of your main script and use GUIGetMsg() as your Sleep(100). If you want you could put it into a Case $GUI_EVENT_NONE section but I don't think that is necessary. Another approach could be to use https://www.autoitscript.com/autoit3/docs/libfunctions/_Timer_SetTimer.htm but again: I would just copy your If and everything inside it into the while 1 loop in your main script. Link to comment Share on other sites More sharing options...
BatMan22 Posted January 21, 2020 Author Share Posted January 21, 2020 (edited) On 1/18/2020 at 12:52 AM, gamerman2360 said: GUIGetMsg() returns pretty quickly. Just move your WinExists code into the while loop of your main script and use GUIGetMsg() as your Sleep(100). If you want you could put it into a Case $GUI_EVENT_NONE section but I don't think that is necessary. Another approach could be to use https://www.autoitscript.com/autoit3/docs/libfunctions/_Timer_SetTimer.htm but again: I would just copy your If and everything inside it into the while 1 loop in your main script. Actually I did what you said, and the GUI still works perfectly, unless the Window exists, then the function is triggered but then after that, the GUI becomes completely unresponsive until restarted.. I don't know what I'm doing wrong expandcollapse popupWhile 1 ;added in, seems to be working, remove if non-responsive! If WinExists("Enter Initial") Then Local $c = WinActivate("Enter Initial") WinWaitActive($c) Sleep(200) If $c = 0 Then Exit MsgBox(0, 0, "errpr") Local $aPos = WinGetPos("Enter Initial") If @error Then Exit MsgBox(0, 0, 0) ConsoleWrite(@CRLF & $aPos[0] & " " & $aPos[1] & " " & $aPos[2] & " " & @CRLF) MouseClick("Primary", $aPos[0] + 25, $aPos[1] + 25, 1, 1) Send("password") Send("{Enter}") EndIf ;remove to here. $nMsg = GUIGetMsg() Switch $nMsg Case $UseMeForTest Case $ClearTest ClearAllMyFiles() Case $vRemoteDirixElisaBatchForMe FixElisaBatchInLIMS() WinActivate("OmegaHelper") Case $MakeMeANewElisaBatch MakeMeANewElisaBatchInLIMS() WinActivate("OmegaHelper") Case $ClipToTemplate ElisaPlateTemplateFixAndExport() Case $ExcelElisa MsgBox(0, 0, "replaced by FIx Eliza Macro!") Case $btnLoadAllFromSampleDue ; Load All Samples from Due Sheet ClearAllMyFiles() Isitrunning() ; First - Checks to see if LIMS is running, goes to main screen if it is. GoToSampleDueSheet() ;Second - Get to SampleDueSheet ExcelLoadAndSum() ; Load the Data From Columns One and Two and Display Both ConsoleWrite(@CRLF & "Close Crap" & @CRLF) AddAllTestCodes() ConsoleWrite(@CRLF & "Add All TestCodes" & @CRLF) Knownornot() ConsoleWrite(@CRLF & "Known Or Not" & @CRLF) Addtolistifknownfunction() ConsoleWrite(@CRLF & "Add to list if known" & @CRLF) ReplacementAndClean() ; Is this still all needed? ConsoleWrite(@CRLF & "ReplacementAndClean Finished") SortEverything() ConsoleWrite(@CRLF & "Sort") MakeWorkingCopies() TrayTip("Samples Loaded", "Samples Loaded From Due Sheet!", 5) WinActivate("OmegaHelper") ;~ ParseAllfile() ;~ TrayTip("Parsing Finished!", "Parsing Finished!", 5) Case $btnLoadFromScreen ExcelLoadAndSum() ; Load the Data From Columns One and Two and Display Both ConsoleWrite(@CRLF & "Close Crap" & @CRLF) AddAllTestCodes() ConsoleWrite(@CRLF & "Add All TestCodes" & @CRLF) Knownornot() ConsoleWrite(@CRLF & "Known Or Not" & @CRLF) Addtolistifknownfunction() ConsoleWrite(@CRLF & "Add to list if known" & @CRLF) ReplacementAndClean() ; Is this still all needed? ConsoleWrite(@CRLF & "ReplacementAndClean Finished") SortEverything() ConsoleWrite(@CRLF & "Sort") MakeWorkingCopies() TrayTip("Samples Loaded", "Samples Loaded From Due Sheet!", 5) WinActivate("OmegaHelper") Case $Button3 ; Clear My Files If ProcessExists("ICReporter3.exe") Then MsgBox(0, 0, "Process exists, forcing restart") ;~ local $cde = ProcessExists("ICReporter3.exe") ProcessClose("ICReporter3.exe") If @error Then MsgBox(0, 0, "Closing the process failed, huh... error # is :" & @error) Else MsgBox(0, 0, "Process wasn't running, suspicious huh?") EndIf Run("C:\Users\Ash\Documents\SampleDueSheetExports\ICReporter3.exe") ;;NEEDS TO BE ON LOCAL PC! If @error Then Exit MsgBox(0, 0, "Couldn't launch IC3Reporter3.exe" & @error & "See Line 184 of SampleDueLoaderScript") Case $Button4 ; Prep Batch Loader TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Isitrunning() AddAllTestCodes() LoadPrepBatchOnly() SortEverything() MakeWorkingCopies() TrayTip("Prep Batch Loaded!", "Batch Loaded!", 5) WinActivate("OmegaHelper") Case $Button5 ; Go to prep batch but don't load TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Isitrunning() $PrepBatchForMe = GUICtrlRead($Combo1) Gotopreponly($PrepBatchForMe) TrayTip("Ready to load prep batch", "Ready to load prep batch", 5) WinActivate("OmegaHelper") Case $Button6 ; Open New Batch Removed Line 592? SortAndCompareToExisting($WhichMachine) TrayTip("toQuit", "Alt-Shift-S to exit!", 1) Isitrunning() AddAllTestCodes() $PrepBatchForMe = GUICtrlRead($Combo1) PrepBatch($PrepBatchForMe) TrayTip("New Batch Loaded!", "New Batch Loaded: " & $PrepBatchForMe, 1) LoadMyMSMSD() LoadPrepBatchOnly() SortEverything() MakeWorkingCopies() WinActivate("OmegaHelper") Case $Button7 ; Source Code TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Run(@ComSpec & ' /c start ' & @ScriptFullPath) Run("Explorer.exe " & @ScriptDir) WinActivate("OmegaHelper") Case $Button8 ; Text Files TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Run("Explorer.exe " & "\\ASH-DEV\Public\MacroShare") WinActivate("OmegaHelper") Case $Button9 TrayTip("toQuit", "Alt-Shift-S to exit!", 5) Isitrunning() WinActivate("OmegaHelper") Case $Button10 ;For Testing Mainly. ProcessClose("MSACCESS.exe") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited January 22, 2020 by BatMan22 Link to comment Share on other sites More sharing options...
BatMan22 Posted January 27, 2020 Author Share Posted January 27, 2020 Bump Any ideas guys? Link to comment Share on other sites More sharing options...
Nine Posted January 28, 2020 Share Posted January 28, 2020 I think the problem is that you have given the focus to "Enter initial" and never got fully back. Maybe because the password is not sent correctly, (btw you should have a sleep between mouseclick and send). Anyway it is hard to say without a runable script that replicates your issue. Nevertheless, I was able to try something with notepad. It is not exactly your situation, but it is close and I lost control of the GUI, so I solved my problem this way : Local $hGUI = GUICreate ("Test") Local $idButton = GUICtrlCreateButton ("OK", 20,50,100,25) GUISetState () Local $c, $aPos, $bAttempted = False While 1 If Not $bAttempted And WinExists("[CLASS:Notepad]") Then Local $c = WinActivate("[CLASS:Notepad]") WinWaitActive($c) Sleep(200) If $c = 0 Then Exit MsgBox(0, 0, "error") Local $aPos = WinGetPos($c) If @error Then Exit MsgBox(0, 0, 0) ConsoleWrite(@CRLF & $aPos[0] & " " & $aPos[1] & " " & $aPos[2] & " " & @CRLF) MouseClick("Primary", $aPos[0] + 125, $aPos[1] + 125, 1, 1) Sleep (800) Send("password") Send("{Enter}") Sleep (2000) If WinExists ($c) Then ConsoleWrite ("Wrong password" & @CRLF) $bAttempted = True EndIf Switch GUIGetMsg() Case $idButton Exit EndSwitch WEnd ps. this is the way to debug a program. Make a smaller replicate of the problem and then it is easier to find solution. BatMan22 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BatMan22 Posted February 1, 2020 Author Share Posted February 1, 2020 On 1/28/2020 at 6:36 AM, Nine said: I think the problem is that you have given the focus to "Enter initial" and never got fully back. Maybe because the password is not sent correctly, (btw you should have a sleep between mouseclick and send). Anyway it is hard to say without a runable script that replicates your issue. Nevertheless, I was able to try something with notepad. It is not exactly your situation, but it is close and I lost control of the GUI, so I solved my problem this way : Local $hGUI = GUICreate ("Test") Local $idButton = GUICtrlCreateButton ("OK", 20,50,100,25) GUISetState () Local $c, $aPos, $bAttempted = False While 1 If Not $bAttempted And WinExists("[CLASS:Notepad]") Then Local $c = WinActivate("[CLASS:Notepad]") WinWaitActive($c) Sleep(200) If $c = 0 Then Exit MsgBox(0, 0, "error") Local $aPos = WinGetPos($c) If @error Then Exit MsgBox(0, 0, 0) ConsoleWrite(@CRLF & $aPos[0] & " " & $aPos[1] & " " & $aPos[2] & " " & @CRLF) MouseClick("Primary", $aPos[0] + 125, $aPos[1] + 125, 1, 1) Sleep (800) Send("password") Send("{Enter}") Sleep (2000) If WinExists ($c) Then ConsoleWrite ("Wrong password" & @CRLF) $bAttempted = True EndIf Switch GUIGetMsg() Case $idButton Exit EndSwitch WEnd ps. this is the way to debug a program. Make a smaller replicate of the problem and then it is easier to find solution. You're a badass. I don't know why but apparently WinActivate for this specific window causes the program to get semi-stuck like you said, weird. Anyways, with the attempted condition added in, it works great. Thanks! As far as debugging, I couldn't figure out why it wasn't working even with the stripped down version because I was using the same window that it was getting stuck on. You rock 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