Jump to content
Sign in to follow this  
WiseGuy

Send key down, do stuff, send key up

Recommended Posts

WiseGuy

Hello and thank you for reading my question,

I am pretty new to this so it probably not a very hard question but here goes: My program does a bunch of stuff which causes items to appear in a listbox. The number of items in the listbox can range anywhere from zero to five and need to be deleted. What I want to do is this:

{hold shift key down}

left click item 1

left click item 2

left click item 3

left click item 4

left click item 5

{let shift go}

click delete button

Holding the shift button down while clicking will allow me to select multiple items at once and have them deleted. The reason I want to do it like this rather than delete them one at a time is because the listbox is connected to a remote database and the time it takes to respond to a command varies, especially when it is very busy.

Now I have scoured the AutoIt help but I have only been able to find functions that will hold it down for a while before executing the next command or can tell me wether or not a key is being held down but not actually one that allows me to send the shift down, do stuff, send shift up. Any and all help will be much appreciated.

Share this post


Link to post
Share on other sites
WiseGuy

Terribly sorry, obviously as soon as I post it and look around the help some more I find my answer. Thank you for looking though.

Send("{shiftdown}")

left click item 1

left click item 2

left click item 3

left click item 4

left click item 5

Send("{shiftup}")

click delete button

Edited by WiseGuy

Share this post


Link to post
Share on other sites
BlueC

Send("{SHIFTDOWN}")

.

.

.

Send("{SHIFTUP}")

Share this post


Link to post
Share on other sites
somdcomputerguy

@WiseGuy - you do realize that the control key is meant to be used for multiple selections, ya? The shift key, while it can be used to specifically multi select items, can also be used to select a range of items. So you could do this:

shiftdown

click item 1

click item 5

shiftup

Then all 5 (1, 2, 3, 4, 5) items would be selected. This 'example' assumes there is 5 items, but it would work the same if there was 50. This would save some time, whether you or AutoIt is doing the clicking. If AutoIt is doing the clicking, this would mean less code. Although you could use a For..Next loop to individually click items (if they're all in a 'row' that is).


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
WiseGuy

Well, the reason I do it like this is because sometimes it'll just come up with say 2 items and then it would click on nothing and as such nothing will happen selectionwise except the first one, which would defeat the purpose. 5 items is however the max it can generate. I am aware that ctrl is generally used for selecting individual items but here it is shift, don't ask me why, it just is. Thanks for thinking along though :oops:

Edited by WiseGuy

Share this post


Link to post
Share on other sites
somdcomputerguy

You bet. Good luck with your project.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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  

×