Sign in to follow this  
Followers 0
soadmania

Buttons dont work :S

7 posts in this topic

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:

#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

Share this post


Link to post
Share on other sites



Put a ExitLoop right after ''Sleep($Time*1000)''

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Nah still not working :D But thx for your help.

Edited by soadmania

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :D

Can u tell me the difference? Im really new at autoit scripting :D

Share this post


Link to post
Share on other sites

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 :D

Share this post


Link to post
Share on other sites

Thank you :D

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0