LastSoul Posted August 23, 2013 Share Posted August 23, 2013 (edited) hey guys there is way to load text file to listbox like this in autoit ? Edited August 23, 2013 by LastSoul Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted August 23, 2013 Moderators Solution Share Posted August 23, 2013 LastSoul,Like this? #include <GUIConstantsEx.au3> ; Read file and convert @CRLF to "|" $sData = "|" & StringReplace(FileRead(@ScriptDir & "\12.txt"), @CRLF, "|") $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 200, 200) GUICtrlSetData($cList, $sData) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndM23 LastSoul 1 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...
LastSoul Posted August 23, 2013 Author Share Posted August 23, 2013 (edited) Thanks this was i looking for^^ Edited August 23, 2013 by LastSoul Link to comment Share on other sites More sharing options...
meows Posted December 13, 2014 Share Posted December 13, 2014 Thanks this was i looking for^^ Trying to get through all the misdirection I tried this to get text into a box, I got this The issue I discovered it the text is all misplaced. the top's in the middle and the bottom is at the top. So I spent two days and got this to actually put text into a box on a page. The issue is it is one and just one VERY long line.. I must say. this is way to time intensive.. just to put text into a box other than Notepad.. It is just i really needed this in a box. but am going to fall back to Open Office and make a PDF and use that in the program,. I've actually got good at that, Many thanks though, Melba23 at least I kinda understood that was going on,, #include <GUIConstantsEx.au3> Global $FO_READ Local Const $sFilePath = @ScriptDir & "\Command Interface.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) ; Read file and convert @CRLF to "|" ;$sData = "|" & StringReplace(FileRead(@ScriptDir & "\Command Interface.txt"), @CRLF, "|") Local $sFileRead = FileRead($hFileOpen) $sData = $sFileRead ;$sData = -1 FileRead & @ScriptDir & "\Command Interface.txt" $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 450, 450) GUICtrlSetData($cList, $sData) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
kylomas Posted December 14, 2014 Share Posted December 14, 2014 (edited) meows, Or just use an edit control like... #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> local $str = 'This is one honk''in ass long line. The purpose of this honk''in ass long line is to demonstrate that a honk''in ass long line can be used.' local $gui010 = guicreate('',200,200) ; $es_multiline causes automatic wrapping and $es_readonly prevents editing local $edt010 = guictrlcreateedit('',0,20,200,150, bitor($es_readonly,$es_multiline)) guictrlsetdata($edt010,$str) guisetstate() ; deselect text in edit control _GUICtrlEdit_SetSel ($edt010, -1, 0) while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd kylomas edit: Can you post the file you are loading???? I suspect that your EOL's are not CRLF. edit2: BTW, your code is NOT what M23 posted...you are not replacing the EOL's...also $sfileread and $sdata contain the same thing This is how your script might have been coded... expandcollapse popup#include <GUIConstantsEx.au3> #include <FileConstants.au3> ;Global $FO_READ ; this is declared in FileConstants.au3...declaring it here without assigning a value is meaningless Local Const $sFilePath = @ScriptDir & "\Command Interface.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) ; the only real reason to use a file handle is to check if the open was sucessful if $sFilePath = -1 Then msgbox(0,'Open Error','File failed to open' & @CRLF & 'File = ' & $sFilePath) Exit endif ; Read file and convert @CRLF to "|" ;$sData = "|" & StringReplace(FileRead(@ScriptDir & "\Command Interface.txt"), @CRLF, "|") ;Local $sFileRead = FileRead($hFileOpen) ; this is redundant to the next statement $sData = fileread($hFileOpen) ; if you are going to use a file handle than you should close the handle when you are done with it fileclose($hFileOpen) ; convert EOL's to delimiter for GuiCtrlSetData() $sdata = stringreplace($sdata,@CRLF,'|') ; assuming that CRLF is EOL $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 450, 450) GUICtrlSetData($cList, $sData) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited December 14, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
meows Posted December 14, 2014 Share Posted December 14, 2014 meows, Or just use an edit control like... #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> local $str = 'This is one honk''in ass long line. The purpose of this honk''in ass long line is to demonstrate that a honk''in ass long line can be used.' local $gui010 = guicreate('',200,200) ; $es_multiline causes automatic wrapping and $es_readonly prevents editing local $edt010 = guictrlcreateedit('',0,20,200,150, bitor($es_readonly,$es_multiline)) guictrlsetdata($edt010,$str) guisetstate() ; deselect text in edit control _GUICtrlEdit_SetSel ($edt010, -1, 0) while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd kylomas edit: Can you post the file you are loading???? I suspect that your EOL's are not CRLF. edit2: BTW, your code is NOT what M23 posted...you are not replacing the EOL's...also $sfileread and $sdata contain the same thing This is how your script might have been coded... expandcollapse popup#include <GUIConstantsEx.au3> #include <FileConstants.au3> ;Global $FO_READ ; this is declared in FileConstants.au3...declaring it here without assigning a value is meaningless Local Const $sFilePath = @ScriptDir & "\Command Interface.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) ; the only real reason to use a file handle is to check if the open was sucessful if $sFilePath = -1 Then msgbox(0,'Open Error','File failed to open' & @CRLF & 'File = ' & $sFilePath) Exit endif ; Read file and convert @CRLF to "|" ;$sData = "|" & StringReplace(FileRead(@ScriptDir & "\Command Interface.txt"), @CRLF, "|") ;Local $sFileRead = FileRead($hFileOpen) ; this is redundant to the next statement $sData = fileread($hFileOpen) ; if you are going to use a file handle than you should close the handle when you are done with it fileclose($hFileOpen) ; convert EOL's to delimiter for GuiCtrlSetData() $sdata = stringreplace($sdata,@CRLF,'|') ; assuming that CRLF is EOL $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 450, 450) GUICtrlSetData($cList, $sData) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Oh yes I used a edit something,, GUICtrlSetTip($TITLE, "The title of the message box.") GUICtrlCreateLabel("Text", 10, 50, 30, 4) $TEXT = GUICtrlCreateEdit("", 10, 65, 420, 100, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) GUICtrlSetData($TEXT, StringFormat("Command Interface\r\nHere you can edit almost everything. We left out editing the Users Start date \r\nfor the next 500 words") GUICtrlSetTip($TEXT, "How to use the Command Interface") ;$aTEXT = @ScriptDir & "/Command Interface.txt" ;GUICtrlSetData($TEXT, StringFormat) ;GUICtrlCreateEdit $sText ("", 10, 65, 420, 100, BitOr($ES_READONLY, $WS_VSCROLL, $ES_AUTOVSCROLL)) and it worked! however I forgot and could not find how many words you can use in this and I have 2130 to enter. And it seemed stupid to have to chase ScIte across the screen so I started looking for another way. Then things got ugly.. I do not now how to use StringFormat ( just a lucky guess it worked at all) It is supposed to look like And NOT like And I put that together not testing a standard PDF only to discover without using FOX you can't use PDF. so it looks like I need to use AutoitHotkey to do some things and Autoit to do others being all the IE goodies are linked to deadends. And I thought i would just make notepad a small pop up. but I could not google any answers on how to control it's size. All for the want to put some ANSI text into a stupid box. I do have one last trick up my sleeve. a simple browser. I was researching adding the File Association for it when I came across your posts. That is not what I wanted but thats the way it is.. 30 years and not one of us can get even the what should be simple right, 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