different keyboard layouts on MacOS #139
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Hi! Thanks for asking! This is expected behavior though. Taking the current layout into consideration is difficult because keyboard layouts can in general produce any Unicode characters. For example, the Ukrainian layout produces Cyrillic letters. It's just not feasible for a low-level library like SharpHook to implement this and expect users of the library to consider the current layout when simulating text. If you want to simulate text entry, then you should do this instead: I've actually implemented getting characters that are produced by various keys in various layouts in Keyboard Switch, an application which gave rise to SharpHook itself, and here's what it does on different systems (spoiler: none of it is pretty):
Regarding Windows - I actually didn't know that this is the current behavior, and I expected it to work the same as on macOS. Hopefully, I'll have time in the nearest future to align this behavior. |
Beta Was this translation helpful? Give feedback.
-
|
I'm experiencing some unexpected behaviour on Windows with these changes. For context; when I have an app simulate the Q key on the US keyboard layout, it will print a Q, and when I then switch to the BE (belgium) keyboard, it will print an A, because of the azerty layout, as expected. However, if I launch the app with the BE keyboard already selected, and then simulate a Q key, it will print a Q, and then when I switch to the US layout, it will print an A. Seemingly as if the operating system switched the two layouts around. I don't imagine this is an issue with SharpHook or libuiohook, but I was wondering if you experienced the same behaviour, and if you may have any clue as to what is going on here. |
Beta Was this translation helpful? Give feedback.

Hi! Thanks for asking!
This is expected behavior though.
eventSimulator.SimulateKeyPress(KeyCode.VcW)- this means that the simulator will simulate the W key from the QWERTY layout (third key from the left in the second row), irrespective of the current keyboard layout.Taking the current layout into consideration is difficult because keyboard layouts can in general produce any Unicode characters. For example, the Ukrainian layout produces Cyrillic letters. It's just not feasible for a low-level library like SharpHook to implement this and expect users of the library to consider the current layout when simulating text.
If you want to simulate text entry, then you should do this instead:
e…