Jump to content
Know_Fear

Selecting Multiple ListView Items with the Mouse

Recommended Posts

Know_Fear
Posted (edited)

So, I have this nicely working script that operates on a ListView - cut / past / copy / delete all work fine.
List View is created with:

 

$LV_List  =    GUICtrlCreateListView("", 5, 45, 602, 400, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($LV_List, BitOR($LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))   ;;;;;;;;;;;;; , $LVS_EX_FULLROWSELECT))


My ListView has 3 columns, the first is a narrow column in which I put the row number, and the other 2 columns contain the data I want to look at and act upon.

This all works, and I can select and act upon single or multiple rows.

But here's the ISSUE ===>  When I use the normal Click-Hold-Drag mouse-rectangle to select the rows I want, ONLY the selected items in Column 1 are "sensitive" to the mouse-rectangle, and only they turn the Selected-Blue-Color.  (However, everything  works as I intend, and my cut / copy / delete stuff acts upon all of the rows that I have selected.)

What I WOULD LIKE ===> To have either all items in the rows, or perhaps just the items in Column 2 (instead of the default Column 1) sensitive to the normal Click-Hold-Drag mouse-rectangle and to turn Selected-Blue-Color.  This would look and feel more "normal", much like how one selects items in MSWindows' "Detailed" file view windows.


(As you can see above, I tried using $LVS_EX_FULLROWSELECT.   As advertised, the entire row turns the Selected-Blue-Color.  The PROBLEM with this is that there is nowhere to start drawing the Mouse Rectangle from.  As soon as one clicks in order to start drawing the rectangle, then ONLY that single row is selected, and no rectangle is drawn.  When using $LVS_EX_FULLROWSELECT, it seems that multiple rows can ONLY be selected by using the keyboard in conjunction with the mouse ... )

 

This isn't a HUGE issue, since the user gets used to using the mouse to select rows based on drawing the rectangle around the item count numbers in Column 1.  But it would be more uniform with most other behaviors that use the mouse to select multiple items if I were able to get a ListView to behave as described above. - Thanks!

 

Edited by Know_Fear

Share this post


Link to post
Share on other sites
Know_Fear

uhg... I edited the above, as  I had written "rows" instead of "columns"....  Hope my question makes more sense now.

Share this post


Link to post
Share on other sites
Know_Fear
Posted (edited)

To illustrate the issue -

 

With this extended style...

$My_List  =    GUICtrlCreateListView("", 5, 45, 602, $Media_Window_Height-50, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($My_List, ($LVS_EX_GRIDLINES)) 
;_GUICtrlListView_SetExtendedListViewStyle($My_List, BITOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))

....here is screenshot of what I get when using the mouse to draw the normal select-rectangle - note that only column 1 (items 5 through 11) change color -

5b353bbd604d4_mouseselect.jpg.f0d89241324f0c125b7283f00b2881f1.jpg

 

 

 

And with FullRowSelect extended style.....

$My_List  =    GUICtrlCreateListView("", 5, 45, 602, $Media_Window_Height-50, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
;_GUICtrlListView_SetExtendedListViewStyle($My_List, ($LVS_EX_GRIDLINES))  
_GUICtrlListView_SetExtendedListViewStyle($My_List, BITOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))

....here is screenshot of what I get  - note that there is NO way to draw a select-rectangle since as soon as one clicks, then one-and-only-one row (row 8 Fountainhead) is selected (multiple items can only be selected using the keyboard and some mouse clicks :(:( ) -

FullRow.jpg.0372aa0d2be513ad6dc9d8de70e62296.jpg

 

 

 

As said above, everything works functionaly.........., but I would like to be able to use the mouse select-rectangle more intuitively and have it select the Titles in column 2 instead of the Item Numbers in column 1....

 

Edited by Know_Fear

Share this post


Link to post
Share on other sites
AutoBert

Can you select multiple filles in explorer only with mouse?

Share this post


Link to post
Share on other sites
Know_Fear
Posted (edited)

Not sure what yo mean AB - do you mean Windows Explorer?  If so, then yes!

 

That is the behavior I am wanting to duplicate for my ListView above - it looks like this (Win7 Windows Explorer...) -

5b363c5129c74_WindowsExplorermultiselect.jpg.6f233c2651fae2165a05f86dcbecbfeb.jpg

Edited by Know_Fear

Share this post


Link to post
Share on other sites
Know_Fear

Anyone?

Share this post


Link to post
Share on other sites
careca
Posted (edited)
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150,BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    Local $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item23|col632|col3433", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("items3|col332|col7533", $idListview)
    GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState(@SW_SHOW)
    GUICtrlSetData($idItem2, "ITEM1")
    GUICtrlSetData($idItem3, "||COL33")
    GUICtrlDelete($idItem1)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)

            Case $idListview
                MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)

        EndSwitch
    WEnd
EndFunc   ;==>Example

Straight from the help file example with just 1 modification.

Edited by careca
  • 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
Know_Fear
Posted (edited)

 

???  Not sure what Question you are addressing careca, but it's not mine :(  Or ?? perhaps there is some difference in the version you are running??  (I am running the most recent  autoit version...)

In any case, the posted example directly above also displays the issue I am trying to get around - i.e., one can NOT use the mouse-click-drag rectangle to select multiple items in the list (unless one starts the click-drag-rectangle in the white space below the last list row -- which is obviously NOT a solution for lists that are longer than the display area).

 

