soadmania Posted June 5, 2009 Share Posted June 5, 2009 This is my first GUI work. If i press close first program closes. But if i press Start program doesnt work. After pressing Start, close button doesnt work too. Here is my code: expandcollapse popup#include <GUIConstants.au3> Global $Pause Global $ClientName Global $Time Global $Start Global $Stop Global $msg GUICreate("Auto Login",180,100) GUICtrlCreateLabel("Client Name",5, 0) $ClientName = GUICtrlCreateInput("SRO_Client",5,15,100,20) GUICtrlCreateLabel("Time",130,0) $Time= GuiCtrlCreateInput("5",130,15,30,20) $Start=GUICtrlCreateButton("Start", 5, 50,80,30) $Stop=GUICtrlCreateButton("Stop", 95, 50,80,30) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf If $msg = $Start Then Start() EndIf If $msg = $Stop Then Stop() EndIf Wend Func Stop() $Pause = NOT $Pause While $Pause sleep(50) WEnd EndFunc Func Start() While 1 If Not WinActive($ClientName,"") Then WinActivate($ClientName,"") EndIf Send("{ENTER}") Sleep($Time*1000) Wend EndFunc Link to comment Share on other sites More sharing options...
oMBRa Posted June 5, 2009 Share Posted June 5, 2009 Put a ExitLoop right after ''Sleep($Time*1000)'' Link to comment Share on other sites More sharing options...
soadmania Posted June 5, 2009 Author Share Posted June 5, 2009 (edited) Nah still not working But thx for your help. Edited June 5, 2009 by soadmania Link to comment Share on other sites More sharing options...
oMBRa Posted June 5, 2009 Share Posted June 5, 2009 ok I understand the problem, this: If Not WinActive($ClientName,"") Then WinActivate($ClientName,"") EndIf should be: If Not WinActive(GuiCtrlRead($ClientName),"") Then WinActivate(GuiCtrlRead($ClientName),"") EndIf Link to comment Share on other sites More sharing options...
soadmania Posted June 5, 2009 Author Share Posted June 5, 2009 ok I understand the problem, this: If Not WinActive($ClientName,"") Then WinActivate($ClientName,"") EndIf should be: If Not WinActive(GuiCtrlRead($ClientName),"") Then WinActivate(GuiCtrlRead($ClientName),"") EndIf Thxxxx it works now Can u tell me the difference? Im really new at autoit scripting Link to comment Share on other sites More sharing options...
oMBRa Posted June 5, 2009 Share Posted June 5, 2009 look at this: $ClientName = GUICtrlCreateInput("SRO_Client",5,15,100,20) $ClientName holds the ID of the control not the text "SRO_Client" or whatever is typed in, to get the text of the control you have to use GuiCtrlRead in order to do the check for the existence of the window. I hope I was clear... you should look also in the help file for more informations Link to comment Share on other sites More sharing options...
soadmania Posted June 5, 2009 Author Share Posted June 5, 2009 Thank you 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