SpotCheckBilly Posted June 5, 2009 Share Posted June 5, 2009 Hey all,in one or I'm working on a rather ambitious project considering my extreme novice knowledge of both programming in general and AutoIt. I Have a nice GUI put together I have also been working with muncherw to help me get started, and who also said I would probably get more help here in the main forums. The main objective is to compare several different types of log files which are actually lists of Windows registry entries. I have a general idea of how I can identify the different sections of the lists but before I can do then I need to be able to get the log files to populate the list box. I've been reading threads here regarding populating listboxs and found one that looked like it would be appropriate for my needs. It involves the following: __FileReadToArray, _GUICtrlListBox_BeginUpdate _GUICtrlListBox_AddString _GUICtrlListBox_UpdateHScroll _GUICtrlListBox_EndUpdate Using the examples in the AutoIt help file, I managed to populate the example listbox with my log files. I ran into a roadblock trying to populate the list box is my main GUI. Here's a stripped-down version of my code for the main GUI: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Main = GUICreate("DB Scanner", 641, 443, 126, 113) GUISetFont(10, 400, 0, "Tahoma") GUISetOnEvent($GUI_EVENT_CLOSE, "MainClose") GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainMinimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MainMaximize") GUISetOnEvent($GUI_EVENT_RESTORE, "MainRestore") $List1 = GUICtrlCreateList("", 4, 14, 625, 326, BitOR($LBS_SORT, $LBS_STANDARD, $LBS_MULTICOLUMN, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER)) GUICtrlSetBkColor(-1, 0xFFFBF0) $Log1 = GUICtrlCreateMenu("&Log") $Open = GUICtrlCreateMenuItem("Open (Ctrl+O)", $Log1) GUICtrlSetOnEvent(-1, "OpenClick") $MenuItem1 = GUICtrlCreateMenuItem("Exit", $Log1) GUICtrlSetOnEvent(-1, "MenuItem1Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func MainClose() Exit EndFunc ;==>MainClose Func MainMaximize() EndFunc ;==>MainMaximize Func MainMinimize() EndFunc ;==>MainMinimize Func MainRestore() EndFunc ;==>MainRestore Func MenuItem1Click() Exit EndFunc ;==>MenuItem1Click OpenClick() Func OpenClick () Dim $aRecords $hListBox=$List1 $handle = FileOpenDialog("", "@working", "Text Files (*.log; *.txt)") If Not _FileReadToArray($handle, $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf ; Add strings _GUICtrlListBox_BeginUpdate($hListBox) For $x = 1 To $aRecords[0] _GUICtrlListBox_AddString($hListBox, $aRecords[$x] & @CR) Next _GUICtrlListBox_UpdateHScroll($hListBox) _GUICtrlListBox_EndUpdate($hListBox) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>OpenClick I also have code for my main GUI with no events if that would be easier to start with. I've spent the last two days working with the AutoIt help file and reading threads here but I don't seem to be able to find what I'm missing. I appreciate any help. I'm starting to get a little bit of an idea how coding works using the tutorials and AutoIt1-2-3 but I seem to be caught in a perpetual loop. Thanks a lot in advance. [font="Tahoma"]"I was worried 'bout rich and skinny, 'til I wound up poor and fat."-- Delbert McClinton[/font] Link to comment Share on other sites More sharing options...
stampy Posted June 6, 2009 Share Posted June 6, 2009 You've not stated what problem you are having. However when reviewing the code I see that you've added a second loop inside the open function that will cause it to get stuck there. You want it to return from that function so that it will return to the main loop. The exit didn't work with that loop there. expandcollapse popup;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #Include <GuiListBox.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Main = GUICreate("DB Scanner", 641, 443, 126, 113) GUISetFont(10, 400, 0, "Tahoma") GUISetOnEvent($GUI_EVENT_CLOSE, "MainClose") GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainMinimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MainMaximize") GUISetOnEvent($GUI_EVENT_RESTORE, "MainRestore") $List1 = GUICtrlCreateList("", 4, 14, 625, 326, BitOR($LBS_SORT, $LBS_STANDARD, $LBS_MULTICOLUMN, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER)) GUICtrlSetBkColor(-1, 0xFFFBF0) $Log1 = GUICtrlCreateMenu("&Log") $Open = GUICtrlCreateMenuItem("Open (Ctrl+O)", $Log1) GUICtrlSetOnEvent(-1, "OpenClick") $MenuItem1 = GUICtrlCreateMenuItem("Exit", $Log1) GUICtrlSetOnEvent(-1, "MenuItem1Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func MainClose() Exit EndFunc ;==>MainClose Func MainMaximize() EndFunc ;==>MainMaximize Func MainMinimize() EndFunc ;==>MainMinimize Func MainRestore() EndFunc ;==>MainRestore Func MenuItem1Click() Exit EndFunc ;==>MenuItem1Click OpenClick() Func OpenClick() Dim $aRecords $hListBox = $List1 $handle = FileOpenDialog("", "@working", "Text Files (*.log; *.txt)") If Not _FileReadToArray($handle, $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf ; Add strings _GUICtrlListBox_BeginUpdate($hListBox) For $x = 1 To $aRecords[0] _GUICtrlListBox_AddString($hListBox, $aRecords[$x] & @CR) Next _GUICtrlListBox_UpdateHScroll($hListBox) _GUICtrlListBox_EndUpdate($hListBox) ; Loop until user exits ;Do ;Until GUIGetMsg() = $GUI_EVENT_CLOSE ;GUIDelete() EndFunc ;==>OpenClick Link to comment Share on other sites More sharing options...
SpotCheckBilly Posted June 7, 2009 Author Share Posted June 7, 2009 Thanks stampy, If I understand this right, that Do... Until was in the example because the GUI WAS the listbox and in my script the listbox is a control within a GUI that supposed to do other things as well. Is that right? This is sort of like learning how to play cribbage. You have to learn to count them all or you lose points, or in this case the script doesn't work. [font="Tahoma"]"I was worried 'bout rich and skinny, 'til I wound up poor and fat."-- Delbert McClinton[/font] 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