As stated above, I'd like my list-view to behave as standard Windows file select windows - where one starts the mouse-click-drag-rectangle off to the side white space (between the vertical slider bar and the file list), and one can select any number of contiguous items in the file list.

Ideas?

5b4bcf155a725_fileselect.thumb.jpg.0cbd72e74f77cf28eb89ca667982d4cd.jpg

 

Edited by Know_Fear

Share this post


Link to post
Share on other sites
careca
Posted (edited)

exactly, did you try the code i posted? Im also in last version and in win 10.

I see that you tried the code and got the same result.. dunno why

Edited by careca
I read your post again

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
FrancescoDiMuro

@Know_Fear
I just tried the code that @careca posted ( nice job buddy! :) ), and it has the mouse "drag select" items ( every column, not just the columns in your mouse drag ).
Is this what you were trying to do? :)

Best Regards.


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Know_Fear
Posted (edited)

Where are y'all starting the "drag select" rectangle in the posted example?

In the list itself???  ....  Or in the white space below???

Try starting the rectangle IN the list (or generate a longer list that is larger than the display window).  Are you still able to use mouse "drag select" to select more than 1 item?

As said, if we have a full list that is larger than the window, then there is no white space to start the rectangle in.  And only the single item gets selected :(  This is on my Windows 7 and XP machines...

 

 

Edited by Know_Fear

Share this post


Link to post
Share on other sites
FrancescoDiMuro
2 minutes ago, Know_Fear said:

In the list itself???

Right here! :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
careca

Either in or off the list, it's the same.


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
Know_Fear
Posted (edited)

Thanks careca - I very much appreciate the replies.

 

I need to figure out what problem I am trying to solve, either an autoit behavior, or a quirk in my win7 and xp systems.........On the code posted  below, Is anyone else out there seeing the same behavior as ether careca (can "drag select" MULTIPLE lines anywhere in a listview)........ or the behavior I see (can only select 1 item with the mouse) ???

 

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150,BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    Local $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
    Local $idItem4 = GUICtrlCreateListViewItem("item23|col632|col3433", $idListview)
    Local $idItem5 = GUICtrlCreateListViewItem("items3|col332|col7533", $idListview)
    Local $idItem6 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
    Local $idItem7 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
    Local $idItem8 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
    Local $idItem9 = GUICtrlCreateListViewItem("item23|col632|col3433", $idListview)
    Local $idItem10 = GUICtrlCreateListViewItem("items3|col332|col7533", $idListview)
    GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState(@SW_SHOW)
    GUICtrlSetData($idItem2, "ITEM1")
    GUICtrlSetData($idItem3, "||COL33")
    GUICtrlDelete($idItem1)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)

            Case $idListview
                MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)

        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Edited by Know_Fear

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@Know_Fear

I can select multiple items with mouse drag and drop :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Know_Fear

I'm sorry Franscesco - I can't tell what it is you're trying to say.  Can you help me out with a more straightforward answer regarding selection of multiple items with mouse "drag-select" in a full listview?

Share this post


Link to post
Share on other sites
FrancescoDiMuro

Is this what are you trying to do?

image.png.347bb28fe80bab2adea91a19f69a0426.png


 


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Know_Fear

Well no....  

That's the effect I want, and sorry if I am not being exactly clear, but you are starting your rectangle in the white space to the right of col 3.

My listview in posts 3 and 4 above are too wide to have whitespace on the right, and too long to have whitepace on the bottom.  As said, there is NO place to start one's "drag-select" rectangle....

Try this one, and tell me if you can select more than 1 line with  mouse "drag-select":

 

#include <GUIConstantsEx.au3>
;#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    Local $idListview = GUICtrlCreateListView("col1|col2|col3|col4|co5|col6|col7", 10, 10, 200, 150,BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    Local $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23|col22|col23|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13|col22|col23|col22|col23", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33|col22|col23|col22|col23", $idListview)
    Local $idItem4 = GUICtrlCreateListViewItem("item23|col632|col3433|col22|col23|col22|col23", $idListview)
    Local $idItem5 = GUICtrlCreateListViewItem("items3|col332|col7533|col22|col23|col22|col23", $idListview)
    Local $idItem6 = GUICtrlCreateListViewItem("item2|col22|col23|col22|col23|col22|col23", $idListview)
    Local $idItem7 = GUICtrlCreateListViewItem("item1|col12|col13|col22|col23|col22|col23", $idListview)
    Local $idItem8 = GUICtrlCreateListViewItem("item3|col32|col33|col22|col23|col22|col23", $idListview)
    Local $idItem9 = GUICtrlCreateListViewItem("item23|col632|col3433|col22|col23|col22|col23", $idListview)
    Local $idItem10 = GUICtrlCreateListViewItem("items3|col332|col7533|col22|col23|col22|col23", $idListview)
    GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState(@SW_SHOW)
    GUICtrlSetData($idItem2, "ITEM1")
    GUICtrlSetData($idItem3, "||COL33")
    GUICtrlDelete($idItem1)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)

            Case $idListview
                MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)

        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites
LarsJ

Know_Fear, It's a Windows 8 or 10 feature that does not work on previous Windows versions. It does not work on your Windows 7 or XP PCs. I see exactly the same behaviour on my Windows 7 PC as you do.

  • Like 1

Share this post


Link to post
Share on other sites
careca

@Know_Fear: Either with the code you posted, or the one i posted, the only way i can drag-select multiple rows, is if i start from the bottom of the list, or the side if possible, in the part that doesn't have any item, anywhere else, it tries to drag the item itself. I could swear it worked in items themselves before..


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

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

×