Jump to content

Keeping A Gui From Closing


Recommended Posts

My script has a second window that pops up if you press home, when I do that it opens like it should, but when I close it, it closes the whole gui rather then just going back to the old one. Here's part of the script, press home the exit out of the second window the whole script will shut down.

#include <GuiConstants.au3>


$GUI = GuiCreate("Something", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))


$Button_2 = GuiCtrlCreateButton("Home", 150, 60, 70, 30)
$Button_3 = GuiCtrlCreateButton("", 150, 180, 70, 30)
$Button_4 = GuiCtrlCreateButton("", 150, 100, 70, 30)
$Button_5 = GuiCtrlCreateButton("", 150, 140, 70, 30)
$Button_6 = GuiCtrlCreateButton("", 280, 280, 90, 20)
$Button_7 = GuiCtrlCreateButton("", 150, 220, 70, 30)
$oIE = ObjCreate("Shell.Explorer.2")
$2GUI = GUICreate ( "Something", 559, 424,-1, -1,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$GUIActiveX      = GUICtrlCreateObj   ( $oIE,     -1, -1 , 559 , 424 )





GuiSetState(@SW_HIDE, $2GUI)
GUISetState(@SW_SHOW, $GUI)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_2
        GUISetState(@SW_SHOW, $2GUI)
        $oIE.navigate("http://www.autoitscript.com/forum/index.php?act=ST&f=10&t=26196&st=0#entry184686")
    Case Else
;;;
    EndSelect
WEnd
Exit
Edited by bucky002
Link to comment
Share on other sites

The key is that either one you are clicking on is generating a $GUI_EVENT_CLOSE event.

Case $msg = $GUI_EVENT_CLOSE :)

Instead of $oIE = ObjCreate("Shell.Explorer.2") I would recomend $oIE = _iecreate() with the IE.au3 UDF

http://www.autoitscript.com/forum/index.ph...avigate+webpage :(

I know you think that I know I understand what you said, but I am not sure that what I understood is what you thought.

Link to comment
Share on other sites

there are many ways to handle this... this is just one way

#include <GuiConstants.au3>


$GUI = GUICreate("Something", 392, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))


$Button_2 = GUICtrlCreateButton("Home", 150, 60, 70, 30)
$Button_3 = GUICtrlCreateButton("", 150, 180, 70, 30)
$Button_4 = GUICtrlCreateButton("", 150, 100, 70, 30)
$Button_5 = GUICtrlCreateButton("", 150, 140, 70, 30)
$Button_6 = GUICtrlCreateButton("", 280, 280, 90, 20)
$Button_7 = GUICtrlCreateButton("", 150, 220, 70, 30)
$oIE = ObjCreate("Shell.Explorer.2")
GUISetState(@SW_SHOW, $GUI)

$2GUI = GUICreate("Something", 559, 424, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$GUIActiveX = GUICtrlCreateObj($oIE, -1, -1, 559, 424)
GUISetState(@SW_HIDE, $2GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            
            ExitLoop
        Case $msg = $Button_2
            GUISetState(@SW_SHOW, $2GUI)
            $oIE.navigate ("http://www.autoitscript.com/forum/index.php?act=ST&f=10&t=26196&st=0#entry184686")
            While 2
                $msg2 = GUIGetMsg()
                Select
                    Case $msg2 = $GUI_EVENT_CLOSE
                        GUISetState(@SW_HIDE, $2GUI)
                        ExitLoop
                    Case Else
                    ;;;
                EndSelect
            WEnd
        Case Else
        ;;;
    EndSelect
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

Thank you Valuater. I appreciate the help. :)

welcome... here's another

#include <GuiConstants.au3>


$GUI = GUICreate("Something", 392, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))


$Button_2 = GUICtrlCreateButton("Home", 150, 60, 70, 30)
$Button_3 = GUICtrlCreateButton("", 150, 180, 70, 30)
$Button_4 = GUICtrlCreateButton("", 150, 100, 70, 30)
$Button_5 = GUICtrlCreateButton("", 150, 140, 70, 30)
$Button_6 = GUICtrlCreateButton("", 280, 280, 90, 20)
$Button_7 = GUICtrlCreateButton("", 150, 220, 70, 30)
$oIE = ObjCreate("Shell.Explorer.2")
GUISetState(@SW_SHOW, $GUI)

$2GUI = GUICreate("Something", 559, 424, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$GUIActiveX = GUICtrlCreateObj($oIE, -1, -1, 559, 424)
GUISetState(@SW_HIDE, $2GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            If WinActive($2GUI) Then 
                GUISetState(@SW_HIDE, $2GUI)
            Else
                Exit
            EndIf
        Case $msg = $Button_2
            GUISetState(@SW_SHOW, $2GUI)
            $oIE.navigate ("http://www.autoitscript.com/forum/index.php?act=ST&f=10&t=26196&st=0#entry184686")
        Case Else
    ;;;
    EndSelect
WEnd

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Thanks.

I have another question.

I have a picture as the background. So if I compiled it into an .exe how do I get the file to be in the .exe file without having to put my script in a zip with the picture file?

Link to comment
Share on other sites

i use it like this

$My_pic = @TempDir & "\XPClean.jpg"
FileInstall("C:\Program Files\AutoIt3\Examples\AutoIt-123\Images\XPClean.jpg", $My_pic)

$Child = GUICreate("", 614, 370); XPClean
$Image_end = GUICtrlCreatePic($My_pic, 5, 20, 598, 61)

be sure to use

guictrlsetstate( -1, $GUI_DISABLE)

just after creating the pic

8)

Edited by Valuater

NEWHeader1.png

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...