Jump to content

Sorting another Program's List


middae
 Share

Recommended Posts

So I've looked through help file, and ran over the forum; but haven't found an answer (or didn't see it) to the following question:

ProgramA (not an AutoIt gui) has a listbox, and I have the $hwnd to that listbox.

This list has several columns with headers.

Is there a way to send a command, besides mouseclicking, to Sort the list by the Second column?

Link to comment
Share on other sites

I'm hoping I'm not relegated to OCRing across the screen until I find a good pxchksum and then mouseclicking there. =/

_GuiCtrlListBox_Sort doesn't offer a way to sort by column. =/

It's probably ListView and not Listbox.

It should be possible by sending WM_NOTIFY message with properly filled struct NMLISTVIEW as parameter (pointer).

Here is piece of code from one of my projects.

Here I need to sort my ListView at startup by first column so I call this function

Func DoSort()
    $struct_NMLISTVIEW = DllStructCreate("hwnd;uint;uint;int;int;uint;uint;uint;int;int;int")
    DllStructSetData($struct_NMLISTVIEW,1,GUICtrlGetHandle($ListView1))
    DllStructSetData($struct_NMLISTVIEW,2,$ListView1)
    DllStructSetData($struct_NMLISTVIEW,3,$LVN_COLUMNCLICK)
    DllStructSetData($struct_NMLISTVIEW,4,-1) ; item = -1
    DllStructSetData($struct_NMLISTVIEW,5,0) ; subitem=0

    _SendMessage($Form1, $WM_NOTIFY, $ListView1, DllStructGetPtr($struct_NMLISTVIEW))
    $struct_NMLISTVIEW = 0
EndFunc
Link to comment
Share on other sites

Yes, sorry, I get my ListBox and ListView mixed up. It's a ListView.

ColA | ColB | ColC | ColdD

Data | Data1 | Data | Data

Data | Data2 | Data | Data

Data | Data3 | Data | Data

I'm trying to click Column Header (or send some Sort_Descending command) for ColB to make it in Descending order

ColA | ColB | ColC | ColdD

Data | Data3 | Data | Data

Data | Data2 | Data | Data

Data | Data1 | Data | Data

Reading your code, I assume $Struct is a created type, and that the uint's are ..how many columns the listview has?

Link to comment
Share on other sites

Reading your code, I assume $Struct is a created type, and that the uint's are ..how many columns the listview has?

No. These uints must stay as they are without any change.

Just modify DllStructSetData part.

Also notice my example is for sending message to ListView inside my own GUI.

For external GUI you probably must allocate memory inside external application memory space

and copy structure content into it.

Search forum for more details about these techniques. You may also look at sources of ListView UDFs there are very nice examples of sending messages to ListView controls inside external applications.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...