Jump to content

Recommended Posts

Posted

Hi

I'm trying to click on an element in a row on a SysListView321 control where all the rows are not visible unless you scroll down.

Is this possible

My code is as follows:

$CHndl = ControlGetHandle("ABC", "", "SysListView321")
_GUICtrlListView_ClickItem($CHndl, 19, "left", False, 2)

The list view has 30 items on it and row 19 is not directly visible - unless you scroll down the page.

Any help or thoughts would be appreciated - I've dug through the forums and can't find anything addressing this question.

Posted

How did you create your "SysListView321"?

Did you create it with GUICtrlCreateListView or _GUICtrlListView_Create?

When you say "click" an item, what exactly do you mean? Do you want that item 'highlighted', to extract the data from that item, etc...

If you try to fail and succeed which have you done?AutoIt Forum Search

Posted

The SysListView321 is a listview that already exists in an externally running program - a window with a listview in it.

I can apply all the _GuictrlListView commands on it, such as reading it, clicking on the visible rows etc and they work fine - but when I try double clicking on a row which is not visible, ie you have to scroll down the listview to see it, it doesn't work. if I maximise the program, so more of the listview is visible, it works. But I don't want to make the program visible, maximise it, and then click it, as there are lots of rows that are still not visible through this route - so scrolling may have to be done as a last resort, but it is a terribly ugly solution.

When I say click it, I mean double click a row so that it opens another window.

Posted (edited)

Hopefully this will give you somewhat of a starting point.

Took parts from another script I was working on.

This is just an example for selecting a specific item in the "SysListView321" of TaskManager.

Since my machine is running McAfee, I simply had it search for the entry of "mcshield.exe" in TaskManager.

It will select/highlight the item

Right click once on the item (since taskmgr doesn't have a left-click option on those items)

It will also list the line in which it found "mcshield.exe"

#include <GUIListView.au3>

Global  $APP = "Windows Task Manager"
ShellExecute("taskmgr",'',@SystemDir,'open',@SW_SHOW)
Do
Until WinExists($APP,"")
WinActivate($APP,"")

Local $hWnd = ControlGetHandle($APP,"","SysListView321")
$iCount = ControlListView($APP,"","SysListView321","GetItemCount")
For $i = 0 To $iCount
    Local $val = _GUICtrlListView_GetItemText($hWnd,$i)
    If $val = "mcshield.exe" Then
        _GUICtrlListView_ClickItem($hWnd,$i,"right",False,1)                
        ConsoleWrite("Item located at: " & $i & @CRLF)
        ExitLoop
    EndIf
Next
Sleep(5000)
WinClose($APP,"")

Exit

Edit:

Since you are basically looking to select a specific item by count, you should be able to get away with this:

#include <GUIListView.au3>

Global    $APP = "Windows Task Manager"
ShellExecute("taskmgr",'',@SystemDir,'open',@SW_SHOW)
Do
Until WinExists($APP,"")
WinActivate($APP,"")

Local $hWnd = ControlGetHandle($APP,"","SysListView321")
_GUICtrlListView_ClickItem($hWnd,19,'right',True,1)
Sleep(5000)
WinClose($APP,"")
Exit
Edited by Country73

If you try to fail and succeed which have you done?AutoIt Forum Search

Posted

Thanks for the code Country - the problem I have is that the click doesn't work when item no 19 is not visible on the screen

_GUICtrlListView_SetItemSelected($hListView, -1, False)
_GUICtrlListView_SetItemSelected($hListView, 19, True)
ControlSend($hListView, "", $hListView, "{ENTER}")

I see fascists...

Posted

Is _GUICtrlListView_ClickItem meant to work on a minimized or hidden gui? I can't seem to get it to work when the gui is minimized - it works fine when it is maximized - can't also seem to see any answers on any of the forums either...

Posted

Have you tried using _GUICtrlListView_EnsureVisible on the listview item?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

I have BrewmanNH - it does not seem to work - the program just exits at the point. If I comment out the ensure_visible line, it continues and @error is 0 after the clickitem call... however it does not select the item in the listview which is simply minimized - if it is not minimized, it is selected ok. Is that how the function clickitem is meant to work - it doesn't seem right...

$CHndl = ControlGetHandle("Identity Cloaker", "", "SysListView321")
   _GUICtrlListView_EnsureVisible($CHndl, $row - 1)
   _GUICtrlListView_ClickItem($CHndl, $row - 1, "left", False, 2)

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
  • Recently Browsing   0 members

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