Sign in to follow this  
Followers 0
Charly3307

Double-click on a listview item

5 posts in this topic

#1 ·  Posted (edited)

I'm trying to double-click on a listview item and don't find how. I call the Find printer window, search for the wanted printer then I need to double-click on the listview item to install it but can't find how. Here is the code I use.

Func InstallPrinters($PrinterName)
   ShellExecute("C:Program Files (x86)BAAD Printer LookupPrinters.qds")
  

   WinWaitActive("Find Printers")
  

   $PrinterWindowHandle = WinGetHandle("Find Printers") ;Get handle on Find printer window
  

   ControlSetText($PrinterWindowHandle,"","[CLASS:Edit; INSTANCE:1]",$PrinterName) ; Put printer number into search field
  

   $ListViewHandle = ControlGetHandle($PrinterWindowHandle,"","[CLASS:SysListView32; INSTANCE:7]") ;Get handle on the listview
  

   ;****** Would like to double-click on the item in the listview here *******
EndFunc

 

Any help will be appreciated.

 

Got some new progress. I have change the code to right-click instead of left-click to get a contextual menu and see were it click. It should click on the first item but it click on the top-left coner of the listview what ever the item number I choose. Here is my code.

Func InstallPrinters($PrinterName)
   ShellExecute("C:Program Files (x86)BAAD Printer LookupPrinters.qds")
   WinWaitActive("Find Printers")
   $PrinterWindowHandle = WinGetHandle("Find Printers") ;Get handle on Find printer window
   GUICtrlSetState($PrinterWindowHandle,$GUI_FOCUS)
   ControlSetText($PrinterWindowHandle,"","[CLASS:Edit; INSTANCE:1]",$PrinterName) ; Put printer number into search field
   WinWait("Find Printers","",2)
   $ListViewHandle = ControlGetHandle($PrinterWindowHandle,"","[CLASS:SysListView32; INSTANCE:7]") ;Get handle on the listview
   if @error Then
         ; add error handling here

   Else   

    _GUICtrlListView_ClickItem($ListViewHandle, 1, "right", True, 1) ;Click on first item in listview, does not work
   EndIf
EndFunc

Edited by Charly3307

Share this post


Link to post
Share on other sites



Dear Charly3307,

I have recently started using AutoIt and I came across your post. I am also trying to automate a listview.

According to the documentation that comes with AutoIt3, the 2nd parameter ($iIndex) is the zero based index of the item.

so to click on the 1st item you need:

_GUICtrlListView_ClickItem($ListViewHandle, 0, "right", True, 1)

instead of

_GUICtrlListView_ClickItem($ListViewHandle, 1, "right", True, 1) ;Click on first item in listview, does not work

Best regards

philking

Share this post


Link to post
Share on other sites

?

$ListViewHandle = ControlGetHandle($PrinterWindowHandle, "", "[CLASS:SysListView32; INSTANCE:7]")
ControlListView($PrinterWindowHandle, "", $ListViewHandle, "Select", 0)
ControlSend($PrinterWindowHandle, "", $ListViewHandle, "{enter}")

Share this post


Link to post
Share on other sites

Dear Charly3307,

I have recently started using AutoIt and I came across your post. I am also trying to automate a listview.

According to the documentation that comes with AutoIt3, the 2nd parameter ($iIndex) is the zero based index of the item.

so to click on the 1st item you need:

_GUICtrlListView_ClickItem($ListViewHandle, 0, "right", True, 1)

instead of

_GUICtrlListView_ClickItem($ListViewHandle, 1, "right", True, 1) ;Click on first item in listview, does not work

Best regards

philking

You know this guy has not been on since February 6th? Odds are he may never be back. 

Necro posting ...... look at the date of when the post was before you answer back.

Share this post


Link to post
Share on other sites

sh*t, I didn't pay attention to that ...

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
Sign in to follow this  
Followers 0