Moving Mouse Cursor To Specific Text Within Listview Control

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Rips
Newbie
Posts: 4
Joined: Tue Jan 29, 2008 11:36 pm

Moving Mouse Cursor To Specific Text Within Listview Control

Post by Rips » Sun Feb 03, 2008 11:54 pm

Is there a way to look for specific text within a listview control, and if found, move the cursor on top of this text?

I am trying to search through a list of rows (would could be quite a long list) to find a value (within a specific column) that matches a user input. If found, I want to right click on this value to bring up it's popup menu.

Cheers

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 04, 2008 8:08 am

GetListItem will return the index in the list of a specified piece of text. So you could use that to get the index and then you know how many rows to move down from the top (I would use key strokes to do that rather than mouse events).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Rips
Newbie
Posts: 4
Joined: Tue Jan 29, 2008 11:36 pm

Post by Rips » Wed Feb 06, 2008 5:57 am

Thanks for the response, however, my problem is that I don't think it is a standard windows listview control. I think the control is custom written and therefore the GetListItem doesn't seem to be working for me. It keeps returning a value of 0.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Feb 06, 2008 1:31 pm

If it's non-standard then GetListItem won't work and we probably can't use Win32 API calls either.

If the text is always visible then you might be able to use the GetTextInRect function. Set up a loop that looks at a rectangle representing a row in the list. You only need do it once and offset the y position each time as the loop iterates, so that you end up scanning each row.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts