Simulating Keyboard Function Layers

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tanvir175
Posts: 2
Joined: 14 Apr 2018, 18:40

Simulating Keyboard Function Layers

14 Apr 2018, 19:21

Hey all,

I put together a 5x5 macro pad using this pcb http://www.40percent.club/2017/09/25.html so I can easily send things like emojis or emoticons instead of having to google it and then copy/paste it.
It's controlled by a Pro Micro clone and is programmed with the open source firmware QMK.

I programmed each key to be something like this: Control+Alt+Windows+Letter since that combination of modifiers is rarely, if ever, used.

It looks something like this:

Code: Select all

<^<!<#b::Send, B emoji (forum doesn't support it)

<^<!<#c::Send, 100 emoji (forum doesn't support it)

<^<!<#d::Send, (•_•) ( •_•)>⌐■-■ (⌐■_■)
25 macros is a bit limiting though so what I planned to do was use QMK to make one or a couple of the keys in function layer keys. One key would raise the function layer by 1, the other key would lower the function layer by 1.

So I would have:

Code: Select all

Key 1: 
Layer 0 = Control+Alt+Windows+Letter
Layer 1 = Control+Alt+Windows+Shift+Letter
Layer 2 = Control+Alt+Windows+Number
Layer 3 = Control+Alt+Windows+Shift+Number

Key 2:
Increase current Layer by 1.

Key 3:
Decrease current Layer by 1.

Instead, since QMK unicode support either isn't extensive or easy to use, I would like to use AHK to simulate these layers since I'm already using it to send the emojis and emoticons.

So what I was thinking of doing was to make a variable called Layer assign it with the integer of the current layer. It would be initialized with 0 to start at Layer 0.
If I press <^<!<#a then it will increase the variable by 1. If I press <^<!<#b it will decrease the variable by 1. And then there would be a macro <^<!<#c which performs different functions depending on the layer.

For example:

Code: Select all

Layer = 0; //initialize as starting layer
MaxLayer = 4; //total of 5 layers so max layer is 4
MinLayer = 0; //first layer is 0, can't go below

Loop{
if(<^<!<#a && (Layer+1) <= MaxLayer){ Layer++}; //increment layer by 1 if Layer+1 is less than or equal to max layer
if(<^<!<#b && (Layer-1) >= MinLayer ){Layer--}; //decrement layer by 1 if Layer-1 is less than or equal to min layer

switch(Layer){
	case 0:
		<^<!<#c:: Send, Layer 0;
	case 1:
		<^<!<#c:: Send, Layer 1;
	case 2:
		<^<!<#c:: Send, Layer 2;
	case 3: 
		<^<!<#c:: Send, Layer 3;
	case 4:
		<^<!<#c:: Send, Layer 4;
}
I'm sure you can tell but I'm a complete novice at AHK and coding in general. I plan on researching AHK a ton as my free time allows to try and get this working.
Any help at all is appreciated, including telling me it can't be done so I don't waste all of my time on it lol.

Thanks!
tanvir175
Posts: 2
Joined: 14 Apr 2018, 18:40

Re: Simulating Keyboard Function Layers

20 Apr 2018, 18:15

Figured it out.

I don't know if topics are supposed to be closed or not, nor do I know how, but mods can close this if they want.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 378 guests