dew Posted February 15, 2009 Share Posted February 15, 2009 (edited) I have two radio buttons ('single user' and 'all users'). When I start the program, the first radio button I select works fine regardless which one I select. But if I decide to select the other button afterward, only the results of the first button is repeated. What I am trying to say is, I would to toggle between the two choice ('single user' or 'all users') while the script is running. My question is how can this be done? Thanks in advance. oops! code did not get attached CODE#include <ButtonConstants.au3> #include <Date.au3> #include <GUIConstantsEX.au3> $hGUI = GUICreate("Link Files Verification Test", 265, 325) ;GUI labels - GUICtrlCreateLabel("Select either ""Single User"" or ""All Users", 5, 15, 200, 35) GuiCtrlCreateLabel("Version beta" & @CRLF & "Copyrighted by David Wagner, 2009", 5, 295, 180, 50) ;----- radio buttons ----- $radio1 = GUICtrlCreateRadio("Single User", 10, 30, 90, 50) GUICtrlSetState(-1, $GUI_CHECKED) $radio2 = GUICtrlCreateRadio("All Users", 10, 65, 90, 50) ;----- buttons to select what to do ----- $Button_1 = GUICtrlCreateButton("1. Generate the Lnk log files.", 5, 125, 195, 25, $BS_LEFT) $Button_2 = GUICtrlCreateButton("2. View the Successful Lnk files found.", 5, 150, 195, 25, $BS_LEFT) $Button_3 = GUICtrlCreateButton("3. Print the Successful Lnk files found.", 5, 175, 195, 25, $BS_LEFT) $Button_4 = GUICtrlCreateButton("4. View the Failed Lnk files not found.", 5, 200, 195, 25, $BS_LEFT) $Button_5 = GUICtrlCreateButton("5. Print the Failed Lnk files not found.", 5, 225, 195, 25, $BS_LEFT) ;Create the link's data files, add Tester name and date of the test ---------------------------------------- $SuccessLog = FileOpen("Successful Links.log", 2) ;Caution: Log will be erased at start! $ErrorLog = FileOpen("Failed Links.log", 2) ;Caution: Log will be erased at start! ; What to do when a button is pressed - GUISetState() ; will display an dialog box with 5 button While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 ;generate the log files ;Input Tester Name $TesterName = InputBox("Tester Name", "Enter your name:", "", "", 250, 125, "-1", "-1", 15) ;Create log header - ;Success FileWriteLine($SuccessLog, "Tester: " & $TesterName & @CRLF & "Test ran on: " & _Now() & @CRLF & @CRLF _ & "Successfully located the following linked files." & @CRLF & @CRLF) ;Failed FileWriteLine($ErrorLog, "Tester: " & $TesterName & @CRLF & "Test ran on: " & _Now() & @CRLF & @CRLF _ & "Was unable to locate the following linked files. This part of the Link Test failed." & @CRLF _ & "Manually check that the linked path is correct." & @CRLF & @CRLF) ;which user mode If GUICtrlRead($radio1) = $GUI_CHECKED Then _loopdir(@StartMenuDir) ;Find all files in the current users's startmenu If GUICtrlRead($radio2) = $GUI_CHECKED Then _loopdir(@StartMenuCommonDir) ;Find all files in allusers's startmenu FileClose($ErrorLog) FileClose($SuccessLog) Case $msg = $Button_2 ;open log file for viewing the successful linked files ShellExecute("notepad.exe", "Successful Links.log", @ScriptDir, "open") ;open txt file (view / edit) Case $msg = $Button_3 ; print the successful log file ShellExecute("Successful Links.log", "", @ScriptDir, "print", @SW_HIDE) ;only print the file Case $msg = $Button_4 ShellExecute("notepad.exe", "Failed Links.log", @ScriptDir, "open") ;open txt file (view / edit) Case $msg = $Button_5 ;print the failure log file ShellExecute("Failed Links.log", "", @ScriptDir, "print", @SW_HIDE) ;only print the file 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 wheter it is a lnk based on file extension $lnkinfo = FileGetShortcut($fullfile) If Not FileExists($lnkinfo[0]) Then ;Check wheter target file exists FileWriteLine($ErrorLog, $fullfile) Else FileWriteLine($SuccessLog, $fullfile) EndIf EndIf WEnd EndFunc ;==>_loopdir Edited February 15, 2009 by dew Link to comment Share on other sites More sharing options...
Authenticity Posted February 15, 2009 Share Posted February 15, 2009 expandcollapse popup#include <GUIConstantsEx.au3> GUICreate('Title', 200, 200) GUICtrlCreateGroup('Radio buttons:', 40, 70, 130, 120) $Radio1 = GUICtrlCreateRadio('&Single User', 50, 95, 100, 25) GUICtrlSetState(-1, $GUI_CHECKED) $Radio2 = GUICtrlCreateRadio('&All Users', 50, 135, 100, 25) $Button = GUICtrlCreateButton('All Users', 50, 40, 70, 25) $fUsers = True GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Radio1 ConsoleWrite('Single User' & @CRLF) Case $Radio2 ConsoleWrite('All Users' & @CRLF) Case $Button If $fUsers Then GUICtrlSetState($Radio2, $GUI_CHECKED) GUICtrlSetData($Button, 'Single User') Else GUICtrlSetState($Radio1, $GUI_CHECKED) GUICtrlSetData($Button, 'All Users') EndIf $fUsers = Not $fUsers EndSwitch WEnd Exit ? Link to comment Share on other sites More sharing options...
M a k a v e l ! Posted February 15, 2009 Share Posted February 15, 2009 I have two radio buttons ('single user' and 'all users'). When I start the program, the first radio button I select works fine regardless which one I select. But if I decide to select the other button afterward, only the results of the first button is repeated. What I am trying to say is, I would to toggle between the two choice ('single user' or 'all users') while the script is running. My question is how can this be done? Thanks in advance. CODE #include <ButtonConstants.au3> #include <Date.au3> #include <GUIConstantsEX.au3> $hGUI = GUICreate("Link Files Verification Test", 265, 325) ;GUI labels - GUICtrlCreateLabel("Select either ""Single User"" or ""All Users", 5, 15, 200, 35) GuiCtrlCreateLabel("Version beta" & @CRLF & "Copyrighted by David Wagner, 2009", 5, 295, 180, 50) ;----- radio buttons ----- $radio1 = GUICtrlCreateRadio("Single User", 10, 30, 90, 50) GUICtrlSetState(-1, $GUI_CHECKED) $radio2 = GUICtrlCreateRadio("All Users", 10, 65, 90, 50) I was going for the GuiCtrlRead. Have fun ! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 260, 227, 392, 188) $Radio1 = GUICtrlCreateRadio("Radio1", 72, 40, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Radio2 = GUICtrlCreateRadio("Radio2", 72, 80, 113, 17) $Button1 = GUICtrlCreateButton("Button1", 88, 128, 75, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Radio1 MsgBox(0,"","Radio 1= " & GUICtrlRead($Radio1) & @CRLF & "Radio 2= " & GUICtrlRead($Radio2)) Case $Radio2 MsgBox(0,"","Radio 1= " & GUICtrlRead($Radio1) & @CRLF & "Radio 2= " & GUICtrlRead($Radio2)) Case $Button1 GUICtrlSetState($Radio1,$GUI_UNCHECKED) GUICtrlSetState($Radio2,$GUI_UNCHECKED) EndSwitch WEnd [font="Lucida Sans Unicode"]M a k. a v e L ![/font] Link to comment Share on other sites More sharing options...
dew Posted February 16, 2009 Author Share Posted February 16, 2009 I was going for the GuiCtrlRead. Have fun ! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 260, 227, 392, 188) $Radio1 = GUICtrlCreateRadio("Radio1", 72, 40, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Radio2 = GUICtrlCreateRadio("Radio2", 72, 80, 113, 17) $Button1 = GUICtrlCreateButton("Button1", 88, 128, 75, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Radio1 MsgBox(0,"","Radio 1= " & GUICtrlRead($Radio1) & @CRLF & "Radio 2= " & GUICtrlRead($Radio2)) Case $Radio2 MsgBox(0,"","Radio 1= " & GUICtrlRead($Radio1) & @CRLF & "Radio 2= " & GUICtrlRead($Radio2)) Case $Button1 GUICtrlSetState($Radio1,$GUI_UNCHECKED) GUICtrlSetState($Radio2,$GUI_UNCHECKED) EndSwitch WEndHi Guys, I am still having a problem understanding what is happening here. I tried this (both suggestions) but it still will not work me. I think my problem is mixing the 'switch' case with my 'select' case and this is preventing anything from working. From my code I have set up a select condition depending on what button is selected. What I am trying to accomplish is once the 'tester' selects either "single" or "all" user, they would have the options of going back and select the other and still be able to generate a new report. I am currently new at this (not just autoit, but basic coding in general as well) and I really appreciate the suggestions I am receiving, thanks to all who has helped me. Hopefully, I can get a handle on this and move on to the next stage. 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