faustf Posted June 21, 2020 Share Posted June 21, 2020 hi guys why this script not colored green ? expandcollapse popup#include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $idListview GUICreate("ListView Set Text Color", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Set colors ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN) ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 100) ; Add items _GUICtrlListView_BeginUpdate($idListview) For $iI = 1 To 10 _GUICtrlListView_AddItem($idListview, "Item " & $iI) If Not Mod($iI, 2) Then ;Even _GUICtrlListView_SetTextColor($idListview, $CLR_RED) Else ;Odd _GUICtrlListView_SetTextColor($idListview, $CLR_GREEN) EndIf Next _GUICtrlListView_EndUpdate($idListview) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Link to comment Share on other sites More sharing options...
mikell Posted June 21, 2020 Share Posted June 21, 2020 Because _GUICtrlListView_SetTextColor is intended to color the text in a whole listview, not in a single item Link to comment Share on other sites More sharing options...
faustf Posted June 21, 2020 Author Share Posted June 21, 2020 o and for siingle item exist a method ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2020 Moderators Share Posted June 21, 2020 faustf, Look at my GUIListViewEx UDF (the link is in my sig) - it allows you to colour individual cells of a List View. Example 6 shows it in action. 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...
faustf Posted June 21, 2020 Author Share Posted June 21, 2020 i tryed but is very complicated for understund , so , but i try to understund i create a script now in this mode expandcollapse popup#include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include "GUIListViewEx.au3" Example() Func Example() Local $idListview GUICreate("ListView Set Text Color", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Set colors ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN) ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 100) ; Add items _GUICtrlListView_BeginUpdate($idListview) Local $iCol For $iI = 1 To 10 _GUICtrlListView_AddItem($idListview, "Item " & $iI) If Not Mod($iI, 2) Then $iCol= "0xFF0000" ;Even ;_GUICtrlListView_SetTextColor($idListview, $CLR_RED) GUIListViewEx_SetColour($idListview, 1, $iI, $iCol) Else $iCol="0x00FF00" ;Odd ;_GUICtrlListView_SetTextColor($idListview, $CLR_GREEN) GUIListViewEx_SetColour($idListview, 1, $iI, $iCol) EndIf Next _GUICtrlListView_EndUpdate($idListview) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example i include your udf inside but return me this error C:\Users\pc\Desktop\dacancellare\_GUICtrlListView_SetTextColor.au3"(36,54) : error: GUIListViewEx_SetColour(): undefined function. GUIListViewEx_SetColour($idListview, 1, $iI, $iCol) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Users\pc\Desktop\dacancellare\_GUICtrlListView_SetTextColor.au3 - 1 error(s), 0 warning(s) o_O Link to comment Share on other sites More sharing options...
Nine Posted June 21, 2020 Share Posted June 21, 2020 You also can use GUICtrlSetBkColor or GUICtrlSetColor to change the color of a list view item (whole line). “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 Link to comment Share on other sites More sharing options...
faustf Posted June 21, 2020 Author Share Posted June 21, 2020 (edited) 4 minutes ago, Nine said: You also can use GUICtrlSetBkColor or GUICtrlSetColor to change the color of a list view item (whole line). is not good color all like _GUICtrlListView_SetTextColor 2 function for do the same work o_O Edited June 21, 2020 by faustf Link to comment Share on other sites More sharing options...
faustf Posted June 21, 2020 Author Share Posted June 21, 2020 underline pfff expandcollapse popup#include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include "GUIListViewEx.au3" Example() Func Example() Local $idListview GUICreate("ListView Set Text Color", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Set colors ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN) ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 100) ; Add items _GUICtrlListView_BeginUpdate($idListview) Local $iCol For $iI = 1 To 10 _GUICtrlListView_AddItem($idListview, "Item " & $iI) If Not Mod($iI, 2) Then $iCol = "0xFF0000" ;Even ;_GUICtrlListView_SetTextColor($idListview, $CLR_RED) _GUIListViewEx_SetColour($idListview, 1, $iI, $iCol) Else $iCol = "0x00FF00" ;Odd ;_GUICtrlListView_SetTextColor($idListview, $CLR_GREEN) _GUIListViewEx_SetColour($idListview, 1, $iI, $iCol) EndIf Next _GUICtrlListView_EndUpdate($idListview) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example now work but nothing happen Link to comment Share on other sites More sharing options...
Nine Posted June 21, 2020 Share Posted June 21, 2020 2 hours ago, faustf said: is not good color all like you need to specify the listview item (LINE), not the whole control ! “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 Link to comment Share on other sites More sharing options...
faustf Posted June 21, 2020 Author Share Posted June 21, 2020 yep sorry expandcollapse popup#include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include "GUIListViewEx.au3" Example() Func Example() Local $idListview GUICreate("ListView Set Text Color", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Set colors ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN) ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 100) ; Add items _GUICtrlListView_BeginUpdate($idListview) Local $iCol For $iI = 1 To 10 _GUICtrlListView_AddItem($idListview, "Item " & $iI) If Not Mod($iI, 2) Then $iCol = "0xFF0000" ;Even ;_GUICtrlListView_SetTextColor($idListview, $CLR_RED) Local $de= _GUIListViewEx_SetColour($idListview,$iCol,$iI,0 ) If $de =0 Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Else $iCol = "0x00FF00" ;Odd ;_GUICtrlListView_SetTextColor($idListview, $CLR_GREEN) _GUIListViewEx_SetColour($idListview,$iCol,$iI,0 ) EndIf Next _GUICtrlListView_EndUpdate($idListview) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example _GUIListViewEx_SetColour($iLV_Index, $sColSet, $iRow, $iCol) return me event error 1 Failure: Returns 0 and sets @error as follows: ; 1 = Invalid index but use $idListview and is correct why return me error ? Link to comment Share on other sites More sharing options...
faustf Posted June 21, 2020 Author Share Posted June 21, 2020 @Melba23 special thankz for your UDF , is very powerfull and i think is also stable , but example 6 is extreamly complicated, doc instrunctions is very short , if you never seen before , apply this udf is necessary minimum one intensive week studying . i think autoit instead of insert debugarray , if re-think listview is much better , because i think simply is better therefore i adop simply solution #include <GuiConstants.au3> #include <GuiListView.au3> $GUI = GUICreate("Test") $List = GUICtrlCreateListView("Column 1|Column 2", _ 10, 10, 380, 380, -1, $LVS_EX_FULLROWSELECT) GUISetState() For $i = 1 To 20 GUICtrlCreateListViewItem("My description " & $i & "|" & "Initial Value " & $i, $List) If $i = 5 Then GUICtrlSetColor(-1, 0x0000FF) ElseIf $i = 10 Then GUICtrlSetColor(-1, 0xFF0000) EndIf Next While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd thankz again for support , when i have time sure i try to study and use your UDF P.S. the problem is only a type of insert o_O i never understund maybe _GUICtrlListView_AddItem($idListview, "Item " & $iI) to GUICtrlCreateListViewItem("My description " & $i & "|" & "Initial Value " & $i, $List) i dream a simply option _GUICtrlListView_AddItem($idListview, "Item " & $iI, COLORTEXT, CELLTOCOLOR ) IF CELLTOCOLOR= * ALL ROW COLORED next update i hope find thankz again Link to comment Share on other sites More sharing options...
Nine Posted June 21, 2020 Share Posted June 21, 2020 2 hours ago, faustf said: i dream a simply option Don't do a nightmare... mLipok 1 “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 Link to comment Share on other sites More sharing options...
careca Posted June 21, 2020 Share Posted June 21, 2020 (edited) Regarding the UDF, i understand what you mean, the examples are packed with different ways things can be done and when you want only one of them, you have to sort through the code to extract only what you need. But take a look at this example, i think you will find it's not that complex. expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0 $hGUI = GUICreate("LVEx Example 1", 500, 430) $hListView_Right = _GUICtrlListView_Create($hGUI, "", 10, 20, 480, 400, BitOR($LVS_DEFAULT, $WS_BORDER)) _GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT) _GUICtrlListView_AddColumn($hListView_Right, "Peter", 83) _GUICtrlListView_AddColumn($hListView_Right, "Paul", 83) _GUICtrlListView_AddColumn($hListView_Right, "Mary", 83) ;============================================================================= For $i = 1 To $iCount_Right _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1) If Mod($i, 4) Then _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1) EndIf _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2) Next ;============================================================================= ; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - move edit by click + headers editable $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 32) ; All columns editable - simple text selected on open _GUIListViewEx_SetEditStatus($iLV_Right_Index, "*") ; Register for sorting, dragging and editing _GUIListViewEx_MsgRegister() GUISetState() ;Coloring only the background of some items, text remains black. ;============================================================================= $Count = _GUICtrlListView_GetItemCount($hListView_Right) ConsoleWrite($Count &@CRLF) For $c = 0 To $Count If $c < 5 Then _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 0) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 1) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 2) ElseIf $c > 10 Then _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 0) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 1) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 2) EndIf Next ;============================================================================= While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $vRet = _GUIListViewEx_EventMonitor($iEditMode) If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Sleep(100) WEnd ;============================================================================= Dont forget to put GUIListViewEx.au3 in the script folder. EDIT: updated example Edited June 22, 2020 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
faustf Posted June 22, 2020 Author Share Posted June 22, 2020 i use your exmple but colored all background i want color only a write look my simply example last Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 22, 2020 Moderators Share Posted June 22, 2020 faustf, I do realise that the UDF is a very complex beast - but ListViews are very complex controls and trying to manipulate them is not an easy task! However, i am always happy to help users amend their scripts to use the UDF, so do not hesitate to ask if you run into problems. As to your specific problem with _GUIListViewEx_SetColour - you need to use the index from a _GUIListViewEx_Init call to identify the ListView to the UDF, not the ControlID returned by AutoIt when you create the control, and also call the _GUIListViewEx_MsgRegister function to allow the UDF to do the colouring. Let me know if you are still interested in using the UDF and post your basic code with the necessary colour requirements and I will see what I can do. 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...
careca Posted June 22, 2020 Share Posted June 22, 2020 1 hour ago, faustf said: i use your exmple but colored all background i want color only a write look my simply example last I supose i was expecting you to modify the example, but check this one out. expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0 $hGUI = GUICreate("LVEx Example 1", 500, 430) $hListView_Right = _GUICtrlListView_Create($hGUI, "", 10, 20, 480, 400, BitOR($LVS_DEFAULT, $WS_BORDER)) _GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT) _GUICtrlListView_AddColumn($hListView_Right, "Peter", 83) _GUICtrlListView_AddColumn($hListView_Right, "Paul", 83) _GUICtrlListView_AddColumn($hListView_Right, "Mary", 83) ;============================================================================= For $i = 1 To $iCount_Right _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1) If Mod($i, 4) Then _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1) EndIf _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2) Next ;============================================================================= ; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - move edit by click + headers editable $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 32) ; All columns editable - simple text selected on open _GUIListViewEx_SetEditStatus($iLV_Right_Index, "*") ; Register for sorting, dragging and editing _GUIListViewEx_MsgRegister() GUISetState() ;Coloring only the background of some items, text remains black. ;============================================================================= $Count = _GUICtrlListView_GetItemCount($hListView_Right) ConsoleWrite($Count &@CRLF) For $c = 0 To $Count If $c < 5 Then _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 0) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 1) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 2) ElseIf $c > 10 Then _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 0) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 1) _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 2) EndIf Next ;============================================================================= While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $vRet = _GUIListViewEx_EventMonitor($iEditMode) If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Sleep(100) WEnd ;============================================================================= Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe 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