Jump to content

Closing a GUI and opening another one


Recommended Posts

#include <GUIConstants.au3>
Global $IniFile
Global $GUIWidth
Global $GUIHeight
$GUIWidth = 240
$GUIHeight = 240
$Randomboy = GUICreate("Randomboy", $GUIWidth, $GUIHeight)
$Randomboy_Pos = WinGetPos($Randomboy, "")
GUISetState(@SW_SHOW)
$button_1 = GUICtrlCreateButton ( "", 105, 90, 30, 30)
GUICtrlCreateLabel("DO NOT PRESS", 80, 130)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button_1
        GUIDelete()
    EndSelect
Wend
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
GUIDelete()

I have this code and I'm trying to close a GUI and open another one with the button in the middle of it. How would I do this?

I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Link to comment
Share on other sites

#include <GUIConstants.au3>
Global $IniFile
Global $GUIWidth
Global $GUIHeight
$GUIWidth = 240
$GUIHeight = 240
$Randomboy = GUICreate("Randomboy", $GUIWidth, $GUIHeight)
$Randomboy_Pos = WinGetPos($Randomboy, "")
GUISetState(@SW_SHOW)
$button_1 = GUICtrlCreateButton ( "", 105, 90, 30, 30)
GUICtrlCreateLabel("DO NOT PRESS", 80, 130)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button_1
        GUIDelete()
        GUI2()
        ExitLoop
    EndSelect
Wend

MsgBox(0, "Last", "This will be the last thing to appear unless the first gui is closed")

Func GUI2()
    GUICreate("GUI 2", $GUIWidth, $GUIHeight)
    $label = GUICtrlCreateLabel("This is the second gui", 10, 10)
    GUISetState()
    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend
    GUIDelete()
EndFunc

I'm not sure exactly what you want but does that help?

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Thanks so much

It's exactly what I needed

EDIT: Typo

Edited by randomboy

I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Link to comment
Share on other sites

Yes pls go to other languages if you want to create such things...

--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Link to comment
Share on other sites

autoit 1-2-3

its a sticky somewhere here

and try to memorize the helpfile

or alter/rewrite some of the examples in the help file

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

If this is run from a single exe, then it can easily be stopped with ctrl+alt+del, and stop the process altogether, regardless of which window is active, so it's not necessarily malware.

Now, there are possible positive uses for this, but instead of deleting the first gui, it could be set as hidden, with a much more control over future interactions among the 2 guis.

In practical terms, if one has a gui that interacts with a child, say a toolbox, one can always create controls in the first gui for the toolbox to be hidden, or even deleted.

Many apps use this kind of approach in order to optimize the desktop space.

IVAN

Link to comment
Share on other sites

I suppose so, but it's faster to set the state of a child window as @show or @hide whenever you need to rather than recreating it. In fact, there's not really a need for 2 loops, but a single one, as illustrated below:

$gui1=GuiCreate(bla...)

$gui2=GuiCreate(bla...)

while 1

main...

wend

Link to comment
Share on other sites

I've sorted it out by the way. And anyway for this particular task I was doing, I abandoned it and did it in flash.

I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Link to comment
Share on other sites

I have absolutely no respect for those using AutoIt with intentions of generating malware, viruses, etc..., and randomboy will certainly not get much help, guidance or assistance here if his attitude is perceived by members of this community as having this potential.

Having said that, we are letting him know this, so for his own sake, he is probably now rethinking about how he could use Autoit for better purposes, as well as how to phrase an apologetic excuse for why he wanted to create such a tool in the first place.

IVAN

Link to comment
Share on other sites

  • 2 months later...

I'm very sorry for the problems I have caused to this forum and its members. I apologise for the inconvenience and distress I have caused. I will not repeat my actions again and will only use AutoIt for good intentions. All members have my word.

Thanks

Randomboy

Edited by randomboy

I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

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