Hello. Maybe this?
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$hMain = GUICreate("Test", -1, 300, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX), $WS_EX_ACCEPTFILES) ;x il drag & drop
;;top
GUICtrlCreateLabel("Listview colour", 55, 0, 275, 40)
GUICtrlSetFont(-1, 24, 400, 0, "Comic Sans MS")
GUICtrlSetColor(-1, $COLOR_GREEN)
GUICtrlCreateLabel("Testing 123", 200, 40, 120, 18)
GUICtrlSetFont(-1, 8, 40, 0, "Comic Sans MS")
GUICtrlSetColor(-1, $COLOR_BLUE)
;;body
GUICtrlCreateLabel("User:", 25, 68, 30, 16)
$inUser = GUICtrlCreateInput("", 56, 66, 83, 21)
$btnLookup = GUICtrlCreateButton("Lookup", 150, 60, 75, 33, $BS_DEFPUSHBUTTON)
$btnGreen = GUICtrlCreateButton("Green", 230, 60, 43, 33)
$btnRed = GUICtrlCreateButton("Red", 275, 60, 43, 33)
$listComputers = GUICtrlCreateListView("Name |Model |Serial |OS Install date|HDD", 55, 100, 290, 100, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SINGLESEL))
GUICtrlSetState($inUser, $GUI_FOCUS)
GUISetState(@SW_SHOW)
; Main GUI loop
While True
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $inUser
GUICtrlSetState($inUser, $GUI_FOCUS)
Case $nMsg = $btnLookup
LookupButtonPressed()
Case $nMsg = $btnGreen
$iIndex = _GUICtrlListView_GetSelectedIndices($listComputers)
$machine = _GUICtrlListView_GetItemText($listComputers, Number($iIndex))
_GUICtrlListView_SetItemImage($listComputers, $iIndex, 1)
; ; change to green?
;_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, 0x00FF00, 16, 16)) ; green
Case $nMsg = $btnRed
$iIndex = _GUICtrlListView_GetSelectedIndices($listComputers)
$machine = _GUICtrlListView_GetItemText($listComputers, Number($iIndex))
_GUICtrlListView_SetItemImage($listComputers, $iIndex, 2)
; ; change to red?
;_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, 0xFF0000, 16, 16)) ; red
EndSelect
WEnd
Func LookupButtonPressed()
_GUICtrlListView_DeleteAllItems($listComputers)
;$aMachines = machine_lookup($user, $searchstring)
Local $aMachines[2][5]
$aMachines[0][0] = "PC01"
$aMachines[0][1] = "HP Compaq 6000"
$aMachines[0][2] = "ABC123"
$aMachines[0][3] = "01/01/2001"
$aMachines[0][4] = "Toshiba HDD"
$aMachines[1][0] = "PC02"
$aMachines[1][1] = "HP Compaq 6000"
$aMachines[1][2] = "XYZ456"
$aMachines[1][3] = "01/01/2001"
$aMachines[1][4] = "Toshiba HDD"
;_ArrayDisplay($aMachines)
If Not @error Then
If IsArray($aMachines) Then
$sComputers = _ArrayToString($aMachines, " - ")
$sComputers = StringReplace($sComputers, @CRLF, "|")
;ConsoleWrite($sComputers & @CRLF)
For $i = 0 To UBound($aMachines) - 1
$machine = $aMachines[$i][0]
$model = $aMachines[$i][1]
$serial = $aMachines[$i][2]
$OSInstallDate = $aMachines[$i][3]
$HDD = $aMachines[$i][4]
_GUICtrlListView_AddItem($listComputers, $machine)
_GUICtrlListView_AddSubItem($listComputers, $i, $model, 1)
_GUICtrlListView_AddSubItem($listComputers, $i, $serial, 2)
_GUICtrlListView_AddSubItem($listComputers, $i, $OSInstallDate, 3)
_GUICtrlListView_AddSubItem($listComputers, $i, $OSInstallDate, 3)
_GUICtrlListView_AddSubItem($listComputers, $i, $HDD, 4)
$hImage = _GUIImageList_Create(16, 16)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, $COLOR_YELLOW, 16, 16)) ; yellow
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, $COLOR_GREEN, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, $COLOR_RED, 16, 16))
_GUICtrlListView_SetImageList($listComputers, $hImage, 1)
Next
_GUICtrlListView_SetItemSelected($listComputers, 0)
EndIf
EndIf
EndFunc ;==>LookupButtonPressed
Saludos