# Annoying ListView thing ! (SOLVED!)

## Recommended Posts

I recently managed to make a ListView sort correctly by clicking on it's columns, it does sort items very well but there's a very annoying thing >_< : every time after the items are sorted out, an item gets focused ! After I click a column, one item gets blue'd, like when its selected, even if its not !

Note that this happens only becuase of this function : _GUICtrlListView_SimpleSort

Instead, the _GUICtrlListView_SortItems function is not doing this , but because of my luck,I must use _GUICtrlListView_SimpleSort ( but it is faster )

Here's my script to test to see what I mean:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
$Form1 = GUICreate("Form1", 383, 307, 192, 124)$ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1,$LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)$ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1)$ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1)$ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1)$ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1) GUISetState(@SW_SHOW) Global$toggle = 1
While 1
$nMsg = GUIGetMsg() Switch$nMsg
Case $GUI_EVENT_CLOSE Exit Case$ListView1
_GUICtrlListView_SimpleSort($ListView1,$toggle, GUICtrlGetState($ListView1)) EndSwitch WEnd How could I get rid of this item focus ? Edited by Rickname ##### Link to post ##### Share on other sites If there aren't many items, i would use and array and then _GUICtrlListView_GetItemFocused($hWnd, $iIndex) if true then _GUICtrlListView_SetItemFocused($hWnd, $iIndex, False) Or _GUICtrlListView_GetItemCount($hWnd)

and unfocus all

_GUICtrlListView_SetItemFocused($hWnd,$iIndex, False)

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

##### Share on other sites

@careca, I tried this and it doesn't work! The _GUICtrlListView_SetItemFocused function doesn't make any effect ! The interesting part is, the function is returning 'True' , but that item still remains blue o_o !

Here's the script :

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
$Form1 = GUICreate("Form1", 383, 307, 192, 124)$ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1,$LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)$ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1)$ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1)$ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1)$ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1) GUISetState(@SW_SHOW) Global$toggle = 1
While 1
$nMsg = GUIGetMsg() Switch$nMsg
Case $GUI_EVENT_CLOSE Exit Case$ListView1
_GUICtrlListView_SimpleSort($ListView1,$toggle, GUICtrlGetState($ListView1))$index = _GUICtrlListView_GetSelectedIndices($Listview1, True) ; get the idex of the selected item from the ListView ;MsgBox(0,"",$index[1])
ConsoleWrite(_GUICtrlListView_SetItemFocused($Listview1,$index[1], False)) ; Unfocus it and display the result
EndSwitch
WEnd
Edited by Rickname
##### Share on other sites

I don't think you can remove the focus color.

The reason why you see the blue line after sorting and before you even touched any row in the Listview is that the focus is put to the first row by default.

I guess that not showing the Blue bar by default on Row 1 is more of an issue.

I have an 'ugly' quick fix to remove the blue focus bar, but...

Case $ListView1 _GUICtrlListView_SimpleSort($ListView1, $toggle, GUICtrlGetState($ListView1))
$cursor = MouseGetCursor() GUISetCursor(16, 1)$aMousePos = MouseGetPos()
MouseClick("left", 320,300, 1, 1)
MouseMove ( $aMousePos[0],$aMousePos[1] , 1 )
_GUICtrlListView_SimpleSort($ListView1,$toggle, GUICtrlGetState($ListView1)) Controlclick($Form1, "", $ListView1) ##### Link to post ##### Share on other sites mikell, Far much better than my mousemove... Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool -------------------- Visually apply effects on an image ##### Link to post ##### Share on other sites Still doesn't work @mikell, the item still remains blue ! lol, Also that MouseClick method ) its even more annoying Thanks anyway Edited by Rickname ##### Link to post ##### Share on other sites Thats it, I finally solved it Here's what I did : after the sorting command, I added this : _GUICtrlListView_SetItemSelected($Listview1, $index[1], False,False) This unselects and unfocuses the selected item from the listview. Here's all the source code #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListView.au3>$Form = GUICreate("Form", 383, 307, 192, 124)
$Listview = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241) GUICtrlSendMsg(-1,$LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1,$LVM_SETCOLUMNWIDTH, 2, 50)

GUICtrlCreateListViewItem("1|5|6", $Listview) GUICtrlCreateListViewItem("2|7|8",$Listview)
GUICtrlCreateListViewItem("3|9|10", $Listview) GUICtrlCreateListViewItem("4|11|12",$Listview)
GUISetState(@SW_SHOW)

