Appskey hotkey combinations

Get help with using AutoHotkey and its commands and hotkeys
Lem2001
Posts: 63
Joined: 27 Jun 2017, 17:59

Appskey hotkey combinations

15 May 2020, 22:43

I'd like to have the Appskey act as a modifier when it is pressed in combination with other keys, while still retaining its native context-menu function when it's pressed (and released) on its own.

There are two types of ways that I'd like to use it:

1. First Method
I would like to hold down the Appskey first, and then press another specific (non-modifier) key, then release both keys and press a single further key to trigger an action.

For example:

Appskey & semi-colon, followed by n = open Notepad
Appskey & semi-colon, followed by c = open Calculator
Appskey & semi-colon, followed by w = open Wordpad

etc.



2. Second Method
The second way that I'd like to use the Appskey (in addition to the above) is just as a standard modifier key that can be used in combination with other modifier keys. It would therefore behave similarly to the Ctrl or Alt key.

In this instance, all keys would be held down at once (and the order in which they are pressed should not matter). The action is then triggered when the keys are released.

For example:

Ctrl & Appskey & D = an action
Alt & Appskey& D = a different action
Ctrl & Shift & Appskey & D = yet another action

I'd like these two methods (1 and 2) to co-exist without interfering with each other, although it should be noted that I do not expect any specifically assigned key combination that uses method 1 to also be able to function in method 2 style.

What's the best way to achieve the above without messing up the native function of the Appskey?
Rohwedder
Posts: 3269
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Appskey hotkey combinations

16 May 2020, 02:51

Hallo,
only the First Method. You can implement the Second Method in a similar way.

Code: Select all

~Appskey & `;::
Input, Key, L1
Switch, Key
{
	Case "n":Run, Notepad.exe
	Case "c":Run, Calc.exe
	Case "w":Run, Wordpad.exe
} 
Return
Lem2001
Posts: 63
Joined: 27 Jun 2017, 17:59

Re: Appskey hotkey combinations

21 May 2020, 02:39

Rohwedder wrote:
16 May 2020, 02:51
Hallo,
only the First Method. You can implement the Second Method in a similar way.

Code: Select all

~Appskey & `;::
Input, Key, L1
Switch, Key
{
	Case "n":Run, Notepad.exe
	Case "c":Run, Calc.exe
	Case "w":Run, Wordpad.exe
} 
Return
Thanks for your reply.

When I try to run your example code I get an error about the line Switch, Key.

Unfortunately I don't understand line 3, so I don't know how to amend it to fix this issue.
Rohwedder
Posts: 3269
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Appskey hotkey combinations

21 May 2020, 02:49

Your Autohotkey is out of date.
Try:

Code: Select all

MsgBox,% "A_AHKVersion: " A_AHKVersion "`nUnicode:`t" (A_IsUnicode?"yes":"no")
It should be:
A_AHKVersion: 1.1.32.00
Unicode: yes
Lem2001
Posts: 63
Joined: 27 Jun 2017, 17:59

Re: Appskey hotkey combinations

21 May 2020, 21:42

I appreciate your warning about AHK versions. I was running v1.1.30.03. This also explains why I found nothing for "Switch" when I searched in the AHK help file. I've now upgraded to v1.1.32.00 and the code works. Thank you!

There are a couple of issues that I'd be grateful for some help with.

1. In the code that you kindly provided, the 'Method 1' modifier hotkeys seem to be dependent on the order in which they are released. As a result, the context menu keeps getting triggered (even though I have also pressed down the semi-colon key at the same time). I understand that the Appskey will 'fire' if it is released prior to any other key being pressed (that is expected), but as soon as another key has been held down at the same time as the Appskey, then that means the standard Appskey menu function was not required. Therefore the order in which the 2 modifier keys are released should not matter at that point (and a standard Appskey 'display context menu' command should not be sent). Is there a way to fix this?

2. You suggested using the same code for 'Method 2', but this does not work. For method 2 I want the action triggered when all keys pressed at the same time. This differs from 'Method 1' where the Appskey will always be pressed down first, and then both the Appskey and the additional modifier key are released before a letter key is pressed.

Method 2 is different because I would like all keys pressable at the same time and in any order (just as long as they all end up being held down at the same time eventually). Likewise, the release order of the keys should not matter. Once they're all released (regardless of the sequence in which they're released) then they hotkey action should be triggered. What's the best way to do this?
Rohwedder
Posts: 3269
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Appskey hotkey combinations

22 May 2020, 03:36

Having to hold down many keys is 1. cumbersome and 2. many keyboard driver do not like it.
My script first expects the key combination: Appskey & Semicolon
(Appskey Down - Semicolon Down - Semicolon Up - Appskey Up)
and second type a letter, e.g. n or N for Notepad.
If you want to hold Appskey all the time (abstruse to me) then:

Code: Select all

~Appskey & `;::
ToolTip, press the first letter:`nNotepad`nCalculator`nWordpad 
Input, Key, L1
ToolTip
Switch, Key
{
	Case "n":Run, Notepad.exe
	Case "c":Run, Calc.exe
	Case "w":Run, Wordpad.exe
}
Return
$Appskey Up::
IF (A_PriorHotkey <> "~Appskey & `;")
	Send, {Appskey Up}
Return
(I can't manage to keep semicolon hold with my German keyboard in addition!)

Method 2 of course requires a slightly different approach, but only if you do it yourself will you get ahead.

Return to “Ask For Help”

Who is online

Users browsing this forum: anhnha, Bing [Bot], pnKed, SilasDeVis and 61 guests