Confused by RemoteControlMBS.WinPressKey function

Hi,

I’m trying to debug an app that uses the RemoteControlMBS.WinPressKey function.
In a small sample, I have the following code running on Windows, after a delay of 2 seconds (so I can quickly switch to a text field to see the result):

call RemoteControlMBS.WinPressKey 11,98,True
call RemoteControlMBS.WinPressKey 11,98,False

This should produce pressing the “b” key (ascii=98, physical key=11), but does actually simulate “2” and I can’t figure out why: “2” has nothing to do with either 98 nor 11. I also tried swapping the parameters in case I had it backward, and it made no visible character.

As this is a simple example which shouldn’t fail (e.g. “b” is always at the same position regardless of the layout), I’m reporting my finding, hoping someone could either try, tell me where I’m wrong, or pinpoint a bug in the MBS plugins.

Virtual key code on Windows is 0x42 for B key, which is 66.
Scan code may be 48, if I looked it up correctly.

You get to “b” by using B key without shift.

1 Like

Ah, so the virtual key code isn’t the physical key… That’s certainly my issue (I’ll check in a few hours, and mark your reply as the solution, if it is).
Thank you!

So I’ll have to hard code each character to its corresponding virtual key code?
(because none of the various provided RemoteControlMBS functions did return 66 for either 98 (ascii) or 11 (physical key), the two values I know in advance).

I made the assumption that the physical key had to be provided. Actually, I’m receiving the key code in a message from a Mac computer, so mapping a Mac key (=physical key code and ascii/character point) to a Windows virtual key code is looking to be convoluted.