xdp22 Posted December 14, 2010 Share Posted December 14, 2010 Hello, how to display txt file lines, in listbox? Example - in file1.txt we have lines : 1 2 3 4 And in listbox we have : 1 2 3 4 Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2010 Moderators Share Posted December 14, 2010 xdp22,Use _FileReadToArray to get the file into an array. Then loop through the array and use GUICtrlSetData to add to the List control like this:#include <GUIConstantsEx.au3> ; Simulate loading lines from the file Global $aArray[4] = [3, "Line 1", "Line 2", "Line 3"] $hGUI = GUICreate("Test", 500, 500) $hList = GUICtrlCreateList("", 10, 10, 200, 200) For $i =1 To $aArray[0] GUICtrlSetData($hList, $aArray[$i]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xdp22 Posted December 14, 2010 Author Share Posted December 14, 2010 (edited) Thanks, i have one more ask, not for this topic, but i don't want create next topic, can i ask here? I have big problem i try example it what i want to make, and i show you the code what don't work for me. I created gui, with 1 input and 5 buttons, one button = create, next = delete, next = clear, next = Start, next = Stop, when i click button Create, i want to make a way, script will take text from input, and create folder with name like input, in this folder create .txt file, and this script wait to press home key, when home key pressed script make screenshoot 100x100 from mouse cursor (remember u helped me in script), this screenshot is saved in this folder what script maked, and screenshot name was added in this .txt file in this folder. So in example, if u click home 4x, script will make 4x screenshots, with name 1.bmp, 2.bmp, 3.bmp, 4.bmp, and make 4 lines in txt file, 1.bmp, 2.bmp, etc. This is end what script make with create button, button Start is button to start program work, program will use "waypoints", search 1.bmp and click on it, search 2.bmp and click on it, search 3.bmp and click on it, search 4.bmp and click on it, and when end it should make it back, so he will search and click on 4.bmp, 3.bmp, 2.bmp, and 1.bmp, and next 1.bmp, 2.bmp and roll, roll, roll. In listbox, was just txt file, remove just remove screenshot what we select in listbox, and clear just clear all screenshots from listbox, so delete 1.bmp, 2.bmp etc. But i need help only with create and with start i think, listbox, and remove is not needed so much. It is possible to help me with that? I don't start making start button, cuz i had problem with create button, here is my program : expandcollapse popupInclude <ScreenCapture.au3> #include <Misc.au3> #include <WinAPI.au3> #include <array.au3> #Include <File.au3> #include <string.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 325, 386, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 8, 16, 305, 21) $Button1 = GUICtrlCreateButton("Button1", 8, 48, 305, 17) $Delete = GUICtrlCreateButton("Delete", 16, 120, 145, 17) $Clear = GUICtrlCreateButton("Clear", 16, 144, 145, 17) $List1 = GUICtrlCreateList("", 176, 112, 129, 214) $Start = GUICtrlCreateButton("Start", 24, 232, 137, 33) $Stop = GUICtrlCreateButton("Stop", 24, 280, 137, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $folder = GUICtrlRead($Input1) Global $plik = @ScriptDir & "\" & $folder While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Switch $nMsg Case $Button1 DirCreate($folder) FileWriteLine($plik & "\" & $folder & ".txt", "") wpt() EndSwitch WEnd ; Create exit mode HotKeySet("{ESC}", "On_Exit") Func wpt() While 1 $dll = DllOpen("user32.dll") ; Wait for mouse click If _IsPressed("24", $dll) Then ; Get mouse position $aMPos = MouseGetPos() $iLeft = $aMPos[0] - 50 $iTop = $aMPos[1] - 50 $iRight = $aMPos[0] + 50 $iBottom = $aMPos[1] + 50 ; Capture that area $wpt = _FileCountLines($plik & "\" & $folder & ".txt") _ScreenCapture_Capture($plik & "\" & $wpt & ".bmp", $iLeft, $iTop, $iRight, $iBottom, False) FileWriteLine($plik, $wpt) wpt() Do Sleep(10) Until Not(_IsPressed("24", $dll)) EndIf WEnd EndFunc Func On_Exit() DllClose($dll) Exit EndFunc Thank you. Edited December 14, 2010 by xdp22 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2010 Moderators Share Posted December 14, 2010 xdp22, How to make the 4 images: expandcollapse popup#Include <ScreenCapture.au3 > #include <Misc.au3> #include <WinAPI.au3> #include <array.au3> #include <File.au3> #include <string.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> Global $dll = DllOpen("user32.dll") Global $plik $Form1 = GUICreate("Form1", 325, 386, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 8, 16, 305, 21) $Button1 = GUICtrlCreateButton("Button1", 8, 48, 305, 17) $Delete = GUICtrlCreateButton("Delete", 16, 120, 145, 17) $Clear = GUICtrlCreateButton("Clear", 16, 144, 145, 17) $List1 = GUICtrlCreateList("", 176, 112, 129, 214) $Start = GUICtrlCreateButton("Start", 24, 232, 137, 33) $Stop = GUICtrlCreateButton("Stop", 24, 280, 137, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Stop DllClose($dll) Exit Case $Button1 $folder = GUICtrlRead($Input1) $plik = @ScriptDir & "\" & $folder DirCreate($folder) ; `FileWriteLine($plik & "\" & $folder & ".txt", "") ; Not sure you will need this now <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< wpt() EndSwitch WEnd Func wpt() ; We need 4 images For $i = 1 To 4 While 1 ; Wait for Home key If _IsPressed("24", $dll) Then ; Get mouse position $aMPos = MouseGetPos() $iLeft = $aMPos[0] - 50 $iTop = $aMPos[1] - 50 $iRight = $aMPos[0] + 50 $iBottom = $aMPos[1] + 50 ; Capture that area - image number comes from the loop index _ScreenCapture_Capture($plik & "\" & $i & ".bmp", $iLeft, $iTop, $iRight, $iBottom, False) ; FileWriteLine($plik, $i & ".bmp") ; Not sure you will need this now <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Do Sleep(10) Until Not (_IsPressed("24", $dll)) ExitLoop EndIf WEnd Next EndFunc ;==>wpt M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xdp22 Posted December 15, 2010 Author Share Posted December 15, 2010 Thanks, you are great programmer. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 15, 2010 Moderators Share Posted December 15, 2010 xdp22, No - just more experienced than you. Keep learning and you will soon be teaching me new things! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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