Jump to content

Send key down, do stuff, send key up


Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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