Jump to content

Dissapearing GUI


Recommended Posts

When I run this script, the GUI flashes and dissapears. I have searched the forums for a solution, but found none. Please help, thanks in advance!

Global $name
Global $OK
Global $Form1
#include <GUIConstants.au3>
#include <IE.au3>

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Control Center", 491, 235, 193, 115)
$Label1 = GUICtrlCreateLabel("Run:", 8, 8, 27, 17)
$run = GUICtrlCreateInput("", 40, 8, 441, 21)
$MediaPlayer = GUICtrlCreateButton("Media Player", 8, 200, 89, 25, 0)
$DataBase = GUICtrlCreateButton("Database", 104, 200, 89, 25, 0)
$ToDo = GUICtrlCreateButton("ToDo", 200, 200, 89, 25, 0)
$Notes = GUICtrlCreateButton("Notes", 296, 200, 89, 25, 0)
$Passwords = GUICtrlCreateButton("Passwords", 392, 200, 89, 25, 0)
$hello = GUICtrlCreateLabel("Welcome, " & IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Name", @UserName) & @CRLF & "Today is " & @MON & "/" & @MDAY & "/" & @YEAR, 264, 72, 126, 50)
$memos = GUICtrlCreateEdit("", 16, 64, 233, 121)
GUICtrlSetData(-1, StringReplace(IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Notes", ""), "/n", @CRLF))
$Label2 = GUICtrlCreateLabel("Memos:", 16, 40, 41, 17)
$google = GUICtrlCreateInput("", 312, 168, 169, 21)
$Label3 = GUICtrlCreateLabel("Google:", 264, 168, 41, 17)
$Button1 = GUICtrlCreateButton("Settings...", 264, 136, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Label2
        
    Case $GUI_EVENT_CLOSE
        Exit
    Case $run
        Run(GUICtrlRead($run))
    Case $MediaPlayer
        Run(@ScriptDir & "\MediaPlayer.exe")
    Case $google
        $search = GUICtrlRead($google)
        _IECreate("http://www.google.com/search?q=%22" & StringReplace($search, " ", "+") & "/")
    EndSwitch
    Switch $nMsg
    Case $DataBase
        Run(@ScriptDir & "\BananaDB.exe")
    Case $ToDo
        Run(@ScriptDir & "\BananaToDo.exe")
    Case $Notes
        Run(@ScriptDir & "\BananaNotes.exe")
    Case $Passwords
        Run(@ScriptDir & "\PasswordSafe.exe")
    Case $OK
        IniWrite(@ScriptDir & "\BananaPackData.data", "Main", "Name", GUICtrlRead($name))
        GUICtrlSetData($hello, "Welcome, " & GUICtrlRead($name) & @CRLF & "Today is " & @MON & "/" & @MDAY & "/" & @YEAR)
        GUIDelete($Form1)
    Case $Button1
        #Region ### START Koda GUI section ### Form=
        $Form1 = GUICreate("Settings", 177, 71, 193, 115)
        $name = GUICtrlCreateInput(IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Name", @UserName), 48, 8, 113, 21)
        $Label1 = GUICtrlCreateLabel("Name:", 8, 8, 35, 17)
        $OK = GUICtrlCreateButton("OK", 32, 40, 105, 25, 0)
        GUISetState(@SW_SHOW)
        #EndRegion ### END Koda GUI section ###
    EndSwitch
WEnd

Func OnAutoItExit ()
    IniWrite(@ScriptDir & "\BananaPackData.data", "Main", "Notes", StringReplace(GUICtrlRead($memos), @CRLF, "/n"))
EndFunc
Link to comment
Share on other sites

The problem came from the line i commented out..Seems like you need to fix your loop

Global $name
Global $OK
Global $Form1
Global $hello
#include <GUIConstants.au3>
#include <IE.au3>

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Control Center", 491, 235, 193, 115)
$Label1 = GUICtrlCreateLabel("Run:", 8, 8, 27, 17)
$run = GUICtrlCreateInput("", 40, 8, 441, 21)
$MediaPlayer = GUICtrlCreateButton("Media Player", 8, 200, 89, 25, 0)
$DataBase = GUICtrlCreateButton("Database", 104, 200, 89, 25, 0)
$ToDo = GUICtrlCreateButton("ToDo", 200, 200, 89, 25, 0)
$Notes = GUICtrlCreateButton("Notes", 296, 200, 89, 25, 0)
$Passwords = GUICtrlCreateButton("Passwords", 392, 200, 89, 25, 0)
$hello = GUICtrlCreateLabel("Welcome, " & IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Name", @UserName) & @CRLF & "Today is " & @MON & "/" & @MDAY & "/" & @YEAR, 264, 72, 126, 50)
$memos = GUICtrlCreateEdit("", 16, 64, 233, 121)
GUICtrlSetData(-1, StringReplace(IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Notes", ""), "/n", @CRLF))
$Label2 = GUICtrlCreateLabel("Memos:", 16, 40, 41, 17)
$google = GUICtrlCreateInput("", 312, 168, 169, 21)
$Label3 = GUICtrlCreateLabel("Google:", 264, 168, 41, 17)
$Button1 = GUICtrlCreateButton("Settings...", 264, 136, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Label2
       
    Case $GUI_EVENT_CLOSE
        Exit
    Case $run
        Run(GUICtrlRead($run))
    Case $MediaPlayer
        Run(@ScriptDir & "\MediaPlayer.exe")
    Case $google
        $search = GUICtrlRead($google)
        _IECreate("http://www.google.com/search?q=%22" & StringReplace($search, " ", "+") & "/")
    EndSwitch
    Switch $nMsg
    Case $DataBase
        Run(@ScriptDir & "\BananaDB.exe")
    Case $ToDo
        Run(@ScriptDir & "\BananaToDo.exe")
    Case $Notes
        Run(@ScriptDir & "\BananaNotes.exe")
    Case $Passwords
        Run(@ScriptDir & "\PasswordSafe.exe")
    Case $OK
        IniWrite(@ScriptDir & "\BananaPackData.data", "Main", "Name", GUICtrlRead($name))
        GUICtrlSetData($hello, "Welcome, " & GUICtrlRead($name) & @CRLF & "Today is " & @MON & "/" & @MDAY & "/" & @YEAR)
        ;GUIDelete($Form1)
    Case $Button1
        #Region ### START Koda GUI section ### Form=
        $Form1 = GUICreate("Settings", 177, 71, 193, 115)
        $name = GUICtrlCreateInput(IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Name", @UserName), 48, 8, 113, 21)
        $Label1 = GUICtrlCreateLabel("Name:", 8, 8, 35, 17)
        $OK = GUICtrlCreateButton("OK", 32, 40, 105, 25, 0)
        GUISetState(@SW_SHOW)
        #EndRegion ### END Koda GUI section ###
    EndSwitch
WEnd

Func OnAutoItExit ()
    IniWrite(@ScriptDir & "\BananaPackData.data", "Main", "Notes", StringReplace(GUICtrlRead($memos), @CRLF, "/n"))
EndFunc
Link to comment
Share on other sites

Thanks!

The problem came from the line i commented out..Seems like you need to fix your loop

Global $name
Global $OK
Global $Form1
Global $hello
#include <GUIConstants.au3>
#include <IE.au3>

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Control Center", 491, 235, 193, 115)
$Label1 = GUICtrlCreateLabel("Run:", 8, 8, 27, 17)
$run = GUICtrlCreateInput("", 40, 8, 441, 21)
$MediaPlayer = GUICtrlCreateButton("Media Player", 8, 200, 89, 25, 0)
$DataBase = GUICtrlCreateButton("Database", 104, 200, 89, 25, 0)
$ToDo = GUICtrlCreateButton("ToDo", 200, 200, 89, 25, 0)
$Notes = GUICtrlCreateButton("Notes", 296, 200, 89, 25, 0)
$Passwords = GUICtrlCreateButton("Passwords", 392, 200, 89, 25, 0)
$hello = GUICtrlCreateLabel("Welcome, " & IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Name", @UserName) & @CRLF & "Today is " & @MON & "/" & @MDAY & "/" & @YEAR, 264, 72, 126, 50)
$memos = GUICtrlCreateEdit("", 16, 64, 233, 121)
GUICtrlSetData(-1, StringReplace(IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Notes", ""), "/n", @CRLF))
$Label2 = GUICtrlCreateLabel("Memos:", 16, 40, 41, 17)
$google = GUICtrlCreateInput("", 312, 168, 169, 21)
$Label3 = GUICtrlCreateLabel("Google:", 264, 168, 41, 17)
$Button1 = GUICtrlCreateButton("Settings...", 264, 136, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Label2
       
    Case $GUI_EVENT_CLOSE
        Exit
    Case $run
        Run(GUICtrlRead($run))
    Case $MediaPlayer
        Run(@ScriptDir & "\MediaPlayer.exe")
    Case $google
        $search = GUICtrlRead($google)
        _IECreate("http://www.google.com/search?q=%22" & StringReplace($search, " ", "+") & "/")
    EndSwitch
    Switch $nMsg
    Case $DataBase
        Run(@ScriptDir & "\BananaDB.exe")
    Case $ToDo
        Run(@ScriptDir & "\BananaToDo.exe")
    Case $Notes
        Run(@ScriptDir & "\BananaNotes.exe")
    Case $Passwords
        Run(@ScriptDir & "\PasswordSafe.exe")
    Case $OK
        IniWrite(@ScriptDir & "\BananaPackData.data", "Main", "Name", GUICtrlRead($name))
        GUICtrlSetData($hello, "Welcome, " & GUICtrlRead($name) & @CRLF & "Today is " & @MON & "/" & @MDAY & "/" & @YEAR)
        ;GUIDelete($Form1)
    Case $Button1
        #Region ### START Koda GUI section ### Form=
        $Form1 = GUICreate("Settings", 177, 71, 193, 115)
        $name = GUICtrlCreateInput(IniRead(@ScriptDir & "\BananaPackData.data", "Main", "Name", @UserName), 48, 8, 113, 21)
        $Label1 = GUICtrlCreateLabel("Name:", 8, 8, 35, 17)
        $OK = GUICtrlCreateButton("OK", 32, 40, 105, 25, 0)
        GUISetState(@SW_SHOW)
        #EndRegion ### END Koda GUI section ###
    EndSwitch
WEnd

Func OnAutoItExit ()
    IniWrite(@ScriptDir & "\BananaPackData.data", "Main", "Notes", StringReplace(GUICtrlRead($memos), @CRLF, "/n"))
EndFunc
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...