svss Posted August 17, 2006 Posted August 17, 2006 Hi, i tried to locate some info in the forum but so far all code i tried failed. Here is what i am trying to achieve I have a text file with usernames user1 user2 user3 etc. I am trying to create a gui with checkboxes for each user and then save the checkoxed users to a new text file. Could someone shine some light on this one. Thx in advance S.
Kreatorul Posted August 17, 2006 Posted August 17, 2006 To read the lines from a file and checkbox them try this #include <GUIConstants.au3> GuiCreate( "Your checkbox script" ) GUISetState () $msg = 0 $read=FileReadLine( "yourfile.txt", 1) $read1=FileReadLine( "yourfile.txt", 2) $read2=FileReadLine( "yourfile.txt", 3) $1=GUICtrlCreateCheckbox( $read, 5, 5) $2=GUICtrlCreateCheckbox( $read1, 5, 30) $3=GUICtrlCreateCheckbox( $read2, 5, 55) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd To write to file use the comand FileWrite...but I can't help you more because i don't know how...hope that helped
MHz Posted August 17, 2006 Posted August 17, 2006 You could look at using _FileReadToArray() and _FileWriteFromArray(). This example may help to give you some direction. I do not want to spoil your fun and do too much... expandcollapse popup#include <GUIConstants.au3> #include <File.au3> Global $aArray _FileReadToArray(@ScriptDir & '\test.txt', $aArray) If @error Then MsgBox(0x1, 'Error', "_FileReadToArray('test.txt', $aArray)") Exit EndIf GUICreate('Title') Global $checkbox[$aArray[0]+1] For $i = 1 To $aArray[0] $checkbox[$i] = GUICtrlCreateCheckbox($aArray[$i], 10, 18 * $i) Next $button_process = GUICtrlCreateButton('&Process', 100, 350, 80) $button_exit = GUICtrlCreateButton('E&xit', 200, 350, 80) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_exit Exit Case $msg = $button_process For $i = 1 To $aArray[0] ; Check state of checkboxes and do conditional action If GUICtrlRead($checkbox[$i]) = $GUI_CHECKED Then $state = 'checked' Else $state = 'unchecked' EndIf MsgBox(0x40000, $aArray[$i], $state) Next EndSelect WEnd Put some names into a text file called test.txt to see the example run.
Zedna Posted August 17, 2006 Posted August 17, 2006 You can use ListView with checkboxes (style $LVS_EX_CHECKBOXES),see my project email_zak - in my signature ...http://www.autoitscript.com/fileman/users/Zedna/email_zak.ziphttp://www.autoitscript.com/fileman/users/Zedna/email_zak.png Resources UDF ResourcesEx UDF AutoIt Forum Search
svss Posted August 18, 2006 Author Posted August 18, 2006 Thanks for the fast reply. I got two issues with your script: 1)i have a list of hundred or so users and need to be able to browse the window. I inserted the following in the script.I see the scroll button on the right side but i am not able to go up or down? GUICreate('Users to Move', 400, 500, -1, -1, $WS_VSCROLL) 2)I try to extract the checkboxed users to a text file with _FileWriteToArray but it gives me the following error ERROR: _FileWriteToArray(): undefined function Is there any other way to do this? Thanks again for all your help Very much appreciated S.
Paulie Posted August 18, 2006 Posted August 18, 2006 For #2, Make sure include at the top of your script (As done in MHz's example) File.au3 #Include <File.au3>
svss Posted August 18, 2006 Author Posted August 18, 2006 Thanks for the reply. I got this included already. Not quite sure what is going on. Thx S.
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