Jump to content
TheOne23

How to re-open a Gui after a GUIdelete function has been made in a loop.

Recommended Posts

TheOne23

Hi Everyone,

I would like to have your assistance to check how to re-open a GUI I created after a guidelete of my a GUI.

Say I got 2 GUIs running. Primary is running and secondary is like a pop-up marquee.

the Pop-up Marque GUI will be closed after 10 seconds using GUIdelete($gui2) 

How can I re-open $gui2?

Here is my code:

#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
AutoItSetOption('ExpandEnvStrings', 1)



;#include <msagentlib.au3>
#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <INet.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <GuiButton.au3>
#include <EditConstants.au3>
#include <Process.au3>
#include <String.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include "Marquee.au3"

Global $aMarquee_Coords[4] = [0, 0, @DesktopWidth, 100]
Global $fMarquee_Pos = "top", $hGUI = 0
; Create an array to hold the marquee indices
Global $aMarquee[8]

Local $hGUI = GUICreate("Amelia 3.0", 300, 150)
GUICtrlCreatePic(@ScriptDir &"\amelia1.jpg", 0, -20, 300, 150)
GuiCtrlSetState(-1,$GUI_DISABLE)

local $lbl_Tools

Global $n1, $sText ,$hGUI1

;$lbl_Tools = GUICtrlCreateLabel("     TOOLS   ", 85, 10, 80, 20, $SS_SUNKEN,$BS_CENTER)
$btn_Start = GUICtrlCreateButton("Start Ameila", 175, 70, 120, 30)
GUICtrlSetColor($btn_Start, 0x00FF00);0x00FF00)
GUICtrlSetBkColor($btn_Start,0x000000); 0x000000)

$n1 = GUICtrlCreateInput("", 200, 5, 50, 20)

$About = GUICtrlCreateMenu("&About")

$About1 = GUICtrlCreateMenuItem("Ronald Jayson G. Paggao", $About)

GUICtrlSetColor(-1, 0x00FF00);0x00FF00)
GUICtrlSetBkColor(-1,0x000000); 0x000000)

GUISetState(@SW_SHOW, $hGUI)

Local $msg = 0

While 1
        local $msg = GUIGetMsg()
        Switch $msg

            Case $btn_Start

            Main()

            Case $GUI_EVENT_CLOSE
               Exit

        EndSwitch
WEnd

GUIDelete($hGUI)

Func Main()

   while 1
   calls_waiting()
   WEnd


EndFunc


Func calls_waiting()

;while 1
      $n = GUICtrlRead($n1)
      ;MsgBox(0,"",$n)

      If $n = 1 Then
         $sText = $n & " Call Waiting!!!"
         Messaging()

      Elseif $n > 1 then

         $sText = $n & " Calls Waiting!!!"
         Messaging()

      EndIf

EndFunc

Func Find_Taskbar(ByRef $aMarquee_Coords)

    ; Find taskbar and get size
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTaskBar_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

    ; If error in finding taskbar
    If Not IsArray($aTaskBar_Pos) Then Return SetError(1, 0)

    ; Determine position of taskbar
    If $aTaskBar_Pos[1] > 0 Then
        ; Taskbar at BOTTOM so coords of the marquee are
        $aMarquee_Coords[0] = 0
        $aMarquee_Coords[2] = @DesktopWidth
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - $aTaskBar_Pos[3] - 60
        EndIf
    ElseIf $aTaskBar_Pos[0] > 0 Then
        ; Taskbar at RIGHT so coords of the marquee are
        $aMarquee_Coords[0] = 0
        $aMarquee_Coords[2] = @DesktopWidth - $aTaskBar_Pos[2]
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - 60
        EndIf
    ElseIf $aTaskBar_Pos[2] = @DesktopWidth Then
        ; Taskbar at TOP so coords of the marquee are
        $aMarquee_Coords[0] = 0
        $aMarquee_Coords[2] = @DesktopWidth
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = $aTaskBar_Pos[3]
        Else
            $aMarquee_Coords[1] = @DesktopHeight - 60
        EndIf
    ElseIf $aTaskBar_Pos[3] = @DesktopHeight Then
        ; Taskbar at LEFT so coords of the marquee are
        $aMarquee_Coords[0] = $aTaskBar_Pos[2]
        $aMarquee_Coords[2] = @DesktopWidth - $aTaskBar_Pos[2]
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - 60
        EndIf
    EndIf

EndFunc


Func Messaging()

   Find_Taskbar($aMarquee_Coords)
            ; Create the banner marquee
               If @error Then
                  MsgBox(0, "Error", "Could not find taskbar")
               Else

                      $hGUI1 = GUICreate("Marquee Example 2", $aMarquee_Coords[2], $aMarquee_Coords[3], $aMarquee_Coords[0], $aMarquee_Coords[1], $WS_POPUPWINDOW, $WS_EX_TOPMOST)
                      $aMarquee[1] = _GUICtrlMarquee_Init()
                      _GUICtrlMarquee_SetScroll($aMarquee[1], 0, Default, "left", Default, 20)
                      _GUICtrlMarquee_SetDisplay($aMarquee[1], 1, 0xFFFFFF, 0x00FFFF, 60, "Times new roman") ;0xC0DCC0
                      _GUICtrlMarquee_Create($aMarquee[1], $sText, 0, 0, $aMarquee_Coords[2], $aMarquee_Coords[3])

                      GUISetState(@SW_SHOW,$hGUI1)

                      Sleep(5000)
                      GUIDelete($hGUI1)

               EndIf

                  While 1
                      sleep(10)
                  WEnd
EndFunc

 

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
BrewManNH

If all you want to do is hide the GUI, don't delete it. Use GUISetState with the @SW_HIDE or @SW_SHOW to hide and make it visible again.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Melba23

TheOne23,

Welcome to the AutoIt forums.

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheOne23
16 hours ago, BrewManNH said:

If all you want to do is hide the GUI, don't delete it. Use GUISetState with the @SW_HIDE or @SW_SHOW to hide and make it visible again.

Hi BrewManNH ,

Thank you for your feedback and inputs, I actually tried it but still not working. It does hide the other GUI (Marquee QUI) but once it is hidden it will not re-appear again.  I use this loop below to loop within the Function:

Func Main()

   while 1
   calls_waiting()
   WEnd


EndFunc

Share this post


Link to post
Share on other sites
TheOne23
16 hours ago, Melba23 said:

TheOne23,

Welcome to the AutoIt forums.

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

Hi Melba23,

 

Thank you for you warm welcome!

I will do this moving forward. 

Any input from you Melba23?

Thank you.

Share this post


Link to post
Share on other sites
TheOne23

Hi Everyone,

 

Thank you for your help. I already found out a way to resolve this.

 

TheOne23

Share this post


Link to post
Share on other sites
Earthshine

and? how did you do it? Can you share the solution with others and edit the title in your first post to say Solved so others can find a solution?


My resources are limited. You must ask the right questions

 

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

×