Jump to content

Close GUI and process code


Recommended Posts

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_

Link to comment
Share on other sites

  • Moderators

#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

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.

Link to comment
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

Link to comment
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.

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...