Jump to content

Running 2 GUI's


MariusN
 Share

Recommended Posts

Hi folks...I am currently running an Autoit Script with 2 Menus...The MAIN menu, and then the other menu as a "Function" from the first menu.

Lets say my first (main) menu has 3 buttons in it and 1 button starts my second Menu. My problem now is, i first have to close the 2nd menu before any other buttons or commands can be run from the firtst Main menu. If i CLOSE the 2nd menu, the buttons in my first menu works...Any ideas where i might have gone wrong?

Link to comment
Share on other sites

Thx for the fast reply. I DO have both Gui's open but only the last opened Gui is active...I need to work on both Gui's simultanously.I read something abou WinActive, but am still a noob at it...Here are my small code:

#include <GUIConstantsEx.au3>

Local $MSG, $menu2, $ok1, $menu1, $go, $hello, $main

message()

Func message()

$main = GUICreate("First", 200, 260, 210, 350)

GUISwitch($main)

$menu2 = GUICtrlCreateButton("Manu2", 60, 35, 80, 20)

$hello = GUICtrlCreateButton("Shows Hello", 60, 130, 80, 20)

GUISetState() ; will display an empty dialog box

While 1

$MSG = GUIGetMsg()

Select

Case $MSG = $GUI_EVENT_CLOSE

ExitLoop

Case $MSG = $menu2

message2()

Case $MSG = $hello

MsgBox(0, "", "Hello")

EndSelect

WEnd

EndFunc ;==>message

Func message2()

GUICreate("Second", 200, 160, 610, 350)

$menu1 = GUICtrlCreateButton("Shows OK", 60, 35, 80, 20)

GUISetState()

While 1

$MSG = GUIGetMsg()

Select

Case $MSG = $GUI_EVENT_CLOSE

ExitLoop

Case $MSG = $menu1

MsgBox(0, "", "OK")

EndSelect

WEnd

GUIDelete()

EndFunc

Link to comment
Share on other sites

GUISwitch($main) - you dont need this line in the message1 function i think.

Basically when you have 2 Gui's open you can switch the control between them with GUISwitch().

If you want to click on the first Gui while the second is still opened you should do something like:

Create a new button on gui2 and when pressed do GUIswith(firstgui)

Link to comment
Share on other sites

Sorry about the GUISwitch($main)in the main menu...wasn't suppose to be there...lol

I know what you mean, but i would like both Gui's to be active and visible (although both ARE visible at the mo). The user must be able to click on both AND use the buttons of both Gui's (without having to close neither)

...that's my freekin prob :)

Link to comment
Share on other sites

Then you should use WinActive() to check which gui has been activated and then use GUISwith() to enable it.

Hope you dont mind, but by using my script above, could you maybe give me an example? Sorry if i'm pushing my luck here, but ive tried all types of tricks...even using WinActive with no luck. If BOTH menus are open and you try to click on let's say "Show Hello" on the first menu, nothing happens...
Link to comment
Share on other sites

Something like this.It is not a good programming but will get you started:

#include <GUIConstantsEx.au3>


Local $MSG, $menu2, $ok1, $menu1, $go, $hello, $main,$second


message()


Func message()
$main = GUICreate("First", 200, 260, 210, 350)
GUISwitch($main)
$menu2 = GUICtrlCreateButton("Manu2", 60, 35, 80, 20)
$hello = GUICtrlCreateButton("Shows Hello", 60, 130, 80, 20)

GUISetState() ; will display an empty dialog box
While 1
    if WinActive("First")=0 then 
        GUISwitch($second)
        MsgBox(0,"Second","Selected")
        message2()
    endif
$MSG = GUIGetMsg()
Select
Case $MSG = $GUI_EVENT_CLOSE
Exit
Case $MSG = $menu2
message2()
Case $MSG = $hello
MsgBox(0, "", "Hello")
EndSelect
WEnd
EndFunc ;==>message


Func message2()

$second=GUICreate("Second", 200, 160, 610, 350)
$menu1 = GUICtrlCreateButton("Shows OK", 60, 35, 80, 20)

GUISetState()
While 1
    if WinActive("Second")=0 then 
        GUISwitch($main)
        MsgBox(0,"First","Selected")
        ExitLoop
    endif
$MSG = GUIGetMsg()
Select
Case $MSG = $GUI_EVENT_CLOSE
ExitLoop
Case $MSG = $menu1
MsgBox(0, "", "OK")
EndSelect
WEnd
EndFunc
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...