Press key combination

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Press key combination

09 Feb 2015, 04:55

Hi forum,

I can't believe myself, I've been searching Autohotkey help and the web for like half an hour, but I can't seem to find the explanation what syntax has to be used to send an arbitrary key combination.

For example, I want to send the combination of Left Control and left Windows Key if a certain key is pressed.

So please, where in the help file is the general description of how to send key combinations?
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Press key combination

09 Feb 2015, 05:59

Hotkeys, KeyList & Remap
eg from Helpfile

Code: Select all

XButton2::^LButton    ;Makes the fifth mouse button (XButton2) produce Control-LeftClick.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Press key combination

09 Feb 2015, 06:01

Thanks, but I'm looking for the general case, not the Ctrl/Shift/Alt prefixes.
For example, I want to send the combination of Left Control and left Windows Key if a certain key is pressed.
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Press key combination

09 Feb 2015, 06:12

then use Send command
look it and read it in the help file, you'll find what you need
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Press key combination

09 Feb 2015, 06:27

Sorry but I can't find anything in the helpfile as I said, also not on the "send" page of it.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Press key combination

09 Feb 2015, 06:35

Send

Code: Select all

{LControl} or {LCtrl}    ; Left CONTROL key (technical info: sends the left virtual key rather than the neutral one)
{LWin}                   ; Left Windows key[
What is in your example "a certain key"???
Did you mean "press any key" or a special key like "K" on your keyboard?
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Press key combination

09 Feb 2015, 06:40

Check this

Code: Select all

return

a::
Send {LControl}{LWin}
return
Change the key "a" for the key you need.

Greetings.
Everything is possible!
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Press key combination

09 Feb 2015, 06:50

I think the example of LControl and LWin has confused the issue.

I believe this states the problem correctly: If a user presses the a key, how can I send the b key while simultaneously holding down the c key? (i.e., not b then c)
Last edited by boiler on 09 Feb 2015, 06:53, edited 1 time in total.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Press key combination

09 Feb 2015, 06:53

Code: Select all

a² + b² = c²
( sorry :D )
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Press key combination

09 Feb 2015, 07:45

empardopo wrote:

Code: Select all

a::
Send {LControl}{LWin}
return
Thanks! So is this the official way? Because I found:

Code: Select all

Send {LControl}+{LWin}
...at different places.

If yes, where in the help file would I find the correct syntax?
Guest

Re: Press key combination

09 Feb 2015, 08:09

I would advice you to start reading the http://ahkscript.org/docs/Tutorial.htm again to learn the basics. You will see that + will mean sending the shift key. If you want to send the plus sign you need to wrap it curly braces {+}. The tutorial should make it clear including where you can find more information and also how to read the documentation.
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Press key combination

09 Feb 2015, 08:23

Thanks for the RTM. However there, I also can't find the information about how to send arbitrary key combinations.

What's more, I start to fear that

Code: Select all

Send {LControl}{LWin}
...sends a sequence, not a combination.
Guest

Re: Press key combination

09 Feb 2015, 08:41

Again actually READ the tutorial not just stare at the link :-)

Sending keys: http://ahkscript.org/docs/Tutorial.htm#s3

You can also send Down and Up events of a key (which you could have read if you actually opened the documentation - nothing will help you more by reading the documentation) - example
Send {LControl down}{LWin down}{Lwin up}{LControl up}
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Press key combination

09 Feb 2015, 08:46

Again, your example sends a sequence, not a combination :(

So if there is no way to send a combination (other than the down/up-sequence workaround), a) just tell me, and b) show me where the manual says such :(
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Press key combination

09 Feb 2015, 08:53

jNizM wrote:

Code: Select all

a² + b² = c²
( sorry :D )
you couldn't help you self, could you?
So please, where in the help file is the general description of how to send key combinations?
if the Send command, may be we don't have the same help gile but you can use the online documentations
http://ahkscript.org/docs/commands/Send.htm
there are examples and explinations
To hold down or release a key: Enclose in braces the name of the key followed by the word Down or Up. For example:

Code: Select all

Send {b down}{b up}
Send {TAB down}{TAB up}
Send {Up down}  ; Press down the up-arrow key.
Sleep 1000  ; Keep it down for one second.
Send {Up up}  ; Release the up-arrow key.
enthused
Posts: 94
Joined: 27 Dec 2014, 03:28

Re: Press key combination

09 Feb 2015, 08:55

Hi DavidP.
When you press control Alt Delete to bring up task manager, is that a combination or a sequence?
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Press key combination

09 Feb 2015, 09:01

When you press control Alt Delete to bring up task manager, is that a combination or a sequence?
That is of course a combination.

A sequence is

Code: Select all

Send, ab{ENTER}cd
:headwall:

So how do i send a damned combination?
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Press key combination

09 Feb 2015, 09:07

If Control+Shift+Del is a combination, and you want a combination:
than test this and you see it opens your taskmanager (COMBINATION)

Code: Select all

a::^+Esc

; a sends a combination of:
; ^   = Control
; +   = Shift
; Esc = Escape
; ==> TASKMANAGER
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Press key combination

09 Feb 2015, 09:11

:headwall: :headwall: :headwall:

For the umpteenth time:
How the **** do I send a combination of ARBITRARY keys?

Like, yo, press "a" and "b" simultaneously.

Without the down/up workaround.

And, where is it in the dam*ed manual.
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Press key combination

09 Feb 2015, 09:48

Yeah, I can't believe all the condescending responses people are giving DavidP (basically saying "read the manual, stupid") when they haven't been able to produce evidence that they can find it either.

He is looking to be able to send two keys in combination, and NOT modifier keys like Shift, Control, Alt. One example didn't even send the modifier keys in combination, it showed them in sequence. Unless you provide an example without the Up/Down work-around, I would hope you could withhold the snarky comments.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], RandomBoy, Rohwedder, ruespe and 363 guests