Page 1 of 1

Send multiple keys?

Posted: 28 Dec 2013, 20:37
by garretthylltun
Greetings and thanks in advance for any info,

Help file leaves me confused. I want to send LCtrl + LShift + ~ to a specific window and then wait like 10 milliseconds and then send a string of text, wait another 10 milliseconds and then send the Enter key. My problem is that the help file leaves me a bit confused on sending multiple keys at once. Do I send it just like this:

Code: Select all

Send ahk_class ClassName {LCtrl}{LShift}~
Thanks,
~Garrett

Re: Send multiple keys?

Posted: 28 Dec 2013, 21:20
by FanaticGuru
There are two methods for sending a key with modifiers held down.

If only one key is getting sent then you can use the modifier symbols ! + ^ #

If more than one key needs to be sent with modifiers held down or you need to indicate left or right modifiers than you can use the Down and Up options after the names of the modifier keys.

I commented out the Down/Up method in the script below.

Code: Select all

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

f1::
	StringofText := "Some Text to Send"
	Send ^+~	; Holds down Control ^ and Shift + while sending ~ (!+^# only affect 1 character before they are released)
;	Send {LCtrl Down}{LShift Down}~{LCtrl Up}{LShift Up}  ; Could be any number of keys between the Down and Up
	Sleep 10
	Send % StringofText
	Sleep 10
	Send {Enter}
return
FG

Re: Send multiple keys?

Posted: 30 Dec 2013, 15:20
by Wade Hatler
Good explanation. The only thing I would add is that if the string of text might contain anything that could be a special character, such as ^!#+{}, the second Send should really be a SendRaw, which sends the string as raw text without special processing , or Send {Raw} which disables special processing for the remainder of that Send command.