Global $toggle = 1 While 1$nMsg = GUIGetMsg()
Switch $nMsg Case$Listview ; sorting function
_GUICtrlListView_SimpleSort($Listview,$toggle, GUICtrlGetState($Listview)) If _GUICtrlListView_GetSelectedCount($Listview) Then ; if is there any item(s) selected, then :
$index = _GUICtrlListView_GetSelectedIndices($Listview, True) ; get the idex of the selected item(s) from the ListView control
For $i = 1 To$index[0]
_GUICtrlListView_SetItemSelected($listview,$index[$i], False,False) ; Unselect them :) Next Endif Case$GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Edited by Rickname
##### Share on other sites

I don't think you understood what i wrote,

i said, in an array, to go thru all items, use: GETItem

_GUICtrlListView_GetItemFocused($hWnd,$iIndex)

if it retrieves true, means it has the focus then SETItem

_GUICtrlListView_SetItemFocused($hWnd,$iIndex, False)

Unfocus it.

Anyway, im glad you sorted it out.

Edited 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

##### Share on other sites

Yes , I did that too, but hadn't work !

Also my method is better, it gets exactly the items that are focused, no need to 'ask' every item from the list if is focused or not

Edited by Rickname

## 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 account

• ### Similar Content

• By Sanja
Hello forum,
I have the problem that I can not use Firefox in combination with WebDriver when using AutoIt on some websites. Of course it does not work with the very website I need it to work with.
As soon as I want to open the desired website, I get the little robot icon which tells me that the "browser is under remote control" and the website stays blank.
I CAN open the website (www.ebay-kleinanzeigen.de) but I get blocked when I want to go to my account, to be precise.

