Any key as modifier sugestion

Discuss the future of the AutoHotkey language
guilhas
Posts: 3
Joined: 12 Oct 2018, 04:07

Any key as modifier sugestion

12 Oct 2018, 05:08

Hello all,

Suggestion is a easy an feature where you can set any key a modifier. And force it to trigger on KeyUp always.

I would prefer that when I do a script as below, that all Escape shortcuts keep working normally.
Currently everything related to Escape stops working.

eg.
Ctrl-Shift-Escape > Open Task manager (windows default)
Escape > Close find pop-up window in notepad

Code: Select all

ESC & g::
	msgbox, test
Return
With Ctrl all works as expected:

Code: Select all

CTRL & g::
	msgbox, test
Return
There are several examples where people have to remap every key:
> https://gist.github.com/solobat/f428bf4 ... 239829fc53

This does not work, because Escape is triggered on KeyDown, by default.

Code: Select all

~ESC & g::
	msgbox, test
Return
After a lot of work, this works:

Code: Select all

#MaxThreadsPerHotkey 2

$ESC::
	KeyWait, ESC, U
	Send, {Esc down}
	Send, {Esc up}
Return

~ESC & g::
	msgbox, test
Return
Possible solutions:
1. By default treat first key always a modifier, triggered only after KeyUp
2. Have a new command: ModifierAdd, Escape

Notes:
I have used https://github.com/randyrants/sharpkeys to swap Capslock for Escape permanently, and I use Escape as a modifier.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Any key as modifier sugestion

12 Oct 2018, 16:15

Suggestion is a easy an feature where you can set any key a modifier. And force it to trigger on KeyUp always.
I don't understand. The custom combination feature already does this, but you say it's your suggestion?
I would prefer that when I do a script as below, that all Escape shortcuts keep working normally.
If Escape is forced to trigger on key-up, it will not be working normally. Your request seems to be self-contradictory.

You could redefine your request to ask that Escape perform its normal key-down and key-up functions simultaneously when the key is released instead of at the normal times. However, you've shown that it can already be very easily achieved. So what are you asking to be changed? Why should the default behaviour be changed?

It's even easier than you showed.

Code: Select all

Esc up::Send {Esc}
Esc & g::MsgBox test
In this example, you can even remove "up" because the custom combination without tilde forces Esc to trigger on key-up.
With Ctrl all works as expected:
Ctrl is not a custom modifier. And it is not triggering on key-up, contrary to your apparent request.
This does not work, because Escape is triggered on KeyDown, by default.
To do anything else would be contrary to the purpose of the tilde modifier, which is to prevent the hotkey from blocking or interfering with the key. In fact, it does work: all Escape shortcuts keep working normally, and the custom combination is also detected.
guilhas
Posts: 3
Joined: 12 Oct 2018, 04:07

Re: Any key as modifier sugestion

16 Oct 2018, 06:56

I don't understand. The custom combination feature already does this, but you say it's your suggestion?
The suggestion is making a easier way to work more like CTRL, an actual modifier
It's even easier than you showed.

Code: Select all

Esc up::Send {Esc}
Esc & g::MsgBox test
This breaks CTRL-SHIFT-ESCAPE (Windows task manager)(win7)
Ctrl is not a custom modifier. And it is not triggering on key-up, contrary to your apparent request.
CTRL is a modifier, and everything with it is ok.
ESC is not a modifier. But if I am using it as a modifier I would like for it to behave more like CTRL.

As an user I would like to use ESC, or Space or any letter, as a modifier with little problems as possible. And without breaking their default actions and other shortcut combinations.

This link is not mine, why would this person remap all keys? I have seen several like this.
https://gist.github.com/solobat/f428bf4 ... 239829fc53
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Any key as modifier sugestion

16 Oct 2018, 22:01

And without breaking their default actions and other shortcut combinations.
You can't have it both ways. Either the native function is blocked and the key acts like a modifier, or the native function is not blocked and this interferes with its use as a modifier. If the native function is blocked, you can reimplement whatever functions you need by adding hotkeys.
CTRL is a modifier, and everything with it is ok.
ESC is not a modifier.
Exactly. Ctrl is not blocked, and this is okay because its native function (when not combined with another key) is usually to do nothing.
This breaks CTRL-SHIFT-ESCAPE (Windows task manager)(win7)
Good point. Try this:

Code: Select all

Esc::return
Esc up::
	if (A_PriorKey = "Escape")
		Send {Esc}
	return
~Esc & g::MsgBox test
The first two hotkeys block Esc if not combined with any standard modifiers, then sends it when Esc is released if no other keys were pressed.
guilhas
Posts: 3
Joined: 12 Oct 2018, 04:07

Re: Any key as modifier sugestion

19 Oct 2018, 08:40

Ok, if you think there is no (need|or does not make sense) a more intuitive keep both actions.
At least consider adding the example below to some example section in the documentation?

Code: Select all

Space::return
Space up::
	if (A_PriorKey = "Space")
		Send {Space}
return

~Space & w::Send {Up}
~Space & a::Send {Left}
~Space & s::Send {Down}
~Space & d::Send {Right}

~Space & e::Send {Enter}
This is related to previous, creating combinations with TriggerDown as modifier. And preserve default actions.
I think it will help a fair amount of people.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 23 guests