Holding a number key button down for a few seconds

Asked by Alsabit Siyyid

Hello, for my particular software, I need to hold down the "1" key for at least 3 seconds to form a binding and save a new view of the screen. I tried the following code to do this:

keyDown("1")
wait(5)
keyUp()

When I do that, Sikuli functions as if I simply pressed the button once as opposed to actually holding down the button for 5 seconds.
I've even added other mouseMove commands in between the key commands to see if that made a difference but it did not. Do you know how I could solve this issue?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1
Revision history for this message
Alsabit Siyyid (asiyyid) said :
#2

@masuo

Thanks. I tried all the things mentioned in that post aside from running sikuli as an administrator. I am still not getting the desired outcome. Manually, I hold down "1" for a few seconds, a sounds happens, and then the key is binded. But no matter what I try with sikuli, the outcome is as if I press it once and immediately let go as oppose to holding it down.

Is there any other way or code I can try out to get the outcome I desire?

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

see #1 answer
https://answers.launchpad.net/sikuli/+question/404260

RaiMan answered the question as follows:
keyDown() does not trigger the keyboard repeat function (Java Robot)

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

@masuo

So theres no way to trigger the keyboard repeat function?

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

@masuo

I've even tried the for loop method he recommended but that doesnt seem to work either.

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

as mentioned in the other question:
keyDown in SikuliX (Java Robot) does not trigger the key repeat feature (works only if keyboard is used manually)

this repeatedly types the given key:

for n in range(10):
    type("1")

or
for n in range(10):
    keyDown("1")
    keyUp()

where the second version types a bit faster.

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

@RaiMan

Thank you for the response. So just to make sure I am understanding correctly, there is nothing in SikuliX that can automate a key repeat feature? That feature can only work manually when SikuliX is not actually being run?

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

- it only works when using the real keyboard (manual typing)
- does not matter, wether SikuliX runs or not
- SikuliX's current features cannot do it

Can you help with this problem?

Provide an answer of your own, or ask Alsabit Siyyid for more information if necessary.

To post a message you must log in.