trying to create Keyboard Layer. First steps

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

trying to create Keyboard Layer. First steps

06 May 2021, 13:41

Introduction: You already are using keyboard layers, for example, when you keep pressed Shift key, all letters are UpperCase and you can type new simbols. That is called a "Keyboard Layer"

I'm a programmer and I'm noob on AutoHotKey so, is there a better way to do this?:
- If I keep pressed "WindowsKey" I want a NumPad on "uio" keys (there are a lot of keys, but the example only shows 3 to be short). No matter what program I'm using.
- If Windows Calculator is active, then keys "uio" are translated to "789". If windows calculator is closed, it just send "uio" keys through.
- If Blender3D is active, I will use those keys "uio" for other purposes...

The reason is I'm introducing myself on split keyboards, dactyl ManuForm keyboard and so on. Before 3DPrinting one myself, I would like to use keyboard layers on my 104 keyboard.

Code: Select all

; NumPad with Winkey pressed
#u::
{ 
  Send, 7
  return
}
#i::
{ 
  Send, 8
  return
}
#o::
{ 
  Send, 9
  return
}
; Windows Calc
$u::
{ 
	if WinActive("ahk_class CalcFrame")
	{
		Send, 7
	}else {
		Send, u
	}
	return
}
$i::
{ 
	if WinActive("ahk_class CalcFrame")
	{
		Send, 8
	}else {
		Send, i
	}
	return
}	
$o::
{ 
	if WinActive("ahk_class CalcFrame")
	{
		Send, 9
	}else {
		Send, o
	}
	return
}	
I already discovered TapHoldManager that would me help a lot. Thanks evilC

I already disabled Win+ L and Win key on windows Registry.

Any code, ideas, better coding method... are all welcome!!

Thanks in advance for your time!.
gregster
Posts: 9014
Joined: 30 Sep 2013, 06:48

Re: trying to create Keyboard Layer. First steps

06 May 2021, 13:48

You should use #If...-directives to create context-sensitive hotkeys...

Code: Select all

#ifWinActive, ahk_class CalcFrame	; or #if WinActive("ahk_class CalcFrame")
$u::Send, 7
$i::Send, 8
$o::Send, 9
#If
If calculator is not active, the keys will work as usual.

And yeah, one-line hotkeys can be written like this (although it doesn't hurt to use more lines):

Code: Select all

; NumPad with Winkey pressed
#u::Send, 7
#i::Send, 8
#o::Send, 9
Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: trying to create Keyboard Layer. First steps

06 May 2021, 14:01

OMG... Thank you very much! I knew I was doing it wrong. Newbies always do it on the complex way! :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 373 guests