Jump to content

Detecting user clicks on ListViewItems


Recommended Posts

as far as Ikno, using the GuiGetMsg() does not return a value when any part of a ListView box is clicked, or a ListViewItem...

My problem is that I need my program when a user clicks one of the items it copies the text and sends it to an inputbox... as far as getting the text and sending it..I have no problem...but how do I detect when a user clicks an item!!!?

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Link to comment
Share on other sites

  • Moderators

GUIRegisterMsg()

Also do a search for "DoubleClick" to see how it's used.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Wow...I am sorry..but I have never messed with API's or DLL structs....so I really understood not much of that I wasnt sure wat u meant by look up dblclik so I used the help in autoit...lost

I thought I was pretty straight forward:

http://www.autoitscript.com/forum/index.ph...ite=DoubleClick

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 1 month later...

as far as Ikno, using the GuiGetMsg() does not return a value when any part of a ListView box is clicked, or a ListViewItem...

My problem is that I need my program when a user clicks one of the items it copies the text and sends it to an inputbox... as far as getting the text and sending it..I have no problem...but how do I detect when a user clicks an item!!!?

Okay, i have an example that i use for single clicks that you might find helpful.

I use it for drive details ina listview. Its gets reused quite a lot.

Clicking on an item in the listview, pastes the info to labels elsewhere on the form.

Should be easy to modify to send data to other controls, just change the references in the GUICtrlSetData lines

for the example:

  • $TabPanel_0_ListView - a ListView control that just happens to be on a tab. It has 5 columns.
  • $TabPanel_0_DriveLabel_2 - a label that displays the contents of the first column.
  • $TabPanel_0_DriveFileSystem_2 = a label that displays the contents of the last column.
Make sure you have: #Include <GuiListView.au3> and #include <GuiConstants.au3> at the top of your code too

CODE

;This locks the mouse click to the ListView control

Case $msg = $GUI_EVENT_PRIMARYDOWN And $TabPanel_0_ListView

;Gets the index of the currently selected listview item.

$CurrentSelection = _GUICtrlListViewGetHotItem($TabPanel_0_ListView)

;Creates an array of the currently selected listview item's column contenst (in my case thats 5 columns of data)

$CurrentSelectionArray = _GUICtrlListViewGetItemTextArray($TabPanel_0_ListView, $CurrentSelection)

;Stops the GUI from crashing if you select a blank part of the ListView control, always handy

If @error Then ContinueCase

;Sets a label that displays the contents of the first column.

GUICtrlSetData($TabPanel_0_DriveLabel_2, $CurrentSelectionArray[1])

;Sets a label that displays the contents of the first column.

GUICtrlSetData($TabPanel_0_DriveFileSystem_2, $CurrentSelectionArray[5])

Edited by frodo
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...