type() works with sikuliIDE scripts, but not with sikulixapi

Asked by Darius Tumas

Hello,

OS: Windows 10
Sikulix: 2.0.5
Java: OpenJDK 11

Simplified Script:

App.focus("Some app")

type("b")

When this logic is ran from SikuliX IDE everything works as expected, but when it is implemented in Java, key press is not triggered in target application.

I'm stuck on trying to figure out where the problem is.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Darius Tumas
Solved:
Last query:
Last reply:
Revision history for this message
Darius Tumas (tokeiito-m) said :
#1

Not sure how relevant following information will be:

Target app is java based.
Type command is used not to type into input box, but to trigger hot key shortcut.
Apart type() i've tested keyDown() keyUp() approach as well.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

I do not have any experience with your scenario (hotkey against java app).

Is it really true, that this works from the SikuliX IDE?

Since you are working at the Java level anyways, you might try to use the AWT Robot class yourself (which internally is used with type/keyDown/keyUp). So you would have a better control over what is happening.

Revision history for this message
Darius Tumas (tokeiito-m) said :
#3

Thank you for replay.

That is the main thing what puzzles me, is that yes it does work at SikuliX IDE. In multiple different scripts. And does not work at all when implemented in pure java.

I will try AWT Robot directly.

Revision history for this message
Darius Tumas (tokeiito-m) said :
#4

It does work when AWT Robot is used directly.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

Thanks for feedback.

Could you again try with the SikuliX type(), but do a

(org.sikuli.basics.) Settings.AutoDetectKeyboardLayout = false;

before doing the first type()

Would be helpful. Thanks.

Revision history for this message
Darius Tumas (tokeiito-m) said :
#6

That was a culprit. It works as intended when keyboard layout detection is turned off.