Erbit Posted June 11, 2007 Share Posted June 11, 2007 I have a problem getting my GUI to appear in the program. I Don't understand why it wont work, and any help will be very nice. If FileExists($ConfigPath) Then $Config = FileOpen($ConfigPath, 0) $ScreenSaverVar = IniRead($Config, "config", "screensaver", "None") $VolumeVar = IniRead($Config, "config", "volume", 100) $ShuffleVar = IniRead($Config, "config", "shuffle", "off") $RepeatVar = IniRead($Config, "config", "repeat", "on") $MuteVar = IniRead($Config, "config", "mute", "off") ; Toggle On/Off Select Case $ShuffleVar == "off" $Shuffle = GUICtrlCreateButton("Shuffle (On)", 376, 96, 81, 25) Case $ShuffleVar == "on" $Shuffle = GUICtrlCreateButton("Shuffle (Off)", 376, 96, 81, 25) Case $RepeatVar == "off" $Repeat = GUICtrlCreateButton("Repeat (On)", 376, 128, 81, 25) Case $RepeatVar == "on" $Repeat = GUICtrlCreateButton("Repeat (Off)", 376, 128, 81, 25) Case $MuteVar == "off" $Mute = GUICtrlCreateButton("Mute (On)", 488, 96, 83, 25) Case $MuteVar == "on" $Mute = GUICtrlCreateButton("Mute (Off)", 488, 96, 83, 25) Case Else $Shuffle = GUICtrlCreateButton("Shuffle (On)", 376, 96, 81, 25) $Repeat = GUICtrlCreateButton("Repeat (Off)", 376, 128, 81, 25) $Mute = GUICtrlCreateButton("Mute (On)", 488, 96, 83, 25) EndSelect FileClose($Config) Why wont my GUI show? Link to comment Share on other sites More sharing options...
poisonkiller Posted June 11, 2007 Share Posted June 11, 2007 Is this your full code or only a part of it, because for creating a GUI, GUICreate() is needed... Link to comment Share on other sites More sharing options...
Erbit Posted June 11, 2007 Author Share Posted June 11, 2007 That's just a small porton of the code. Link to comment Share on other sites More sharing options...
Helge Posted June 11, 2007 Share Posted June 11, 2007 I doubt many people here wanna play "Guess the GUI", but I'll go for it... GUISetState()Did I win ? Link to comment Share on other sites More sharing options...
Erbit Posted June 11, 2007 Author Share Posted June 11, 2007 I have everything there, but the problem is that the buttons arn't being changed based upon the configuration. If you need the full code, just ask. Link to comment Share on other sites More sharing options...
SpookMeister Posted June 11, 2007 Share Posted June 11, 2007 Before you post your whole code.... This is the example from the help file for using buttons: #include <GUIConstants.au3> GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_2 MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSelect Wend Make sure that you have all the key parts in your script. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Erbit Posted June 11, 2007 Author Share Posted June 11, 2007 Do I need the Opt("GUICoordMode",2)? Here's my code anyways: expandcollapse popup; Created by: Frederick Lawler ; Date: 6/01/07 ; Finnished: 106/01/07 #include <Sound.au3> #include <GUIConstants.au3> ; Key variables $ProgramFilesPath = "C:\Program Files\" $DirPath = $ProgramFilesPath & "Screen Player\" $ColString = " " $ConfigPath = $DirPath & "config.ini" ; Form $Form1 = GUICreate("Screensaver Music Player", 584, 171, 189, 107) If FileExists($ConfigPath) Then $Config = FileOpen($ConfigPath, 0) $ScreenSaverVar = IniRead($Config, "config", "screensaver", "None") $VolumeVar = IniRead($Config, "config", "volume", 100) $ShuffleVar = IniRead($Config, "config", "shuffle", "off") $RepeatVar = IniRead($Config, "config", "repeat", "on") $MuteVar = IniRead($Config, "config", "mute", "off") ; Toggle On/Off Select Case $ShuffleVar == "off" $Shuffle = GUICtrlCreateButton("Shuffle (On)", 376, 96, 81, 25) Case $ShuffleVar == "on" $Shuffle = GUICtrlCreateButton("Shuffle (Off)", 376, 96, 81, 25) Case $RepeatVar == "off" $Repeat = GUICtrlCreateButton("Repeat (On)", 376, 128, 81, 25) Case $RepeatVar == "on" $Repeat = GUICtrlCreateButton("Repeat (Off)", 376, 128, 81, 25) Case $MuteVar == "off" $Mute = GUICtrlCreateButton("Mute (On)", 488, 96, 83, 25) Case $MuteVar == "on" $Mute = GUICtrlCreateButton("Mute (Off)", 488, 96, 83, 25) Case Else $Shuffle = GUICtrlCreateButton("Shuffle (On)", 376, 96, 81, 25) $Repeat = GUICtrlCreateButton("Repeat (Off)", 376, 128, 81, 25) $Mute = GUICtrlCreateButton("Mute (On)", 488, 96, 83, 25) EndSelect FileClose($Config) Else $Makeconfig = FileOpen($ConfigPath, 2) FileWrite($Makeconfig, "[songs]" & @CRLF) FileWrite($Makeconfig, "song[0][0][0]=D:\Desktop\My Stuff\Media\Music\Toolbox\Ænima\15 Third Eye.mp3" & @CRLF) FileWrite($Makeconfig, "[config]" & @CRLF) FileWrite($Makeconfig, "screensaver=Helios.scr" & @CRLF) FileWrite($Makeconfig, "volume=100" & @CRLF) FileWrite($Makeconfig, "shuffle=off" & @CRLF) FileWrite($Makeconfig, "repeat=on" & @CRLF) FileWrite($Makeconfig, "mute=off" & @CRLF) FileClose($Makeconfig) EndIf ; Read and setup configureations $Sound = "D:\Desktop\My Stuff\Media\Music\Toolbox\Ænima\15 Third Eye.mp3" $Screensaver = "Helios.scr" _SoundOpen($Sound, "song") ; Create the GUI Form #Region ### START Koda GUI section ### Form= ; Form $Form1 = GUICreate("Screensaver Music Player", 584, 171, 189, 107) ; Buttons $Save = GUICtrlCreateButton("Save", 8, 8, 81, 25) $Add = GUICtrlCreateButton("Add", 8, 40, 81, 25) $Remove = GUICtrlCreateButton("Remove", 8, 136, 81, 25) $Help = GUICtrlCreateButton("Help", 488, 128, 81, 25) $Up = GUICtrlCreateButton("Move Up", 288, 8, 73, 25, 0) $Down = GUICtrlCreateButton("Move Down", 288, 40, 73, 25, 0) $Screensaver = GUICtrlCreateButton("Screensaver", 8, 104, 81, 25, 0) ; Labels $Volume = GUICtrlCreateLabel("Volume", 376, 32, 55, 17) ; Slider $VolumeSlider = GUICtrlCreateSlider(376, 48, 161, 33) ; Listbox $List1 = GUICtrlCreateListView("ID|Song" & $ColString, 96, 8, 185, 149) GUICtrlSetData(-1, "ID|Song", "Song") $item1 = GUICtrlCreateListViewItem("001|15 Third Eye.mp3", $List1) ; Just for show for now ; Groupboxes $Controls = GUICtrlCreateGroup("Music Controls", 368, 8, 209, 153) GUICtrlCreateGroup("", -99, -99, 1, 1) ; Get GUI State GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; End the GUI Form ; Hotkeys HotKeySet('{ESC}', 'quit') ; GUI Message While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SoundClose('mysound') Exit Case $Save Save() EndSwitch ; Find the install Directory If Not FileExists($ProgramFilesPath & "Screen Player\") Then DirCreate($ProgramFilesPath & "Screen Player\") EndIf ; Look for the screensaver process. ;~ Sleep(1000) If ProcessExists($Screensaver) Then _SoundPlay("song") EndIf WEnd ; Functions Func Save() Sleep(1000) $SavedFile = FileOpen($DirPath & "config.ini", 2) If $SavedFile = -1 Then MsgBox(0, "Error", "File has not been opened.") Exit Else IniWrite($DirPath, "config", "screensaver", $ScreenSaver) EndIf FileClose($SavedFile) Sleep(100) MsgBox(4096,"Saved!", "The configuration has been saved!") EndFunc Func quit() _SoundClose('mysound') Exit EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now