UdovdM Posted July 27, 2006 Share Posted July 27, 2006 (edited) I have made a script with GUI that, if you push the "send" button, will push a button of another program and looks what that programm does in a progress dialog. It may then close 2 error messages if it detects it failed. It works perfect. But when it's done you can't activate any other window by selecting it directly or from the taskbar. WinActivate($GUItitle) doesn't change the active window, just makes the window look active. Active program is responding as normal. You can switch between windows by using the ALT+TAB keys. After that everything works again. It also works again after rightclicking on the AutoIt3 icon. It doesn't seem to pause. The "next" button doesn't cause this problem. Does anyone know this problem and/or knows what might cause it? This is a stripped version without any messageboxes and splashtexts: expandcollapse popupDim $GUItitle = "Display Manager Control" Dim $DMtitle = "Display Manager V1.0 (95)" Run("C:\Program Files\Display Manager\dmngr.exe /NOBCKGRND") WinWaitActive($DMtitle) Sleep(500) WinMove($DMtitle, "", 0, 0, 840, 733) Sleep(500) MouseClick("primary", 80, 100) Sleep(200) Send("{RIGHT 2}") Sleep(400) Send("{ALT}{DOWN 2}{ENTER}") Sleep(200) ; Starting GUI #include <GuiConstants.au3> GuiCreate($GUItitle, 180, 230, 840, 40) $statusTemp = GUICtrlCreateLabel ("--", 10, 10, 160, 20) $buttonNext = GuiCtrlCreateButton("Next", 10, 40, 80, 40) $statusNext = GUICtrlCreateLabel ("First template number", 10, 90, 160, 20) $buttonSend = GuiCtrlCreateButton("Send", 10, 120, 80, 40) $statusSend = GUICtrlCreateLabel ("--", 10, 170, 160,20) $status = GUICtrlCreateLabel ("Ready.", 10, 200, 160, 20) ; Display GUI GuiSetState () Dim $DMsendtitle = "Verzenden" Dim $DMdataerrortitle = "Data error" Dim $msg = 0 ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Select Case $msg = $buttonNext ; Load next template GUICtrlSetData($status, "") GUICtrlSetData($statusNext, "Next template number") Sleep(100) GUICtrlSetData($statusTemp, "Template number") GUICtrlSetData($status, "Ready.") WinActivate($GUItitle) Case $msg = $buttonSend ; Start sending data and check result GUICtrlSetData($status, "") GUICtrlSetData($statusSend, "Sending.") While 1 ; Push transmit button WinActivate($DMtitle) Sleep(100) MouseClick("primary", 500, 690) Sleep(100) If WinActive($DMsendtitle, "response: geen!") Then ; Faillure. No connection. GUICtrlSetData($statusSend, "Failed. Not connected.") GUICtrlSetBkColor($statusSend, 0xFF0000) If WinWaitActive($DMdataerrortitle, "", 5) then Send("{ENTER}") EndIf ; Second failure message If WinWaitActive($DMdataerrortitle, "", 5) then Send("{ENTER}") EndIf GUICtrlSetData($status, "Ready.") WinActivate($GUItitle) ExitLoop EndIf Wend Case Else ;;;; EndSelect Until $msg = $GUI_EVENT_CLOSE I'm using AutoIt V3.1.1 Windows XP Professional SP1 (English) Promedion laptop Pentium 4, 2.66GHz, 256MB Ram Udo Edited July 28, 2006 by UdovdM Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 28, 2006 Share Posted July 28, 2006 HI, you can put ConsoleWrite commands between your statements to check how far you get and where it hangs. Maybe you do not leave your while 1 wend loop. Good luck! So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
UdovdM Posted July 28, 2006 Author Share Posted July 28, 2006 (edited) It does all the steps it is supposed to do, and it doesn't repeat itself.If doesn't hang because I can get it started again.It is a script to control Display Manager, a Led Display program for Windows 95.Here is my new improved longer script:expandcollapse popup; AutoIt Version: 3.1.1 ; Language: US English ; Platform: WinXP ; Author: UdovdM ; Date: 28 Juli 2006 ; Script Function: ; Display Manager v1.0 control Dim $GUItitle = "Display Manager Control" Dim $DMtitle = "Display Manager V1.0 (95)" ; Prompt the user to run the script - use a Yes/No prompt $answer = MsgBox(4, "Display Manager Control Script", "This script will open and manage Display Manager v1.0." & @CRLF & "Run Display Manager?") ; If "No" was clicked (7) then exit the script If $answer = 7 Then Exit EndIf ;;;$CurrentTitle = WinGetTitle("") ; Show splash text ;;;SplashTextOn( "Display Manager Control Script", "Lauching Display Manager and determining windowtitle." & @CRLF & @CRLF & "Please wait.", 300, 100) SplashTextOn( "Display Manager Control Script", "Lauching Display Manager." & @CRLF & @CRLF & "Please wait.", 300, 100) ; Launch Display Manager and determine title Run("C:\Program Files\Display Manager\dmngr.exe /NOBCKGRND") WinWaitActive($DMtitle) ; Dispay Manager should now be active Sleep(500) ;;;$DMtitle = WinGetTitle("") ; Change window position ;;;SplashTextOn( "Display Manager Control Script", "Windowtitle = " & $DMtitle & @CRLF & "Repositioning window." & @CRLF & @CRLF & "Please wait.", 300, 100) SplashTextOn( "Display Manager Control Script", "Repositioning window." & @CRLF & @CRLF & "Please wait.", 300, 100) WinMove($DMtitle, "", 0, 0, 840, 733) Sleep(500) ; Select first show SplashTextOn( "Display Manager Control Script", "Selecting project and Display editor." & @CRLF & @CRLF & "Please wait.", 300, 100) WinActivate($DMtitle, "") Sleep(200) MouseClick("primary", 80, 100) Sleep(200) Send("{RIGHT 2}") Sleep(400) Send("{ALT}{DOWN 2}{ENTER}") Sleep(200) ; done initialising SplashTextOn( "Display Manager Control Script", "Done", 300, 100) Sleep(500) SplashOff() ; Prompt the user to keep the script - use a Yes/No prompt $answer = MsgBox(4, "Display Manager Control Script", "Use this script to manage Display Manager?") ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "Display Manager Control Script", "OK. Bye!") Exit EndIf ; Create GUI #include <GuiConstants.au3> GuiCreate($GUItitle, 180, 250, 840, 40) $statusTemp = GUICtrlCreateLabel ("--", 10, 10, 160, 20) $buttonNext = GuiCtrlCreateButton("Next", 10, 40, 80, 40) $statusNext = GUICtrlCreateLabel ("First template number", 10, 90, 160, 30) $buttonSend = GuiCtrlCreateButton("Send", 10, 130, 80, 40) $statusSend = GUICtrlCreateLabel ("--", 10, 180, 160,30) $status = GUICtrlCreateLabel ("Ready.", 10, 220, 160, 20) ; Display GUI GuiSetState () Dim $DMsendtitle = "Verzenden" Dim $DMdataerrortitle = "Data error" Dim $msg = 0 ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Select Case $msg = $buttonNext ; Load next template GUICtrlSetData($status, "") GUICtrlSetData($statusNext, "Next template number") Sleep(100) GUICtrlSetData($statusTemp, "Current template number") GUICtrlSetData($status, "Ready.") WinActivate($GUItitle) Case $msg = $buttonSend ; Start sending data and check result GUICtrlSetData($status, "") GUICtrlSetData($statusSend, "Sending.") GUICtrlSetBkColor($statusSend, 0xFFFF00) $sendPush = 1 $try = 1 While 1 If $sendPush = 1 Then ; Push transmit button WinActivate($DMtitle) Sleep(100) MouseClick("primary", 500, 690) Sleep(100) $sendPush = 0 EndIf If WinActive($DMsendtitle, "port closed!") Then ; Succes. GUICtrlSetData($statusSend, "Succeded.") GUICtrlSetBkColor($statusSend, 0x00FF00) WinActivate($DMsendtitle) Sleep(1000) Send("{ENTER}") ExitLoop ElseIf WinExists($DMdataerrortitle) Then ; Faillure. GUICtrlSetData($statusSend, "Try " & $try & " failed.") GUICtrlSetBkColor($statusSend, 0xFFFF00) WinActivate($DMdataerrortitle) Send("{ENTER}") Sleep(1000) ; Second failure message WinActivate($DMdataerrortitle) If WinWaitActive($DMdataerrortitle, "", 4) then Send("{ENTER}") EndIf ; Third failure message WinActivate($DMdataerrortitle) If WinWaitActive($DMdataerrortitle, "", 1) then Send("{ENTER}") EndIf ; Allow 4 tries If $try < 4 Then ; Retry $try = $try + 1 $sendPush = 1 GUICtrlSetData($statusSend, "Try " & $try & " .") Else ; No more retries ; Maybe not connected. GUICtrlSetData($statusSend, "FAILED.") GUICtrlSetBkColor($statusSend, 0xFF0000) ExitLoop EndIf EndIf Wend Sleep(100) WinActivate($DMtitle) Sleep(100) WinActivate($GUItitle) GUICtrlSetData($status, "Ready.") EndSelect Sleep(100) Until $msg = $GUI_EVENT_CLOSEThe problem already start with the second messagebox.I can click on the buttons again after one of the folowing:Select Display Manager, press ALT+TAB click on the button twice!Rightclick somewhere then select the messagebox/GUI again.The keyboard still works, so pressing the Spacebar or Enter also work.I think it is a bug in Display Manager but you only notice when some other program (AutoIt for instance) changes the active window. I'll try to fix it with a rightclick on the messagebox/GUI.I have also tried making AutoIt click the left- and right-mousebutton but the problem stays the same.Making AutoIt press Alt+Tab doesn't work.I have placed #include <GuiConstants.au3> halfway at the beginning of the GUI part. Is that OK?Udo Edited July 28, 2006 by UdovdM 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