Jump to content

Recommended Posts

Posted

Is this possible ?

I have a main gui, and several child gui's in my script.

Some of the child gui handles some input and so.

What i need is to pause a function until a child gui windows closes, but without pausing the entire script.

for now i do something like this.

GuiSetState(@SW_SHOW, $ChildGUI)
winactivate($ChildGUI, "") ; Child contains some inputboxes and an activation button and an exit button
_Function()


Func _Funftion()
winwaitclose($ChildGUI, "")
msgBox(16, "Msg", "Msg")
EndFunc

My problem is that the winwaitclose pauses the entire script, so the user can not use the buttons in the childGUI

I did try to put in a do until, and a while 1 wend and the all blocks the use of the child gui :mellow:

Is there any way to do this, or do i have to loop forth and back until the child is closed?

Cheers

/Rex

  • Moderators
Posted

Rex,

Without sight of the code proper, this is only a SWAG.

You could use an Adlib function to check if the window still exists:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hLabel = GUICtrlCreateLabel("", 10, 10, 100, 20)
$hButton = GUICtrlCreateButton("Child", 10, 50, 80, 30)

GUISetState()

While 1

    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $hButton
                    $hChild = GUICreate("Child", 200, 100, 100, 100)
                    GUISetState()
                    AdlibRegister("_Check_Child")
            EndSwitch
        Case Else
            If $aMsg[0] = $GUI_EVENT_CLOSE Then GUIDelete($hChild)
    EndSwitch

WEnd

Func _Check_Child()

    If Not WinExists($hChild) Then
        MsgBox(0, "Child", "No longer there!")
        AdlibUnRegister("_Check_Child")
    EndIf

EndFunc

Ask if anything is unclear. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 2/23/2010 at 6:11 PM, 'PsaltyDS said:

Switch your script to GuiOnEventMode. The events actions will interrupt most things like WinWaitClose().

:mellow:

I always run in Guioneventmode :(, but still the winwait ect. still blocks until i do a hardkill :lol:

Cheers

/Rex

Posted

  On 2/23/2010 at 6:24 PM, 'Rex said:

I always run in Guioneventmode :(, but still the winwait ect. still blocks until i do a hardkill :lol:

No it doesn't:
#include <GuiConstantsEx.au3>

Opt("GuiOnEventMode", 1)

$hGUI = GUICreate("Test", 300, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUICtrlCreateButton("ONE", 100, 100, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUICtrlCreateButton("TWO", 100, 150, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUISetState()

_WaitForIt()

Func _WaitForIt()
    WinWaitClose($hGUI)
    MsgBox(64, "Closed", "Window Closed")
EndFunc

Func _Quit()
    GUIDelete($hGUI)
EndFunc

Func _ButtonHit()
    Local $sText = ControlGetText($hGUI, "", @GUI_CtrlId)
    MsgBox(64, "Button Hit", "You clicked: " & $sText)
EndFunc

The code you posted does not use event mode. Post a demo where you use event mode and get blocking.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

  On 2/23/2010 at 6:17 PM, 'Melba23 said:

Rex,

Without sight of the code proper, this is only a SWAG.

You could use an Adlib function to check if the window still exists:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hLabel = GUICtrlCreateLabel("", 10, 10, 100, 20)
$hButton = GUICtrlCreateButton("Child", 10, 50, 80, 30)

GUISetState()

While 1

    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $hButton
                    $hChild = GUICreate("Child", 200, 100, 100, 100)
                    GUISetState()
                    AdlibRegister("_Check_Child")
            EndSwitch
        Case Else
            If $aMsg[0] = $GUI_EVENT_CLOSE Then GUIDelete($hChild)
    EndSwitch

WEnd

Func _Check_Child()

    If Not WinExists($hChild) Then
        MsgBox(0, "Child", "No longer there!")
        AdlibUnRegister("_Check_Child")
    EndIf

EndFunc

Ask if anything is unclear. :(

M23

Hi Melba

i think that this is eact what i need for my prog.

Did't new that that func existed thru i did a help file search before posting :mellow:

I will try to put it into my code, and then repost tomorrow when i have tryed it a bit :lol:

Cheers

/Rex

Posted

Have one Q.

In the adlib...("func") how do i add extra options to load in function

eg.

func _Func($1, $2)

endfunc

cant finde any info in help file either.

Cheers

/Rex

  • Moderators
Posted

rex,

  Quote

What i need is to pause a function until a child gui windows closes, but without pausing the entire script

child gui handles some input and so

Adlib lets you run your main script and interrupts at intervals. It could check whether there is any input in the child window, but as I said at the beginning, without sight of some code this is all guesswork. Give us some concrete details of what you want the child to do and what your main script is doing while waiting. Then we can see what might work.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 2/23/2010 at 6:59 PM, 'Melba23 said:

rex,

Adlib lets you run your main script and interrupts at intervals. It could check whether there is any input in the child window, but as I said at the beginning, without sight of some code this is all guesswork. Give us some concrete details of what you want the child to do and what your main script is doing while waiting. Then we can see what might work.

M23

The Adlib.. works as a charm :(

My q was only becorse i did't wanned to make a var global, but insted send the var's result to the function :P)

Like _Func("data")

Func _Func($Data)

Somthing here :lol:

endfunc

But i can't find out how to put the ("Data") in the adlib func call :mellow:

Cheers

/Rex

  • Moderators
Posted

Rex,

  Quote

But i can't find out how to put the ("Data") in the adlib func call

Af far as I know, you cannot pass parameters to an Adlib function - which is why you cannot find out how do do it! :mellow: Looks like Global will have to do.

I did find this UDF which allows you to pass parameters to a function which is called at intervals. I have never used it, so I have no idea if it works well, but you might find it useful.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 2/24/2010 at 2:02 PM, 'Melba23 said:

Rex,

Af far as I know, you cannot pass parameters to an Adlib function - which is why you cannot find out how do do it! :( Looks like Global will have to do.

I did find this UDF which allows you to pass parameters to a function which is called at intervals. I have never used it, so I have no idea if it works well, but you might find it useful.

M23

Yes the globals it was :mellow:)

The udf looks cool, but i recall somthing about the adlib-en/dis-able was removed and replaced by adlib-reg/unreg, thoe i only skimmed the code of the udf.

Cheers

/Rex

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
  • Recently Browsing   0 members

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