Sign in to follow this  
Followers 0
brodie28

The GUI created in this function is unresponsive...

7 posts in this topic

#1 ·  Posted (edited)

Func qcode()

msgbox(0, "test", "starting qcode")

_IEAction ( $o_IE, "visible" )

$Form3 = GUICreate("Enter Security Code", 219, 68, 193, 125)

$secinput = GUICtrlCreateInput("", 16, 22, 113, 21)

$subsec = GUICtrlCreateButton("Submit", 144, 20, 65, 25, 0)

GUISetState(@SW_SHOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")

GUICtrlSetOnEvent ( $subsec, "SubmitCode" )

while 1

sleep(50)

WEnd

EndFunc

Anyone have any idea why when this function is called, the GUI it creates does nothing? It is the only GUI open at the time it is called... Also, Opt("GUIOnEventMode", 1) is used earlier in the script.

Edited by brodie28

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>
AutoItSetOption ( "GUIOnEventMode",1)

$Form3 = GUICreate("Enter Security Code", 219, 68, 193, 125)
$secinput = GUICtrlCreateInput("", 16, 22, 113, 21)
$subsec = GUICtrlCreateButton("Submit", 144, 20, 65, 25, 0)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")
GUICtrlSetOnEvent ( $subsec, "SubmitCode" )

while 1
sleep(50)
WEnd

Func terminate()
    Exit
EndFunc

Func SubmitCode()
    MsgBox(0,"","SUBMIT")
EndFunc


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Is this func called by an EVENT from another GUI?

If so you need to complete that event first before a next Event is handled.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

As in the script posted above, it's not a good idea to have a while loop in your function. You main while loop should be in the main body of the script. In addition if this is a second GUI, you don't need another while loop, as the first / main loop takes care of this.

Share this post


Link to post
Share on other sites

I need to have a while loop in that function though. In my script, There is a main GUI at the start which has a while loop... But then it calls a function and the main GUI is deleted. In the middle of the function it calls, this function is called and I need it to stop and get the user input before the first function continues.

It looks something like this:

Main GUI (with while loop) - calls function main()

main() - In the middle of this function, the function I posted is called.

So it needs its own while loop so that the user inputs the data needed before continuing the main function.

Share this post


Link to post
Share on other sites

I need to have a while loop in that function though. In my script, There is a main GUI at the start which has a while loop... But then it calls a function and the main GUI is deleted. In the middle of the function it calls, this function is called and I need it to stop and get the user input before the first function continues.

It looks something like this:

Main GUI (with while loop) - calls function main()

main() - In the middle of this function, the function I posted is called.

So it needs its own while loop so that the user inputs the data needed before continuing the main function.

I have given you the reason why it doesn't work when the Func qcode() is called by a EVENT. You need to change your code that this Event finishes before building the new GUI or not use GUIEvents for the second GUI.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I need to have a while loop in that function though. In my script, There is a main GUI at the start which has a while loop... But then it calls a function and the main GUI is deleted. In the middle of the function it calls, this function is called and I need it to stop and get the user input before the first function continues.

It just will not work that way. You can only have one While loop for OnEvent mode. You'll have to break the first function up. If you need data from this first GUI to create the main GUI, then do you initialization and call this GUI in one function. In the exit function for this GUI call the function that creates your main GUI -

Init() -> call _InputGUI()

InputGUI exit function -> calls _MainGUI()

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