Jump to content
Sign in to follow this  
russell

Close a GUI without exit

Recommended Posts

russell

I wrote a script that makes several GUI's on one i have it set to contuie the script afer 'OK' is pressed. How do i get it to close that GUI and still contiue...i know i cant use exit or the script will terminate.


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
kylomas

russell,

Use guidelete()

And if you are running a message loop in a function then "return" on $gui_event_close instead of exit.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
russell

thank you very much :)


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
guinness

russell,

Use guidelete()

And if you are running a message loop in a function then "return" on $gui_event_close instead of exit.

kylomas

ExitLoop is more favourable.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
kylomas

russell,

guiness is quite right. A boilerplate might look like this

; *** Start added by AutoIt3Wrapper ***
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
; *** End added by AutoIt3Wrapper ***

#AutoIt3Wrapper_Add_Constants=n

;------------------------------------------------------------------------------------------------
;  Main GUI
;------------------------------------------------------------------------------------------------

local $gui010   =   guicreate('Primary Gui')
local $aSize10  =   wingetclientsize($gui010)
local $lbl010   =   guictrlcreatelabel('Click on me for Secondary Gui',0,20,$aSize10[0],50,bitor($ss_sunken,$ss_center))
                    guictrlsetfont(-1,16,600)
                    guisetstate()

while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
        case $lbl010
            _MyFunc()
    EndSwitch
WEnd

;------------------------------------------------------------------------------------------------
;  Secondary GUI
;------------------------------------------------------------------------------------------------

func _MyFunc()

    local $gui020   =   guicreate('Secondary Gui',500,200)
    local $aSize20  =   wingetclientsize($gui020)
    local $lbl020   =   guictrlcreatelabel('My Secondary Gui',20,20,$aSize20[0]-40,50,bitor($ss_sunken,$ss_center))
                        guictrlsetfont(-1,12,800,default,'Comic Sans Serif')
                        guisetstate()

    while 1
        switch guigetmsg()
            case $gui_event_close
                guidelete($gui020)
                Exitloop
        EndSwitch
    WEnd

    Return

endfunc

kylomas

edit: corrected spacing

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Amathian

If you run into the problem, as I did, where you would have to click the Exit button multiple times when using GUIDelete(), change

While 1

to

While $msg <> $GUI_EVENT_CLOSE

It worked for me, not sure if it is the optimal way to do it, though

Edited by Amathian

Share this post


Link to post
Share on other sites
kylomas

Amathian,

There is something else wrong with your code. Are you issueing guigetmsg() multiple times, a long sleep in the msgloop, a long running function actioned by a control in the msgloop, etc?

If you post your code we'll take a look...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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  

×