RaiMan / SikuliX1

SikuliX version 2.0.0+ (2019+)
https://sikulix.github.io
MIT License
2.72k stars 349 forks source link

Keyboard commands don't send when AutoDetectKeyboardLayout=True #305

Closed balmma closed 3 years ago

balmma commented 4 years ago

Cloned from https://bugs.launchpad.net/sikuli/+bug/1861588

Sikuli 2.0.2

I had been previously using SikuliX 1.1.3 and noticed upon updating to 1.1.4 / 2.0.2 that my keyDown/keyUp and type commands were no longer registering in the target application. There were no errors logged in debug and Sikuli did report that it was pressing the desired key but there was no response from the application.

I went digging through the source files and landed on the method 'doKeyPress' in RobotDesktop.java. Looking at how behavior changed between 1.1.3 and 2.0.2 I noticed that when AutoDetectKeyboardLayout=True it will attempt to send the key using 'User32.INSTANCE.SendInput' and otherwise it falls back to the same behavior that 1.1.3 had.

Once I set 'Settings.AutoDetectKeyboardLayout=False' at the start of my script Sikuli started behaving as expected and was able to send key commands into the target application again.

Not sure if this is so much a bug but I've seen numerous reports of people having issues with RDP and Citrix sessions where they needed to run as administrator and other workarounds. Of note the application I am targeting is NOT a remote desktop window or similar application, but it seems to ignore inputs the same as those applications. Perhaps something in the documentation to let people know that some applications might require AutoDetectKeyboardLayout=False, or an option that enforces the old behavior used in versions prior to 1.1.4 that doesn't require disabling auto detection of keyboard layout?

balmma commented 4 years ago

On our side the new behavior works very well under different scenarios (including RDP and Citrix). Can you please give me some additional details about your environment (Windows version, input devices, Java version, virtual or real machine)?

Disclaimer: I'm the author of the layout detection feature and hence very interested in those details :-)

balmma commented 4 years ago

Oh, and isn't the new implementation working at all or only in some applications?

balmma commented 4 years ago

Can you please also try with the following JAR?

https://balmi.net/sikulixide-2.1.0-keyboard-fix.jar (don't mind the invalid certificate, have to fix this :-))

It's a build of https://github.com/SKOORAG/SikuliX1/tree/keyboard-layout with a slightly different method to simulate the keystrokes. This function is also used from within AWT.

balmma commented 4 years ago

An example script might me helpful as well 😀

balmma commented 4 years ago

No response for over a month, can be closed I would say. On Launchpad as well.

mauroroa commented 4 years ago

Thanks a lot. I was having problem send CTRL and special keys through Citrix and the version with keyboard fix solve the problems!!

balmma commented 4 years ago

@mauroroa You talk about the version from https://balmi.net?

RaiMan commented 3 years ago

should be checked

balmma commented 3 years ago

Should anyway be solved since PR #336

RaiMan commented 3 years ago

@balmma Thanks for clarification.