I am using AutoIt 3.3.14.5 I have checked my FireFox version. It is up to date. Also the special browser drivers like gecko etrc. are up to date too and everything works fine with the WebDriver demo.
It seems that another user also had the same problem, but the thread has already been closed and the users solution (setting security lower did not work for me).
I mean I can only choose between "standard", "strict" and "customized". On "customized I unchecked everything but it still would not change anything.
I also have checked Google Chrome and MS Edge. Same result.
I tried swiching profiles (only with FireFox). Same result.
I tried to acess a previously opened FireFox session where I manually logged in by using this code snippet:
_WD_Option('Driver', 'C:\Path\to\the\executable\geckodriver.exe') _WD_Option('DriverParams', '--log trace --connect-existing  --marionette-port 2828') _WD_Option('Port', 4444) Obviously I adjusted the path of the geckodriver.exe but it did not work at all on my computer.
So far my code is really basically nothing but I can not even start to code. I myself am not a real coder and I know only the very basics like loops, conditions and variables.
----------------------------------------
; Script Start #include <Array.au3> #include <AutoItConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <File.au3> #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <StaticConstants.au3> #include "wd_core.au3" #include "wd_helper.au3" #include <WindowsConstants.au3> Local $sDesiredCapabilities,$sSession, $sElement SetupGecko()$_WD_DEBUG = $_WD_DEBUG_None _WD_Startup()$sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.ebay-kleinanzeigen.de/m-meine-anzeigen.html?sort=CREATION_DATE_ASC&keyword=winter") Exit Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace --marionette-port 2828') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "' & "C:/Users/myaccount/AppData/Roaming/Mozilla/Firefox/Profiles/0123456.default-release" & '"],"log": {"level": "trace"}}}}}' EndFunc ;==>SetupGecko Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}' EndFunc ;==>SetupChrome Func SetupEdge() _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace(@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}' EndFunc ;==>SetupEdge -------------------------------------- I left the three setup functions in, because I do not care what browser I use as long as I can start coding. Also, please understand that I am not trying to be lazy here. I do not want someone to code for me. Maybe the problem is very basic, but I just do not know how to eliminate that restriction. Is it something I need to uncheck in the browser settings or is it more complicated? If you need more information, I will be happy to provide those. If somebody has an idea or a solution, I would very much appreciate it. Edit: I am not bothered by the robot icon itself. I do not care about it. If I try to acess my regular ebay account: "https://mesg.ebay.de/mesgweb/ViewMessages/0" it works like a charm despite the notification that the browser is remotely controlled. My problem is, that the first website does not load for some reason ONLY when the browser is remote controlled. • By UEZ This project has been discontinued! Here a small tool I wrote to update my Sysinternal tools collection without the need to download always the whole package or visiting the site to check for updates. I know that there are several tools available (also some tools written in AutoIt) but here another one for the collection. It was good exercise for me to code it. Some files from the live web site cannot be downloaded although they are visible! Here the download link of the source code only: AutoIt Sysinternal Tools Synchronizer v0.99.6 build 2020-09-23 beta.7z (1557 downloads previously) -=> Requires AutoIt version 3.3.13.20 or higher / tested on Win8.1 real machine and some VMs: Win7 / Vista / Win10 Compiled exe only: @MediaFire Just select the Sysinternal Tools folder or create one and press the synchronize button to download the selected items. Click on AutoIt label (near to left upper corner) to open menu. Special thanks to LarsJ, Melba23 and mesale0077 for their help. I've still some ideas to implement which are more gimmick related, so it is not finished yet... If you want to add your language please check out #Region Language. Thanks. Please report any bug or if you have any suggestions. The language of the tool tip from each of the executable in the left list view were automatically created using Google translator and weren't checked for correctness. Br, UEZ • Hi everyone, I have created a ListView that is in a tab, and I want to display an image in that tab, with the ListView on top. However, the image still appears on top of my ListView. If I remove the tabs everything works. I looked at the autoit documentation and the <GuiListView.au3> documentation , I can't figure out how to display a background image, and put on top a ListView, inside a tab. 😥 Here is the code: Opt("GUIOnEventMode", 1)$Form1 = GUICreate($Titre, 700, 627,$Form1Width, $Form1Height); main window$tabulation = GUICtrlCreateTab(148,0,700,580); creating tabs $tab1=GUICtrlCreateTabItem("Tab 1"); first tab GUICtrlSetState(-1,$GUI_SHOW); this tab is selected by default $Pic1 = GUICtrlCreatePic("image.jpg", 0, 30, 700, 627) GUICtrlSetState(-1,$GUI_DISABLE). $idListview = GUICtrlCreateListView("list 1|list 2|list 3", 200, 50, 390, 200) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Thank you in advance. • By DrJohn Hello all. It's me again. I've got a ListView with an associated ImageList to display icons. What I seem to be hung up on is how to keep the ImageList updated to match the ListView as the latter changes. I thought it was the case that the indices of the items in the ListView and those in the ImageList just needed to match. So, for example, if I: Delete an item from the ListView [_GUICtrlListView_DeleteItem()], and also delete the image at the matching index in the ImageList [_GUIImageList_Remove()]. Then add a new item to the end of the ListView [_GUICtrlListView_AddItem()], and correspondingly add an image at the end of the ImageList [_GUIImageList_AddIcon()] Shouldn't everything stay in sync? Here's the code I thought would work: #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <FontConstants.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> Test() func Test()$gui = GUICreate("Test", 400, 300) ; Create ListView $lv = _GUICtrlListView_Create($gui, "", 10, 10, 380, 240, $LVS_DEFAULT) _GUICtrlListView_AddColumn($lv, "Col1", 50) _GUICtrlListView_AddColumn($lv, "Col2", 50) for$i = 0 to 2 $s = StringFormat("%d,1",$i+1) _GUICtrlListView_AddItem($lv,$s, $i)$s = StringFormat("%d,2", $i+1) _GUICtrlListView_AddSubItem($lv, $i,$s, 1) next ; Add ImageList $img_list = _GUIImageList_Create(16, 16, 5, 3) for$i = 0 to 2 $ico = StringFormat("%d.ico",$i+1) _GUIImageList_AddIcon($img_list,$ico) next _GUICtrlListView_SetImageList($lv,$img_list, 1) ; $btn = GUICtrlCreateButton("Test", 10, 260, 60, 30) GUISetState(@SW_SHOW) HotKeySet("^q", Quit) ; Loop until the user exits. while True switch GUIGetMsg() case$GUI_EVENT_CLOSE Exit case $btn ; Remove 2nd list item and image _GUICtrlListView_DeleteItem($lv, 1) _GUIImageList_Remove($img_list, 1) ; Add new item to end of ListView$idx = _GUICtrlListView_AddItem($lv, "foo") _GUICtrlListView_AddSubItem($lv, $idx, "bar", 1) ; Add new image to end of ImageList _GUIImageList_AddIcon($img_list, "5.ico") endswitch wend GUIDelete() endfunc func Quit() Exit endfunc What seems to happen is that when the new item is added to the ListView, its icon is 1.ico (the first item in the ImageList), rather than 5.ico (the newly added item that should be at the end of the ImageList).
Or do I need to re-create the whole ImageList any time the ListView changes?
A zip file is attached that contains the script and also the .ico files, for easier testing.
Thanks!
/John
test.zip

• Hello! Thanks you for looking at my post
**No source code I'm sorry work related can't copy information**
I've been using autoit for about 1 year.
I'm having trouble automating a click on an internet explorer web page and I've tried a lot of examples from help pages and forums already. The object I'm trying to click on isnt always in the same spot so I can't use mouse click or control click, I have tried to use the different get collection options and clickbyname, or index or get object. I'm just struggling.
Description of object I'm trying to click --
HTML Code looks like <a ng-click.. "Click Here" it appears it's just a click able object named "click here" that opens a hidden window by running a script inside the web page. I'm not able to grab the information from the window unless it's open so I have to automate this click somehow.

I understand it's difficult to assist without having something to look at, I apologize for that sincerely and appreciate and assistance and suggestions.
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...