Sign in to follow this  
Followers 0
itsmeagain_

Close GUI and process code

5 posts in this topic

Hi,

I'm using a GUI to declare variables and when you push a button it has to execute a script and use this var's set in the GUI, the script itself is working fine but the GUI won't close when pressing the button. Here is the part of my script that matters:

#include <GUIConstants.au3>

Opt("GUIOnEventMode",1)

GUICreate("Windowname", 100, 155 )

GUICtrlCreateLabel("Accountnumber:", 10, 5 )
$acc = GUICtrlCreateInput("", 10, 20, 75, 20, $ES_PASSWORD + $ES_NUMBER )
GUICtrlCreateLabel("Password:", 10, 45)
$pass = GUICtrlCreateInput("", 10, 60, 75, 20, $ES_PASSWORD )
GUICtrlCreateLabel("Delay (mins):", 10, 85)
$delay = GUICtrlCreateInput("", 10, 100, 75, 20, $ES_NUMBER );Time before launching script
$YesID  = GUICtrlCreateButton("Login", 10, 130, 35, 20 )
GUICtrlSetOnEvent($YesID,"OnYes")
$ExitID = GUICtrlCreateButton("Exit", 50, 130, 35, 20 )
GUICtrlSetOnEvent($ExitID,"OnExit")

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")

GUISetState()

While 1
   Sleep (1000)
WEnd

Func OnYes()
    $delay = $delay * 60 * 1000
    Sleep( $delay )
    <A fine working code>
    Exit
EndFunc

Func OnExit()
    Exit
EndFunc

So what do I need to do to make it process the code under Func OnYes and make it close the GUI while doing that? It would be also nice to get a little countdown box wich will be displayed as long as the delay takes with a close/stop button so you can stop it at any time, could anyone help me with that too :o?.

Thanks

Itsmeagain_

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>

Opt("GUIOnEventMode",1)

Global $MainGUI = GUICreate("Windowname", 100, 155 )

GUICtrlCreateLabel("Accountnumber:", 10, 5 )
$acc = GUICtrlCreateInput("", 10, 20, 75, 20, $ES_PASSWORD + $ES_NUMBER )
GUICtrlCreateLabel("Password:", 10, 45)
$pass = GUICtrlCreateInput("", 10, 60, 75, 20, $ES_PASSWORD )
GUICtrlCreateLabel("Delay (mins):", 10, 85)
$delay = GUICtrlCreateInput("", 10, 100, 75, 20, $ES_NUMBER );Time before launching script
$YesID  = GUICtrlCreateButton("Login", 10, 130, 35, 20 )
GUICtrlSetOnEvent($YesID,"OnYes")
$ExitID = GUICtrlCreateButton("Exit", 50, 130, 35, 20 )
GUICtrlSetOnEvent($ExitID,"OnExit")

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")

GUISetState()

While 1
   Sleep (1000)
WEnd

Func OnYes()
    GUIDelete($MainGUI)
    $delay = $delay * 60 * 1000
    Sleep( $delay )
    <A fine working code>
    Exit
EndFunc

Func OnExit()
    Exit
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Nice, the GUI will disapear now.

But now I got an other problem, I'm using vars for the accountnumber and the password, these will send to an other program using "Send( $acc )" but it seems its just sending a "4" not the code you entered at the GUI, what did I do wrong? I think the var for the delay has the same problem cause the script is executed immediatly.

Thanks for the help so far :o

Share this post


Link to post
Share on other sites

Nice, the GUI will disapear now.

But now I got an other problem, I'm using vars for the accountnumber and the password, these will send to an other program using "Send( $acc )" but it seems its just sending a "4" not the code you entered at the GUI, what did I do wrong? I think the var for the delay has the same problem cause the script is executed immediatly.

Thanks for the help so far :o

Couple of things

1st the delay should be read and stored into another var,

2nd your probably not reading the control, but sending the control id

#include <GUIConstants.au3>

Opt("GUIOnEventMode",1)

Global $MainGUI = GUICreate("Windowname", 100, 155 )

GUICtrlCreateLabel("Accountnumber:", 10, 5 )
$acc = GUICtrlCreateInput("", 10, 20, 75, 20, $ES_PASSWORD + $ES_NUMBER )
GUICtrlCreateLabel("Password:", 10, 45)
$pass = GUICtrlCreateInput("", 10, 60, 75, 20, $ES_PASSWORD )
GUICtrlCreateLabel("Delay (mins):", 10, 85)
$delay = GUICtrlCreateInput("", 10, 100, 75, 20, $ES_NUMBER );Time before launching script
$YesID  = GUICtrlCreateButton("Login", 10, 130, 35, 20 )
GUICtrlSetOnEvent($YesID,"OnYes")
$ExitID = GUICtrlCreateButton("Exit", 50, 130, 35, 20 )
GUICtrlSetOnEvent($ExitID,"OnExit")

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")

GUISetState()
$i_delay = 0
While 1
   Sleep (1000)
WEnd

Func OnYes()
    GUIDelete($MainGUI)
    $i_delay = Number(GUICtrlRead($delay)) * 60 * 1000
    Sleep( $i_delay )
    Exit
EndFunc

Func OnExit()
    Exit
EndFunc

to read the $acc

Send(GuiCtrlRead($acc))

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanks, now I understand I have to "read" vars from the GUI like GuiCtrlRead($var), I was just doing one thing wrong, deleting the GUI first and rtying to read the vars after :o. But oh well, the script working like it should now.

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