dew Posted February 8, 2009 Share Posted February 8, 2009 I am working on my first GUI and I am having a problem getting the buttons to work correctly. Would someone show me what I am doing wrong? Thanks ahead. source code: ;#RequireAdmin #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #Include <WinAPI.au3> #Include <File.au3> ; _FileReadToArray #include <array.au3> LOCAL $Button_1, $Button_2, $Button_3, $Button_4, $Button_5, $msg Dim $log, $dir, $fullfile, $lnkinfo, $sAppOpen, $shWndFocus, $file, $search ;************************************************************ ;GUI GuiCreate("Link Files Verification Test", 365, 225) ;GUI labels - GuiCtrlCreateLabel("Test to verify that the necessary "" Lnk"" files work correctly.", 5, 5, 350, 50) GuiCtrlCreateLabel(" ( Log files are created for", 5, 75, 350, 50) GuiCtrlCreateLabel(" both passed and failed", 5, 90, 350, 50) GuiCtrlCreateLabel(" ""Lnk"" files.)", 5, 105, 350, 50) ;GUI labels - created by GuiCtrlCreateLabel("Copyrighted by David Wagner, 2009", 5, 200, 350, 50) ;----- buttons/input ----- ;GUICtrlSetFont(-1,10) GuiSetState() $Button_1 = GUICtrlCreateButton("1. Generate the Lnk log files.",5,40,150,25) $Button_2 = GUICtrlCreateButton("2. View the Successful Lnk files found.", 165,40,195,25) $Button_3 = GUICtrlCreateButton("3. Print the Successful Lnk files found.", 165,75,195,25) $Button_4 = GUICtrlCreateButton("4. View the Failed Lnk files not found.", 165,110,195,25) $Button_5 = GUICtrlCreateButton("5. Print the Failed Lnk files not found.", 165,145,195,25) ; What to do when a button is pressed - GUISetState() ; will display an dialog box with 2 button While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "", "Test Was Canceled.") ExitLoop Case $msg = $Button_1 ;Create the link's data file ----------------------------------------------------------------- $log = FileOpen("lnkFilesList.txt", 2) ;Caution: txt file will be erased at start! _loopdir(@StartMenuCommonDir) ;Use @StartMenuDir to find all files in the current users's startmenu, ;use @StartMenuCommonDir for the allusers startmenu _loopdir(@ProgramsDir) ;Will find all files in the current users's program menu (folder on start menu) FileClose($log) ;Close the file Case $msg = $Button_2 Run('Notepad.exe') ; Will Run/Open Notepad MsgBox(0, 'Testing', 'Button 2 was pressed') ; demonstrate Button 2 being pressed Case $msg = $Button_3 MsgBox(0, 'Testing', 'Button 3 was pressed') ; demonstrate Button 3 being pressed Case $msg = $Button_4 MsgBox(0, 'Testing', 'Button 4 was pressed') ; demonstrate Button 4 being pressed Case $msg = $Button_5 MsgBox(0, 'Testing', 'Button 5 was pressed') ; demonstrate Button 5 being pressed EndSelect WEnd ;-------------------------------------------------------------------------------------------------------------- Func _loopdir($dir) $search = FileFindFirstFile($dir & "\*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $fullfile = $dir & "\" & $file If StringInStr(FileGetAttrib($fullfile), "D") Then _loopdir($fullfile) ;If its a subdirectory, check this too If StringLower(StringRight($file, 3)) = "lnk" Then ;Check to see if it is a lnk based on file extension $lnkinfo = FileGetShortcut($fullfile) FileWriteLine($log, $fullfile) EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
Bert Posted February 8, 2009 Share Posted February 8, 2009 (edited) The labels you have are covering up the buttons. (Width was set to 350) As soon as I remarked the labels out, the script performed as expected. I fixed it and remarked where you made the error. In SciTE, look at lines 17, 18, and 19. Width is set to 150 expandcollapse popup;#RequireAdmin #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #Include <WinAPI.au3> #Include <File.au3> ; _FileReadToArray #include <array.au3> Local $Button_1, $Button_2, $Button_3, $Button_4, $Button_5, $msg Dim $log, $dir, $fullfile, $lnkinfo, $sAppOpen, $shWndFocus, $file, $search ;************************************************************ ;GUI GUICreate("Link Files Verification Test", 365, 225) ;GUI labels - ;GUICtrlCreateLabel("Test to verify that the necessary "" Lnk"" files work correctly.", 5, 5, 350, 50) GUICtrlCreateLabel(" ( Log files are created for", 5, 75,150, 50) ;width was set to 350. I set it to 150 GUICtrlCreateLabel(" both passed and failed", 5, 90, 150, 50);width was set to 350. I set it to 150 GUICtrlCreateLabel(" ""Lnk"" files.)", 5, 105, 150, 50);width was set to 350. I set it to 150 ;~ ;GUI labels - created by ;~ GUICtrlCreateLabel("Copyrighted by David Wagner, 2009", 5, 200, 350, 50) ;----- buttons/input ----- ;GUICtrlSetFont(-1,10) $Button_1 = GUICtrlCreateButton("1. Generate the Lnk log files.", 5, 40, 150, 25) $Button_2 = GUICtrlCreateButton("2. View the Successful Lnk files found.", 165, 40, 195, 25) $Button_3 = GUICtrlCreateButton("3. Print the Successful Lnk files found.", 165, 75, 195, 25) $Button_4 = GUICtrlCreateButton("4. View the Failed Lnk files not found.", 165, 110, 195, 25) $Button_5 = GUICtrlCreateButton("5. Print the Failed Lnk files not found.", 165, 145, 195, 25) ; What to do when a button is pressed - GUISetState() ; will display an dialog box with 2 button While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "", "Test Was Canceled.") ExitLoop Case $msg = $Button_1 ;Create the link's data file ----------------------------------------------------------------- $log = FileOpen("lnkFilesList.txt", 2) ;Caution: txt file will be erased at start! _loopdir(@StartMenuCommonDir) ;Use @StartMenuDir to find all files in the current users's startmenu, ;use @StartMenuCommonDir for the allusers startmenu _loopdir(@ProgramsDir) ;Will find all files in the current users's program menu (folder on start menu) FileClose($log) ;Close the file Case $msg = $Button_2 Run('Notepad.exe') ; Will Run/Open Notepad MsgBox(0, 'Testing', 'Button 2 was pressed') ; demonstrate Button 2 being pressed Case $msg = $Button_3 MsgBox(0, 'Testing', 'Button 3 was pressed') ; demonstrate Button 3 being pressed Case $msg = $Button_4 MsgBox(0, 'Testing', 'Button 4 was pressed') ; demonstrate Button 4 being pressed Case $msg = $Button_5 MsgBox(0, 'Testing', 'Button 5 was pressed') ; demonstrate Button 5 being pressed EndSelect WEnd ;-------------------------------------------------------------------------------------------------------------- Func _loopdir($dir) $search = FileFindFirstFile($dir & "\*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $fullfile = $dir & "\" & $file If StringInStr(FileGetAttrib($fullfile), "D") Then _loopdir($fullfile) ;If its a subdirectory, check this too If StringLower(StringRight($file, 3)) = "lnk" Then ;Check to see if it is a lnk based on file extension $lnkinfo = FileGetShortcut($fullfile) FileWriteLine($log, $fullfile) EndIf WEnd EndFunc ;==>_loopdir Edited February 8, 2009 by Volly The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
dew Posted February 9, 2009 Author Share Posted February 9, 2009 Volly, Thank you for getting back to me. And thanks for pointing out what was wrong. I guessed when I defined the dialog box at '365', I assumed the labeled to be mosted of the length (DUH!) and then placed it over the button. I understand what I was doing. Again, thanks for pointing it out. The labels you have are covering up the buttons. (Width was set to 350) As soon as I remarked the labels out, the script performed as expected. I fixed it and remarked where you made the error. In SciTE, look at lines 17, 18, and 19. Width is set to 150 expandcollapse popup;#RequireAdmin #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #Include <WinAPI.au3> #Include <File.au3> ; _FileReadToArray #include <array.au3> Local $Button_1, $Button_2, $Button_3, $Button_4, $Button_5, $msg Dim $log, $dir, $fullfile, $lnkinfo, $sAppOpen, $shWndFocus, $file, $search ;************************************************************ ;GUI GUICreate("Link Files Verification Test", 365, 225) ;GUI labels - ;GUICtrlCreateLabel("Test to verify that the necessary "" Lnk"" files work correctly.", 5, 5, 350, 50) GUICtrlCreateLabel(" ( Log files are created for", 5, 75,150, 50) ;width was set to 350. I set it to 150 GUICtrlCreateLabel(" both passed and failed", 5, 90, 150, 50);width was set to 350. I set it to 150 GUICtrlCreateLabel(" ""Lnk"" files.)", 5, 105, 150, 50);width was set to 350. I set it to 150 ;~ ;GUI labels - created by ;~ GUICtrlCreateLabel("Copyrighted by David Wagner, 2009", 5, 200, 350, 50) ;----- buttons/input ----- ;GUICtrlSetFont(-1,10) $Button_1 = GUICtrlCreateButton("1. Generate the Lnk log files.", 5, 40, 150, 25) $Button_2 = GUICtrlCreateButton("2. View the Successful Lnk files found.", 165, 40, 195, 25) $Button_3 = GUICtrlCreateButton("3. Print the Successful Lnk files found.", 165, 75, 195, 25) $Button_4 = GUICtrlCreateButton("4. View the Failed Lnk files not found.", 165, 110, 195, 25) $Button_5 = GUICtrlCreateButton("5. Print the Failed Lnk files not found.", 165, 145, 195, 25) ; What to do when a button is pressed - GUISetState() ; will display an dialog box with 2 button While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "", "Test Was Canceled.") ExitLoop Case $msg = $Button_1 ;Create the link's data file ----------------------------------------------------------------- $log = FileOpen("lnkFilesList.txt", 2) ;Caution: txt file will be erased at start! _loopdir(@StartMenuCommonDir) ;Use @StartMenuDir to find all files in the current users's startmenu, ;use @StartMenuCommonDir for the allusers startmenu _loopdir(@ProgramsDir) ;Will find all files in the current users's program menu (folder on start menu) FileClose($log) ;Close the file Case $msg = $Button_2 Run('Notepad.exe') ; Will Run/Open Notepad MsgBox(0, 'Testing', 'Button 2 was pressed') ; demonstrate Button 2 being pressed Case $msg = $Button_3 MsgBox(0, 'Testing', 'Button 3 was pressed') ; demonstrate Button 3 being pressed Case $msg = $Button_4 MsgBox(0, 'Testing', 'Button 4 was pressed') ; demonstrate Button 4 being pressed Case $msg = $Button_5 MsgBox(0, 'Testing', 'Button 5 was pressed') ; demonstrate Button 5 being pressed EndSelect WEnd ;-------------------------------------------------------------------------------------------------------------- Func _loopdir($dir) $search = FileFindFirstFile($dir & "\*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $fullfile = $dir & "\" & $file If StringInStr(FileGetAttrib($fullfile), "D") Then _loopdir($fullfile) ;If its a subdirectory, check this too If StringLower(StringRight($file, 3)) = "lnk" Then ;Check to see if it is a lnk based on file extension $lnkinfo = FileGetShortcut($fullfile) FileWriteLine($log, $fullfile) EndIf WEnd EndFunc ;==>_loopdir 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