Hotkey Control - CTRL+Space not supported? Topic is solved

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
User avatar
TheArkive
Posts: 435
Joined: 05 Aug 2016, 08:06
GitHub: TheArkive

Hotkey Control - CTRL+Space not supported?

23 Jun 2020, 07:19

I figured this is simple. Either CTRL+Space is supposed to work in a hotkey control, or it doesn't. It doesn't seem to work, and it seems intention, I'm just asking if it is.

As soon as I press the {Space} the control changes to "None" while I'm holding CTRL. Oddly enough, I can pre-populate it with CTRL+Space.

I've made sure to close all my other scripts to ensure there's no other conflicts.

EDIT: On the bright side, I can use OnEvent("change",...) to wait for GetKeyState() on CTRL and Space, then I can set ctl.Value := "^Space". Unless I'm doing something else wrong, the workaround for this isn't too invasive.
User avatar
TheArkive
Posts: 435
Joined: 05 Aug 2016, 08:06
GitHub: TheArkive

Re: Hotkey Control - CTRL+Space not supported?

23 Jun 2020, 07:27

Oops, meant to post in AHK v2 help. Using AHK v2-a112 currently.
swagfag
Posts: 4141
Joined: 11 Jan 2017, 17:59

Re: Hotkey Control - CTRL+Space not supported?  Topic is solved

23 Jun 2020, 11:09

appears to be just a limitation of the win32 hotkey control, eg Ctrl + Backspace, Alt + Space dont get intercepted either and perform their original functions instead
it could be fixedworked around in source(as it is done for some other controls). i dont know if it will be
lexikos
Posts: 7194
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Hotkey Control - CTRL+Space not supported?

24 Jun 2020, 03:52

The standard (Microsoft) Hotkey control is very limited by comparison to hook hotkeys. I think extending it to support the full range of hotkeys would be quite difficult - it would be easier to implement a new Hotkey control based on an Edit or Text control. (Doing this in script is easier than in C++. One can use OnMessage and/or InputHook.)
User avatar
TheArkive
Posts: 435
Joined: 05 Aug 2016, 08:06
GitHub: TheArkive

Re: Hotkey Control - CTRL+Space not supported?

24 Jun 2020, 05:01

I managed to work around it like this:

Code: Select all

gui_hotkey_events(ctl, info) {
	result := ""
	ctrl := GetKeyState("Ctrl")		; fix key combos with {Space}
	alt := GetKeyState("Alt")		; fix key combos with {Space}
	shift := GetKeyState("Shift")	; fix key combos with {Space}
	If ((ctrl Or alt Or shift) And GetKeyState("Space"))
		result := (ctrl ? "^" : "") (alt ? "!" : "") (shift ? "+" : "") "Space"
	
	result ? ctl.Value := result : ""
}
So far so good!

I might try to come up with a class or function to extend this support, like you said, based on an edit box, and probably WM_KEYDOWN or something.

Return to “AutoHotkey v2 Help”

Who is online

Users browsing this forum: No registered users and 6 guests