fraizor Posted June 7, 2022 Posted June 7, 2022 Hello how can i limit the amount of lines a list can hold ? i am using a list in my project to show logs. the list eventually will show thousands of lines, i want to limit the amount of lines to avoid any crash or slow performance , as we only need to see the last 50 or so logs i tried this but no luck $listLog = GUICtrlCreateList("", 0, 400, @DesktopWidth/2 -460,200,0x1000) GUICtrlSetLimit($listLog, 3) GUISetState(@SW_SHOW) AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF !
Moderators Melba23 Posted June 7, 2022 Moderators Posted June 7, 2022 fraizor, Read the number of items in the list with _GUICtrlListBox_GetCount and, if it is over the required maximum, use _GUICtrlListBox_DeleteString to delete the early lines. M23 fraizor 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
water Posted June 7, 2022 Posted June 7, 2022 GUICtrlSetLimit only limits the horizontal scrolling. You have to use GUICtrlSetData to fill the list. Simply stop adding new entries when your limit has been reached. fraizor 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Nine Posted June 7, 2022 Posted June 7, 2022 Here an example how to use ControlCommand to interact with a ListBox : #include <GUIConstants.au3> #include <Constants.au3> Example() Func Example() Local $hGUI = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idMylist = GUICtrlCreateList("Buttons that have been clicked by number", 176, 32, 150, 120, BitOR($WS_BORDER, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetLimit(-1, 300) ; to limit horizontal scrolling GUICtrlSetData(-1, "The following buttons have been clicked") Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) Local $iNum = 0, $iCount While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idButton_Add $iCount = ControlCommand($hGUI, "", $idMylist, "GetCount") If $iCount > 10 Then ControlCommand($hGUI, "", $idMylist, "DelString", 0) $iNum += 1 GUICtrlSetData($idMylist, "You clicked button No " & $iNum & "|") ControlCommand($hGUI, "", $idMylist, "SetCurrentSelection", $iCount > 10 ? 10 : $iCount) Case $idButton_Clear GUICtrlSetData($idMylist, "") EndSwitch WEnd EndFunc ;==>Example “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
fraizor Posted June 7, 2022 Author Posted June 7, 2022 24 minutes ago, Nine said: Here an example how to use ControlCommand to interact with a ListBox : #include <GUIConstants.au3> #include <Constants.au3> Example() Func Example() Local $hGUI = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idMylist = GUICtrlCreateList("Buttons that have been clicked by number", 176, 32, 150, 120, BitOR($WS_BORDER, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetLimit(-1, 300) ; to limit horizontal scrolling GUICtrlSetData(-1, "The following buttons have been clicked") Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) Local $iNum = 0, $iCount While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idButton_Add $iCount = ControlCommand($hGUI, "", $idMylist, "GetCount") If $iCount > 10 Then ControlCommand($hGUI, "", $idMylist, "DelString", 0) $iNum += 1 GUICtrlSetData($idMylist, "You clicked button No " & $iNum & "|") ControlCommand($hGUI, "", $idMylist, "SetCurrentSelection", $iCount > 10 ? 10 : $iCount) Case $idButton_Clear GUICtrlSetData($idMylist, "") EndSwitch WEnd EndFunc ;==>Example thank you for the example , i am getting this error ... AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF !
water Posted June 7, 2022 Posted June 7, 2022 Replace "GetCount" wiht "GetLineCount". fraizor 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
fraizor Posted June 7, 2022 Author Posted June 7, 2022 great , thank you guys, one more thing .. how can i always automatically scroll to the end of the list ? AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF !
water Posted June 7, 2022 Posted June 7, 2022 Does the script work for you? Means: Press the "Add" button until you see > 10 lines. Here the script does not delete lines. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted June 7, 2022 Posted June 7, 2022 Seems that "GetLineCount" does not work for a ListBox. I modified the script and it now works for me: expandcollapse popup#include <GUIConstants.au3> #include <Constants.au3> #include <GuiListBox.au3> Example() Func Example() Local $hGUI = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idMylist = GUICtrlCreateList("Buttons that have been clicked by number", 176, 32, 150, 120, BitOR($WS_BORDER, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetLimit(-1, 300) ; to limit horizontal scrolling GUICtrlSetData(-1, "The following buttons have been clicked") Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) Local $iNum = 0, $iCount While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idButton_Add ; $iCount = ControlCommand($hGUI, "", $idMylist, "GetLineCount") $iCount = _GUICtrlListBox_GetCount($idMyList) ConsoleWrite("$iCount: " & $iCount & ", @error=" & @error & @CRLF) If $iCount >= 10 Then ; ControlCommand($hGUI, "", $idMylist, "DelString", 1) _GUICtrlListBox_DeleteString ($idMylist, 0) ConsoleWrite("ControlCommand: @error=" & @error & @CRLF) EndIf $iNum += 1 GUICtrlSetData($idMylist, "You clicked button No " & $iNum & "|") ControlCommand($hGUI, "", $idMylist, "SetCurrentSelection", $iCount > 10 ? 10 : $iCount) Case $idButton_Clear GUICtrlSetData($idMylist, "") EndSwitch WEnd EndFunc ;==>Example My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
fraizor Posted June 7, 2022 Author Posted June 7, 2022 2 minutes ago, water said: Does the script work for you? Means: Press the "Add" button until you see > 10 lines. Here the script does not delete lines. yes it seems to work for me , all buttons are working , however my auto scroll question is in general. this is a sample code.. how can i make it always show the last line ? GUICreate("", 500, 600) $listLog = GUICtrlCreateList("", 0, 400, @DesktopWidth/2 -460,200) GUISetState(@SW_SHOW) for $i = 0 to 90 GUICtrlSetData($listLog,@SEC & "|") Sleep(500) next AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF !
water Posted June 7, 2022 Posted June 7, 2022 This works perfect here: expandcollapse popup#include <GUIConstants.au3> #include <Constants.au3> #include <GuiListBox.au3> Example() Func Example() Local $hGUI = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $iMaxItems = 10 Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idMylist = GUICtrlCreateList("Buttons that have been clicked by number", 176, 32, 150, 120, BitOR($WS_BORDER, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetLimit(-1, 300) ; to limit horizontal scrolling GUICtrlSetData(-1, "The following buttons have been clicked") Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) Local $iNum = 0, $iCount While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idButton_Add $iCount = _GUICtrlListBox_GetCount($idMylist) If $iCount >= $iMaxItems Then _GUICtrlListBox_DeleteString($idMylist, 0) $iCount = $iCount - 1 EndIf $iNum += 1 GUICtrlSetData($idMylist, "You clicked button No " & $iNum & "|") _GUICtrlListBox_SetCurSel($idMylist, $iCount) $iCount = $iCount + 1 Case $idButton_Clear GUICtrlSetData($idMylist, "") EndSwitch WEnd EndFunc ;==>Example My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Nine Posted June 7, 2022 Posted June 7, 2022 52 minutes ago, fraizor said: thank you for the example , i am getting this error ... Download latest version 3.3.16.0, cause it is working fine on this version. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
water Posted June 7, 2022 Posted June 7, 2022 My version runs and works with AutoIt 3.3.14.5 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Nine Posted June 7, 2022 Posted June 7, 2022 21 minutes ago, water said: My version runs and works with AutoIt 3.3.14.5 Does my script works or do you get OP error too ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
water Posted June 7, 2022 Posted June 7, 2022 As posted above: The parameter for ControlCommand was wrong. Has to be changed from "GetCount" to "GetLineCount". In addition $iCount = ControlCommand($hGUI, "", $idMylist, "GetLineCount") always returned 0. According to the help file: "Returns # of lines in an Edit". So GetLineCount does not seem to work for a ListBox control (at least in 3.3.14.5.). My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Nine Posted June 7, 2022 Posted June 7, 2022 3 minutes ago, water said: Has to be changed from "GetCount" to "GetLineCount". I do not have 3.3.14.5 anymore but according to 3.3.16.0 documentation of ControlCommand : Quote "GetCount", "" Returns number of entries in a ListBox or ComboBox Where Quote option [optional] Additional parameter required by some commands. So with 3.3.16.0 $iCount = ControlCommand($hGUI, "", $idMylist, "GetCount") The code is working perfectly and you do not have to specify the option parameter. I guess it is time to update “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
water Posted June 7, 2022 Posted June 7, 2022 Keyword "GetCount" does not exist in AutoIt 3.3.14.5 and was added with 3.3.16.0 in March 2022. I let a few months pass before I update to the latest version My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Nine Posted June 7, 2022 Posted June 7, 2022 44 minutes ago, water said: I let a few months pass before I update to the latest version Like the Beatles said "Dear Prudence" “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
water Posted June 8, 2022 Posted June 8, 2022 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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