Jump to content
Sign in to follow this  
Rickname

Annoying ListView thing ! (SOLVED!)

Recommended Posts

Rickname

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

Share this post


Link to post
Share on other sites
careca

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)

  • Like 1

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

Share this post


Link to post
Share on other sites
Rickname

@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 this post


Link to post
Share on other sites
GreenCan

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 )
GUISetCursor($cursor)

...I must admit that i would never do that myself... :shifty:

GreenCan


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

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Share this post


Link to post
Share on other sites
GreenCan

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

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Share this post


Link to post
Share on other sites
Rickname

Still doesn't work @mikell, the item still remains blue ! lol,

Also that MouseClick method :)) its even more annoying :) Thanks anyway ;)

Edited by Rickname

Share this post


Link to post
Share on other sites
Rickname

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 this post


Link to post
Share on other sites
careca

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

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

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.

Firefox Profile Backup - Backup/restore previously saved profile.

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

Share this post


Link to post
Share on other sites
Rickname

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

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • nooneclose
      By nooneclose
      Hello again, I am in phase two of my help bot. I cannot figure out how to properly code Autoit to click on a webpage button using the I.E UDF. I want to click on the button that I have attached as an image. This button does not have a name but it has an ID. Here is the HTML code for this button that I found using chromes developer inspector.
      HTML Code: 
      <img role="button" tabindex="-1" id="toolactions_INSERT-tbb_image" src="nav_icon_insertkey.gif" alt="New Work Order CTRL+ALT+I" draggable="false"> Here is the code that I have so far:
      ;******************************************************************************* ; Opens IE and fill out a New Workorder ;******************************************************************************* ; Start IE at the ** Tracking Application in ****** $oIE = _IECreate("https:I_am_Bound_by_my_company_to_not_reveal_this_webpage") ; Wait for a browser page load to complete _IELoadWait($oIE) Sleep(6000) ; Store the field names where the important data will be sent Local $nWorkOrderB = _IEGetObjById($oIE, "toolactions_INSERT-tbb_image") _IEAction($nWorkOrderB, "click")  I want my program to click on the button that looks like a piece of paper with a blue # 
      (For those wondering, I am allowed to send images just not the URL.) 
      As always any help would be appreciated. 

    • nooneclose
      By nooneclose
      How to use _Excel_RangeSort to sort my excel file by three different headers Column A1, B1, and C1 have headers on which I want to sort by. The headers on which I want to sort are department, employee type, and name.
      I still really new to AutoIt so I do not actually know how to properly start this line or lines of code, to be honest. The example code is the best I can do.
      _Excel_RangeSort($OpenWorkbook, Default, "A1:C1", "1:1", $xlDescending, Default, $xlYes, Default, $xlSortRows) I just need to sort by those three headers in that order of department, employee type, and name, plus in descending order.
       
      any and all help would be greatly appreciated.  Thank you!
    • Haselnuzz
      By Haselnuzz
      Hi and Hello from a Noob..:-)
      i have a very weird problem. I fill up a 2d array with a)numbers and b)letters from A-Z, so 2 columns. This works absolutely perfect. But as soon as i try to sort them (numbers ascending) the array ends up in some kind of "String-sortation". What exactly am i doin wrong? To make it easy, i post below the piece of code, which i am talking about. Hope that someone can help me out.
      Func Analyse()
          Local $BasisArray[0]
          Local $aFill = "A" & "|B" & "|C" & "|D" & "|E" & "|F" & "|G" & "|H" & "|I" & "|J" & "|K" & "|L" & "|M" & "|N" & "|O" & "|P" & "|Q" & "|R" & "|S" & "|T" & "|U" & "|V" & "|W" & "|X" & "|Y" & "|Z"
          _ArrayAdd ($BasisArray, $afill)
          Local $FreqArray[0][2]=[[]]
       
          $row = 0

          For $i = 0 to 25
       
              $fummel = _ArrayToString ($BasisArray, ":" , $row, $row)
              $readout = _GUICtrlRichEdit_GetText ($hRichEdit)
              $anzAs = stringreplace ($readout, $fummel, $fummel)
              $extended = @extended
              $FreqFill = $extended & "|" & $fummel
              _ArrayAdd($FreqArray, $FreqFill)
       
              $row = $row + 1
          Next
          _ArrayDisplay($FreqArray, "2D - Item delimited")
          _ArraySort($FreqArray)
          _ArrayDisplay($FreqArray, "bla")
       
       
      Thanks for helping me,
       
      Cheers,
       
      Patrick
    • careca
      By careca
      Hi, i have this array of numbers in the form of strings, and i assumed _arraysort would sort them out, but theres no option to do it numerically, so i had to do it another way, seems clumsy, what am i missing here? There's for sure a better way to sort this out numerically right? _arraysort is doing a mess with the numbers, it goes like this: 35,45,50,42,48,54
      #include<Array.au3> Local $ID, $AM Local $FO = Fileopen('mult.txt') Local $FR = FileReadToArray($FO) FileClose($FO) _ArrayDisplay($FR) For $d = 0 To UBound($FR) $AM = _ArrayMin($FR, 1) ConsoleWrite($AM &@CRLF) $ID = _ArraySearch($FR, $AM) _ArrayDelete($FR, $ID) Next So this way i retrieve the lowest number and then delete it from the array, what would you do?
      mult.txt
×