Jump to content
Sign in to follow this  
BananaFredSoft

Second GUI won't show

Recommended Posts

BananaFredSoft

In this script when you click the Close button on the first GUI, the script keeps running but the second GUI doesn't show. Any help?

#include <GUIConstants.au3>
Global $n = 1
Global $wh = 1
If $n = 1 Then
    $wh = 0
    Opt("GUIOnEventMode", 1)
    $g1 = GUICreate("Test", 100, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Delete", $g1)
    GUISetState(@SW_SHOW)
    While 1
        Sleep(100)
    WEnd
EndIf
$g2 = GUICreate("Test 2", 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExScript", $g2)
GUISetState(@SW_SHOW)
If $wh = 1 Then
    While 1
        Sleep(100)
    WEnd
EndIf
Func Delete ()
    GUIDelete(@GUI_WinHandle)
EndFunc
Func ExScript ()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
MrCreatoR

Hi,

The second gui not shown because the first loop is still looping :)

You need to exit this loop, something like that:

#include <GUIConstants.au3>
Global $n = 1
Global $wh = 1
Global $IsFirstGui = 1
If $n = 1 Then
    $wh = 0
    Opt("GUIOnEventMode", 1)
    $g1 = GUICreate("Test", 100, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Delete", $g1)
    GUISetState(@SW_SHOW)
    While $IsFirstGui = 1
        Sleep(100)
    WEnd
EndIf
$g2 = GUICreate("Test 2", 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExScript", $g2)
GUISetState(@SW_SHOW)
If $wh = 1 Then
    While 1
        Sleep(100)
    WEnd
EndIf
Func Delete ()
    GUIDelete(@GUI_WinHandle)
    $IsFirstGui = 0
EndFunc
Func ExScript ()
    Exit
EndFuncoÝ÷ Øêò¢çf¤zåÊÞ)jëh×6#include <GUIConstants.au3>
Global $n = 1
Global $wh = 1
If $n = 1 Then
    $wh = 0
    Opt("GUIOnEventMode", 1)
    $g1 = GUICreate("Test", 100, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Delete", $g1)
    GUISetState(@SW_SHOW)
EndIf

$g2 = GUICreate("Test 2", 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExScript", $g2)

If $wh = 1 Then
    While 1
        Sleep(100)
    WEnd
EndIf
Func Delete ()
    GUIDelete(@GUI_WinHandle)
    GUISetState(@SW_SHOW, $g2)
EndFunc
Func ExScript ()
    Exit
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
BananaFredSoft

Well, I can get that to work but not with my real script, so I'll show you the problematic part of the real script.

Hi,

The second gui not shown because the first loop is still looping :)

#Region ### START Koda GUI section ### Form=F:\Applications\Koda FormDesigner\Forms\todomain.kxf
Opt("GUIOnEventMode", 1)
$guiMain = GUICreate("Banana ToDo", 305, 314, 237, 122)
GUISetOnEvent($GUI_EVENT_CLOSE , "CloseScript", $guiMain)
$ListView1 = GUICtrlCreateListView("Name           |Date          |Done  ", 8, 8, 281, 257)
$num = IniRead(@ScriptDir & "\Banana ToDo Data.data", "Info", "Number", 1)
Do
    _ArrayAdd($lv, "")
    $num = $num - 1
Until $num = 0
$num = IniRead(@ScriptDir & "\Banana ToDo Data.data", "Info", "Number", 1)
MsgBox(0, "$num", $num)
$pcount = $num
Do
    $1 = IniRead(@ScriptDir & "\Banana ToDo Data.data", "Todo " & $num, "Name", "")
    $2 = IniRead(@ScriptDir & "\Banana ToDo Data.data", "Todo " & $num, "Date", "")
    $cut1 = StringLeft($2, 4)
    $cut2 = StringMid($2, 6, 2)
    $cut3 = StringMid($2, 9)
    $total = ($cut1 * 365) + ($cut2 * 31) + $cut3
    $3 = IniRead(@ScriptDir & "\Banana ToDo Data.data", "Todo " & $num, "Done", "")
    MsgBox(0, "Thingy", $1 & " " & $2 & " " & $3)
    If BitAND($1 <> "", $2 <> "", $3 <> "") Then
        If (@YEAR * 365) + (@MON * 31) + @MDAY >= ($total - IniRead(@ScriptDir & "\Banana ToDo Data.data", "Todo " & $num, "Reminder", "")) Then
            If $3 = "No" Then
                $n = 1
                #Region ### START Koda GUI section ### Form=F:\Applications\Koda FormDesigner\Forms\todo taskalert.kxf
                $Form1 = GUICreate("Task Alert", 357, 135, 404, 212)
                GUISetOnEvent($GUI_EVENT_CLOSE, "ExitTDisplay", $Form1)
                $Label1 = GUICtrlCreateLabel("Banana ToDo Task Alert", 8, 8, 122, 17)
                $Label2 = GUICtrlCreateLabel("Name: " & $1, 8, 32, 500, 17)
                $Label3 = GUICtrlCreateLabel("Date Due: " & $2, 8, 56, 500, 17)
                $Label4 = GUICtrlCreateLabel("Today's Date: " & @YEAR & "/" & @MON & "/" & @MDAY, 8, 80, 500, 17)
                $done = GUICtrlCreateCheckbox("Task is complete", 8, 104, 100, 25)
                $ok = GUICtrlCreateButton("OK", 216, 104, 137, 25, 0)
                GUICtrlSetOnEvent($ok, "GUIRemove")
                GUISetState(@SW_SHOW)
            EndIf
        EndIf
        $lv[$num] = GUICtrlCreateListViewItem($1 & "|" & $2 & "|" & $3, $ListView1)
        GUICtrlSetOnEvent($lv[$num], "ViewOrEditItem")
    EndIf
    $num = $num - 1
Until $num = 0
$Button1 = GUICtrlCreateButton("New", 8, 272, 137, 33, 0)
MsgBox(0, "B1", $Button1)
GUICtrlSetOnEvent($Button1, "NewItem")
$Button3 = GUICtrlCreateButton("Delete", 152, 272, 137, 33, 0)
GUICtrlSetOnEvent($Button3, "DeleteItem")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
MsgBox(0, "Special", "0")
While 1 ;if $n = 0
    Sleep(100)
WEnd

The second gui is $guiMain.

Share this post


Link to post
Share on other sites
MrCreatoR

It is hard to tell, because in that script missing many functions, includes, and many variables used without been declared :)

If you want, you can send to me whole content of your script by PM, and also ini files that needed for it (or some other files that this script uses), and then i can see more clearly where is the problem...

But all what i can say for now (from this part of the code), is that you can try to show the gui like this:

GuiSetState(@SW_HIDE, $guiMain)oÝ÷ Ù©Ý~ìyÊ'v¢jëh×6GUISetState(@SW_SHOW, $Form1)

Maby the problem is that one of conditions is not replyes, so the creation of gui is never executed...

For debug your script (check where the functions is getting, or not getting), you can put a simple empty msgbox (MsgBox(0, "", "")), and if it shown, then you know that in that part where you put it, the script is reached, and if not, try to put the msgbox to outside of the loop/If....Then statments, so you can exactly know where it's stack (or not).


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
gsglive

Try:

GUICtrlSetState(@SW_Show)

for the second GUI.

- gsglive


- gsglive

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  

×