keydown() doesn't work

Asked by Christos

My code :

wait(2)

click(some area) #click inside a notepad (empty) window

wait(0.5)

keyDown("o")
wait(6.3)
keyUp("o")
wait(1)
keyDown("o")
wait(4.9)
keyUp("o")
wait(1)
keyDown("o")
wait(3.6)
keyUp("o")
wait(1)
keyDown("r")
wait(2)
keyUp("r")
wait(1)

So, instead of having something like this : "oooooooooooooooooooooooooooooooooooooooooooooooooooooooorrrrrrr" (it doesn't matter how it would actually look like) I get this : "ooor".

So, instead of keeping "o" and "r" down, it seems it just types it once!

A little backstory :

The above is part of a code for playing a game. "o" is accelaration, "r" is reset.
I have written my code for the same game in my laptop and it works perfectly.
When I transfered my code to my friend's PC, it simply doesn't work.
When I wanted to undersatand why it wouldn't work, I thought to test it on notepad.
I tried for almost 3 hours to find any solution but nothing.
Right now, I tried the code on my laptop and it worked. I am trying the above segment on notepad and I get the exact same resaults as on my friend's PC.

Any ideas?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Christos
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

keyDown() does not trigger the keyboard repeat function (Java Robot)

Revision history for this message
Christos (chris023r) said :
#2

@Raiman

1. Then why is this working on my laptop and not on my friend's PC (for the game I am trying to create a sikuli)?

2. What does trigger the keyboard repeat function?

3. Do you have any suggestion for what I am trying to do?

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

1. many possible reasons: System, Java, ... no idea

2. no idea

3. for n in range(10): type ("o")

Sorry, on vacation this week

Revision history for this message
Christos (chris023r) said :
#4

I tried #3. The button has to be kept down, not repeatedly being pushed.

If anyone else has any ideas, please share!

Revision history for this message
Christos (chris023r) said :
#5

Sooooo, after trying and trying for hours, the problem was that I didn't run Sikuli as administrator.

Yeap, that's right.

Anyway, problem solved. I hope anyone with the same issue reads this and solves his issue quicker than I did...

Revision history for this message
masuo (masuo-ohara) said :
#6

@Christos
Please introduce your environment (OS, Java, SikuliX, eg.)

Revision history for this message
Christos (chris023r) said :
#7

@mauso

Windows 10 64-bit 14393.447

Sikuli 1.0.0

Java 7 Update 80 64-bit

Revision history for this message
masuo (masuo-ohara) said :
#8

@Christos
Thank you for your information.
keyDown("o") do not work on my environment.

[my environment:]
  Windows 10 64-bit
  SikuliX1.1.1
  Java 1.8.0_111 64-bit

Revision history for this message
Christos (chris023r) said :
#9

@mauso

I don't think I can help you further. That's why I opened this question. In the end, my problem was that I didn't run Sikuli as administrator. Try this and if it doesn't work for you, I am sorry but I won't be able to assist you further...

Revision history for this message
masuo (masuo-ohara) said :
#10

@Christos
Don't worry, I just wanted to confirm whether there are differences in the environment.

Revision history for this message
Alsabit Siyyid (asiyyid) said :
#11

Has an answer been achieved for this question?

Revision history for this message
Christos (chris023r) said :
#12

Yes. Comment #5