old_dog Posted September 6, 2006 Share Posted September 6, 2006 I am trying to automate an external program. I want to display a window with a "Start", "Stop" and "Exit" button. When the Start button is clicked, I want to run a menu item from the ext program that checks to see if a device is plugged into a Comm port. If it is not there, it checks 3 times, each time displaying a window saying that it is checking. after 3 attempts, it displays an error window with an "OK" button". i want to loop this process until the "Stop" button is clicked. The following code works sometimes. I think it is because of the popup windows and the GUIwindow is not active at the time I click the "Stop" button. Is there a way to fix this? Or is it easier to change my logic and put the stop button window in the start button loop. expandcollapse popupLocal $MainTitle = "DriveRight Software 2.6.2" Local $ErrorTitle = "Communication Error" Local $ErrorText = "DriveRight is not responding. " Local $MessTitle = "Message" Local $MessText = "Assign Downloaded Data To:" $CheckWin = GUICreate("Is Drive Right Running?", 270, 80) $Label = GUICtrlCreateLabel("Please click a button!", 30, 10) $YesID = GUICtrlCreateButton("Yes", 30, 50, 50, 20) ;$NoID = GUICtrlCreateButton("No", 110, 50, 50, 20) $ExitID = GUICtrlCreateButton("Exit", 190, 50, 50, 20) GUISetState(@SW_SHOW,$CheckWin) ; display the GUI Do $msg = GUIGetMsg() Select Case $msg= $YesID GUIDelete($CheckWin) $StartWin = GUICreate("Monitor Fuel Bowser", 270, 80,-1,100) $StartID = GUICtrlCreateButton("Start", 30, 50, 50, 20) $StopID = GUICtrlCreateButton("Stop", 110, 50, 50, 20) $ExitID2 = GUICtrlCreateButton("Exit", 190, 50, 50, 20) GUISetState(@SW_SHOW,$StartWin) Do $msg2 = GUIGetMsg(1) Select Case $msg2[0] = $StartID While 1 WinWait($MainTitle) WinMenuSelectItem($MainTitle,"","&DriveRight","&Download DriveRight") WinWait($ErrorTitle, $ErrorText, 20) If WinExists($ErrorTitle,$ErrorText) Then WinActivate($ErrorTitle,$ErrorText) ControlClick($ErrorTitle,$ErrorText,"Button1") Else WinWait($MessTitle,$MessText,45) If WinExists($MessTitle,$MessText) Then WinActivate($MessTitle,$MessText) ControlClick($MessTitle,$MessText,"Button2") WinWait("Information","",5) WinActivate("Information",) ControlClick("Information","","Button1") Else MsgBox(4096,"","xxxxxxx",2) EndIf EndIf $msg2 = GUIGetMsg(1) WEnd Case $msg2[0] = $StopID ;MsgBox(64, "New GUI", "You clicked on the stop button!") Case $msg2[0] = $ExitID2 ;MsgBox(64, "New GUI", "You clicked on the exit button!") Case $msg2[0] = $GUI_EVENT_CLOSE EndSelect Until ($msg2[0] = $GUI_EVENT_CLOSE or $msg2[0] = $StopID or $msg2[0] = $ExitID2) and $msg2[1] = $StartWin GUIDelete($StartWin) $CheckWin = GUICreate("Is Drive Right Running?", 270, 80) $Label = GUICtrlCreateLabel("Please click a button!", 30, 10) $YesID = GUICtrlCreateButton("Yes", 30, 50, 50, 20) $ExitID = GUICtrlCreateButton("Exit", 190, 50, 50, 20) GUISetState(@SW_SHOW,$CheckWin) ; display the GUI Case $msg= $ExitID Case $msg= $GUI_EVENT_CLOSE EndSelect Until $msg = $GUI_EVENT_CLOSE or $msg = $ExitID Link to comment Share on other sites More sharing options...
AceLoc Posted September 6, 2006 Share Posted September 6, 2006 Case $msg= $ExitID Case $msg= $GUI_EVENT_CLOSE ¿¿¿? [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
old_dog Posted September 6, 2006 Author Share Posted September 6, 2006 Sorry, did not copy whole program..... expandcollapse popup#include <GUIConstants.au3> Opt("WinWaitDelay",1000) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) If WinExists("DriveRight Software 2.6.2") Then Else Run("C:\Program Files\DriveRight Software\dright.exe","C:\Program Files\DriveRight Software") WinWait("Please enter User Name and Password","User Name") If Not WinActive("Please enter User Name and Password","User Name") Then WinActivate("Please enter User Name and Password","User Name") WinWaitActive("Please enter User Name and Password","User Name") Send("*****{TAB}*****{ENTER}") EndIf WinWait("DriveRight Software 2.6.2","") If Not WinActive("DriveRight Software 2.6.2","") Then WinActivate("DriveRight Software 2.6.2","") WinWait("DriveRight Software 2.6.2","") WinMenuSelectItem("DriveRight Software 2.6.2","","&Setup","&Serial Port...") WinWait("Serial Port Settings","Auto Detect") ControlClick("Serial Port Settings","Auto Detect","BorRadio3") ControlClick("Serial Port Settings","Auto Detect","Button2") WinSetState("DriveRight Software 2.6.2","",@SW_MAXIMIZE) WinSetState("DriveRight Software 2.6.2","",@SW_MINIMIZE) Local $MainTitle = "DriveRight Software 2.6.2" Local $ErrorTitle = "Communication Error" Local $ErrorText = "DriveRight is not responding. " Local $MessTitle = "Message" Local $MessText = "Assign Downloaded Data To:" $CheckWin = GUICreate("Is Drive Right Running?", 270, 80) $Label = GUICtrlCreateLabel("Please click a button!", 30, 10) $YesID = GUICtrlCreateButton("Yes", 30, 50, 50, 20) ;$NoID = GUICtrlCreateButton("No", 110, 50, 50, 20) $ExitID = GUICtrlCreateButton("Exit", 190, 50, 50, 20) GUISetState(@SW_SHOW,$CheckWin) ; display the GUI Do $msg = GUIGetMsg() Select Case $msg= $YesID GUIDelete($CheckWin) $StartWin = GUICreate("Monitor Fuel Bowser", 270, 80,-1,100) $StartID = GUICtrlCreateButton("Start", 30, 50, 50, 20) $StopID = GUICtrlCreateButton("Stop", 110, 50, 50, 20) $ExitID2 = GUICtrlCreateButton("Exit", 190, 50, 50, 20) GUISetState(@SW_SHOW,$StartWin) Do $msg2 = GUIGetMsg(1) Select Case $msg2[0] = $StartID While 1 WinWait($MainTitle) WinMenuSelectItem($MainTitle,"","&DriveRight","&Download DriveRight") WinWait($ErrorTitle, $ErrorText, 20) If WinExists($ErrorTitle,$ErrorText) Then WinActivate($ErrorTitle,$ErrorText) ControlClick($ErrorTitle,$ErrorText,"Button1") Else WinWait($MessTitle,$MessText,45) If WinExists($MessTitle,$MessText) Then WinActivate($MessTitle,$MessText) ControlClick($MessTitle,$MessText,"Button2") WinWait("Information","",5) WinActivate("Information",) ControlClick("Information","","Button1") Else MsgBox(4096,"","xxxxxxx",2) EndIf EndIf $msg2 = GUIGetMsg(1) WEnd Case $msg2[0] = $StopID ;MsgBox(64, "New GUI", "You clicked on the stop button!") Case $msg2[0] = $ExitID2 ;MsgBox(64, "New GUI", "You clicked on the exit button!") Case $msg2[0] = $GUI_EVENT_CLOSE EndSelect Until ($msg2[0] = $GUI_EVENT_CLOSE or $msg2[0] = $StopID or $msg2[0] = $ExitID2) and $msg2[1] = $StartWin GUIDelete($StartWin) $CheckWin = GUICreate("Is Drive Right Running?", 270, 80) $Label = GUICtrlCreateLabel("Please click a button!", 30, 10) $YesID = GUICtrlCreateButton("Yes", 30, 50, 50, 20) $ExitID = GUICtrlCreateButton("Exit", 190, 50, 50, 20) GUISetState(@SW_SHOW,$CheckWin) ; display the GUI Case $msg= $ExitID Case $msg= $GUI_EVENT_CLOSE EndSelect Until $msg = $GUI_EVENT_CLOSE or $msg = $ExitID Link to comment Share on other sites More sharing options...
AceLoc Posted September 6, 2006 Share Posted September 6, 2006 its kinda late here.. i will look at it when im done eating [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
old_dog Posted September 7, 2006 Author Share Posted September 7, 2006 Any one got any ideals on this???? 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