-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Problem with mapping certain keys in action section #15403
Comments
Fyi @0x5bfa |
@XTorLukas thank you for the feedback. Aside from this issue, do you have any other thoughts or feedback on this feature? |
@yaira2 Maybe I would like to be able to map also numeric keys e.g. Num0, Num1 and others and divide e.g. |
Thanks for the feedback! It looks like your keyboard is not US keyboard, what keyboard type are you using? |
Thanks! It looks like Files has an issue around humanizing input keys. |
Maybe it will be useful.I don't know how the implementation is used here, but I personally use this class: public class KeyCodeConverter
{
[DllImport("user32.dll")]
private static extern int ToUnicode(
uint wVirtKey,
uint wScanCode,
byte[] lpKeyState,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszBuff,
int cchBuff,
uint wFlags);
[DllImport("user32.dll")]
private static extern bool GetKeyboardState(byte[] lpKeyState);
[DllImport("user32.dll")]
private static extern uint MapVirtualKey(uint uCode, uint uMapType);
[DllImport("user32.dll")]
private static extern IntPtr GetKeyboardLayout(uint idThread);
public static char ConvertKeyCodeToChar(Keys key)
{
char ch = '\0';
byte[] keyboardState = new byte[256];
if (!GetKeyboardState(keyboardState))
{
return ch;
}
uint virtualKey = (uint)key;
uint scanCode = MapVirtualKey(virtualKey, 0);
StringBuilder stringBuilder = new StringBuilder(2);
int result = ToUnicode(virtualKey, scanCode, keyboardState, stringBuilder, stringBuilder.Capacity, 0);
if (result > 0)
{
ch = stringBuilder[0];
}
return ch;
} Use in codechar character = KeyCodeConverter.ConvertKeyCodeToChar(keyData); |
@yaira2 ToUnicode seems to be actually needed though I did remove. cinqmilleans's implementation is always correct... I'll work on. |
Thanks! |
It looks like we didn't remove that ToUnicode line. @XTorLukas If you have a solution to this, do you wanna open a PR for this? |
@0x5bfa I have my general solution, but I'm here for a short time and need time to get my head around the code, it's not easy with complex code. But I'm certainly willing to help if I know the solution, just the correct implementation is important. |
@XTorLukas thank you for your detailed report and fix! |
Description
I discovered a small bug where two characters are not displayed correctly:
KEY:
;
wrong map to´;
KEY:
)
wrong map to¨)
but this problem is only in the text string representation, the KEY function is recorded correctly
Steps To Reproduce
Files Version
3.4.1.0
Windows Version
10.0.22631.3593
Log File
There are no errors
The text was updated successfully, but these errors were encountered: