kareltucek / firmware

This is fork of UHK's firmware featuring extended macro engine.
Other
82 stars 9 forks source link

How to use Windows Key in tabKeySq? #100

Closed provinzio closed 2 years ago

provinzio commented 2 years ago

Hey,

I'd like to include a Windows Shortcut into a macro chain. Unfortunatly I can't find the keyid for a windows key (already looked in macro_shortcut_parser.c and the documentation).

Would love a kick in the right direction.

kareltucek commented 2 years ago

It is the "Gui" modifier. So if you want the key alone, "LG-" should work.

provinzio commented 2 years ago

Thanks for the heads up.

I am still having difficulties with the command. My OS layout is QWERTZ.

Using $tabKey LG- gives the error testÖ 0Ö 0Ö unrecogniyed commandÖ tabKez LGß. So I thought, I have to mimick a en-US layout: y turns to z, but which key do I use for the -? At the position of the en-US - QWERTZ has ß which can not be entered in the text macro field.

kareltucek commented 2 years ago

It is tapKey.

Indeed, you need to refer to your keys (scancodes) by their enUS names. ( This is furthermore explained in https://ultimatehackingkeyboard.com/blog/2018/06/23/how-can-i-type-accented-characters-with-my-uhk .)

To get a - with enUS OS keyboard layout, you would use simply -, or minusAndUnderscore. For other (language) layouts, you need to figure out which key is translated to the desired character by your OS, and then refer to that key by its enUS layout.

(The error output is typed on the keyboard as if it was an enUS layout, which might be confusing you. If you want clear output, you will need to switch to enUS before using printStatus.)

provinzio commented 2 years ago

For my first test, I wanted to implement Win+L.

Running the following does work.

$pressKey leftGui
$tapKey l
$releaseKey leftGui

I also tried to implement this with tapKeySeq, but as far as I found out, I cannot use the shortcuts e.g. LG- because, I cannot enter the scancode for enUS - into the agent - which is ß on my layout. Pressing the ß on my keyboard does nothing when trying to enter the text macro.

So I cannot use tapKeySeq? Or is there some other way?

Edit: Because in the next step, I'd like to use if-statements like $ifCtrl. How could I combine this with the above? I tried $ifCtrl pressKey leftGui tapKey l releaseKey leftGui with no success.

Edit2: I found the goTo functionality, and tried to use it instead, but the following macro gives me an error.

$ifCtrl goTo default
$pressKey leftAlt
$tapKey np7
$releaseKey leftAlt
$default: tapKey b

error:

0
1
2
3
4
§testÖ 0Ö 0Ö Label not foundÖ default

This might make problems because of the enUS : which is a Ö on my layout. But as stated above, I cannot enter special characters in the agent...

kareltucek commented 2 years ago

For my first test, I wanted to implement Win+L.

You may as well use tapKeySeq LG-l, or tapKey LG-l for that matter, since the LG-l is still just a simple shortcut - consisting of a modifier and a key. (The windows/gui key is a modifier (just as a shift or control).)

(The left hand side of LG-l stands for modifier mask and means Left Gui.)

You could also rewrite the above explicitly as tapKeySeq pLG- l rLG-, meaning press left gui, tap l, release left gui.

I also tried to implement this with tapKeySeq,

Meaning you are trying to implement the Win+L, while facing the problems with the ß key?

Commands are consisting of characters, not scancodes, so you are really supposed to just paste tapKeySeq LG-l into the field (irrespectively of your OS language map, assuming that the map has L at the same place as enUS has). (The reason why error log types out ß is that... uhk types out actual - scancode, and it is your OS which translates it to ß because of your language map.)

but as far as I found out, I cannot use the shortcuts e.g. LG- because, I cannot enter the scancode for enUS - into the agent - which is ß on my layout. Pressing the ß on my keyboard does nothing when trying to enter the text macro.

So I cannot use tapKeySeq? Or is there some other way?

So let's backtrack a bit:

I.e., ß is not a scancode. It is a character, produced by your OS language (key)map. It is definitely not a legal input in any of Agent fields.

If you want to trigger the key which has - label in enUS layout, you need to enter the - character into Agent's input field, which means that you need to physically tap such key combination which results in the - within your actual language map. On the other hand, if you are trying to make UHK produce - character, you first have to figure out which keys on your OS language keymap produce that character, translate them to enUS layout keys, and then enter these as characters into the Agent's fields.

kareltucek commented 2 years ago

This can be shortened to:

$ifCtrl final tapKey b
tapKey LA-np7

§testÖ 0Ö 0Ö Label not foundÖ default

It should work if you remove the dollar in $default:.

Sorry about this, the firmware is somewhat in process of transition from text action with dollar notation, to command action without dollar notation... current rule is actually that a text action is interpretted as command action if the first character of the action is $.

This might make problems because of the enUS : which is a Ö on my layout. But as stated above, I cannot enter special characters in the agent...

You don't need to. All you need to type into macros or into Agent to produce any behaviour are regular ascii characters.

provinzio commented 2 years ago

You enlightened my day. Thank you!

kareltucek commented 2 years ago

You are welcome!