Jump to content

Send keys to the selected item in listview control


 Share

Recommended Posts

Dear friends and respected seniors,

                                I am trying to send keys to the selected item in a listview control in a window, but with no success. :sweating:  I know I am making some mistake, but I am not able to figure it out. :'(

This is the code I am using

; get window's handle
Local $a = WinGetHandle( "My Program" )

; set focus on that window
 WinActivate($a);

; get the listview control's handle which is in that window
Local $b = ControlGetHandle($a,"",2111)

; set focus on that listview control
ControlFocus($a,"",2111);

; clear all selections on that listview control
ControlListView($a,"",$b,"SelectClear");
sleep(1000);

; select second item from that listview control
ControlListView($a,"",$b,"Select", 1 )
sleep(1000);

; send the ENTER key to that selected item in listview control
send("{Enter}")  ; not working
; OR
ControlSend($a,"",$b,"{ENTER}")  ; not working

Can anyone please kindly guide me and help me with this problem. :)
Awaiting your replies, :)
Thank you. 

Link to comment
Share on other sites

  • 1 month later...

Something like this usually works for me:

ControlListView($hWnd, "", "SysListView321", "Select", $k, $k)
ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:1]")

Really i think you should check the control id. Try this "SysListView321"

What does it show as the ID with the info tool?

Spoiler

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.

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

Link to comment
Share on other sites

Thanks Careca, :)

I tried ur code, but it still clicks random items from the list, n not the one that i select programmatically :sweating:

the control id is 2111

 

this is the code that i tried now

;selecting the 2nd item from the list
ControlListView($a, "", "[CLASS:SysListView32; INSTANCE:1]", "Select", 1)

;but this double clicks a random item from the list :(
ControlClick($a, "", 2111,"left",2)

It seems that i will have to create a GUI :(

Link to comment
Share on other sites

can we reproduce the issue somewhere?

note that i posted

"Select", $k, $k)

because select can take 2 optional params.

and

SysListView321

not 32. try without instance 1 and with 321 instead of 32.

Spoiler

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.

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

Link to comment
Share on other sites

Thanks Careca, :)

I tried syslistview32 but it didnt work , so i used SysListView323 as the autoit tool was showing ClassnameNN: SysListView323 :)

this is the code that i tried now

;working :)
;selecting the 1st item from the list
ControlListView($a, "", "SysListView323", "Select", 0,0)


Sleep(2000)


; not working :|
; but these 2 codes still double click a random item from the list and not the one selected by the above code

ControlClick($a, "", "SysListView323","left",2)

; OR

ControlClick($a, "", 2111,"left",2)

I will try to make a GUI :) 

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...