Sign in to follow this  
Followers 0
gredo

Keypress + Click

7 posts in this topic

I want to do this: Hold the CTRL key, then click somewhere and then release the CTRL key (or let it hold it forever I don't care). Any ideas?

Thank you in advance!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Send("{Ctrldown}")
Mouseclick("left", x, y)
Send("{Ctrlup}")

was that it?

Edited by rrrm99

Share this post


Link to post
Share on other sites

From the pages of the Help File (Function Reference>Keyboard Control>Send):

Function Reference

Send

--------------------------------------------------------------------------------

Sends simulated keystrokes to the active window.

Send ( "keys" [, flag] )

Parameters

keys The sequence of keys to send.

flag [optional] Changes how "keys" is processed:

flag = 0 (default), Text contains special characters like + and ! to indicate SHIFT and ALT key-presses.

flag = 1, keys are sent raw.

Return Value

None.

Remarks

See the Appendix for some tips on using Send. AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to send (see {ASC} at the bottom of the table below).

The "Send" command syntax is similar to that of ScriptIt and the Visual Basic "SendKeys" command. Characters are sent as written with the exception of the following characters:

'!'

This tells AutoIt to send an ALT keystroke, therefore Send("This is text!a") would send the keys "This is text" and then press "ALT+a".

N.B. Some programs are very choosy about capital letters and ALT keys, i.e. "!A" is different to "!a". The first says ALT+SHIFT+A, the second is ALT+a. If in doubt, use lowercase!

'+'

This tells AutoIt to send a SHIFT keystroke, therefore Send("Hell+o") would send the text "HellO". Send("!+a") would send "ALT+SHIFT+a".

'^'

This tells AutoIt to send a CONTROL keystroke, therefore Send("^!a") would send "CTRL+ALT+a".

N.B. Some programs are very choosy about capital letters and CTRL keys, i.e. "^A" is different to "^a". The first says CTRL+SHIFT+A, the second is CTRL+a. If in doubt, use lowercase!

'#'

The hash now sends a Windows keystroke; therefore, Send("#r") would send Win+r which launches the Run dialog box.

You can set SendCapslockMode to make CAPS LOCK disabled at the start of a Send operation and restored upon completion.

However, if a user is holding down the Shift key when a Send function begins, text may be sent in uppercase.

One workaround is to Send("{SHIFTDOWN}{SHIFTUP}") before the other Send operations.

Certain keyboard as the Czech one send different characters when using the Shift Key or being in CAPS LOCK enabled and sending a char. Due to the send AutoIt implementation the CAPS LOCKed char will be sent as Shifted one so it will not work.

Certain special keys can be sent and should be enclosed in braces:

N.B. Windows does not allow the simulation of the "CTRL-ALT-DEL" combination!

Send Command (if zero flag) Resulting Keypress

{!} !

{#} #

{+} +

{^} ^

{{} {

{}} }

{SPACE} SPACE

{ENTER} ENTER key on the main keyboard

{ALT} ALT

{BACKSPACE} or {BS} BACKSPACE

{DELETE} or {DEL} DELETE

{UP} Up arrow

{DOWN} Down arrow

{LEFT} Left arrow

{RIGHT} Right arrow

{HOME} HOME

{END} END

{ESCAPE} or {ESC} ESCAPE

{INSERT} or {INS} INS

{PGUP} PageUp

{PGDN} PageDown

{F1} - {F12} Function keys

{TAB} TAB

{PRINTSCREEN} Print Screen key

{LWIN} Left Windows key

{RWIN} Right Windows key

{NUMLOCK on} NUMLOCK (on/off/toggle)

{CAPSLOCK off} CAPSLOCK (on/off/toggle)

{SCROLLLOCK toggle} SCROLLLOCK (on/off/toggle)

{BREAK} for Ctrl+Break processing

{PAUSE} PAUSE

{NUMPAD0} - {NUMPAD9} Numpad digits

{NUMPADMULT} Numpad Multiply

{NUMPADADD} Numpad Add

{NUMPADSUB} Numpad Subtract

{NUMPADDIV} Numpad Divide

{NUMPADDOT} Numpad period

{NUMPADENTER} Enter key on the numpad

{APPSKEY} Windows App key

{LALT} Left ALT key

{RALT} Right ALT key

{LCTRL} Left CTRL key

{RCTRL} Right CTRL key

{LSHIFT} Left Shift key

{RSHIFT} Right Shift key

{SLEEP} Computer SLEEP key

{ALTDOWN} Holds the ALT key down until {ALTUP} is sent

{SHIFTDOWN} Holds the SHIFT key down until {SHIFTUP} is sent

{CTRLDOWN} Holds the CTRL key down until {CTRLUP} is sent

{LWINDOWN} Holds the left Windows key down until {LWINUP} is sent

{RWINDOWN} Holds the right Windows key down until {RWINUP} is sent

Share this post


Link to post
Share on other sites

you may want to view ControlSend is very useful especially foreground

Share this post


Link to post
Share on other sites

I keep the help files open forever but I just didn't notice this CTRLDOWN thing. Thank you all for helping!

Share this post


Link to post
Share on other sites

open scite and press f1

Share this post


Link to post
Share on other sites

Send("{Ctrldown}")
Mouseclick("left", x, y)
Send("{Ctrlup}")

was that it?

I recently tried something similar to this to hold down the [Alt] key while clicking on a save button, which in the application in question forces certain additional options to be saved. This method was not working for me until I added "Sleep(100)" after the Mouseclick function (actually, I was using a ControlClick, but it's the same idea).

After I figured this out, I realized this was necessary to ensure that the [Alt] key stayed down long enough after the click for the program I was controlling to register it. I thought I might save someone else some time by pointing this out.

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