key input 'Enter'

Asked by Sathyamoorthy

Hi,

I have to pass key input 'Enter' into my script. i tried type(key.ENTER), but it did not work.

Question information

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

the docs would have told you:

type(Key.ENTER)

or

in many cases this works too:

type("\n")

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#2

Thanks,
What about Space key?

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

Hi,
Thanks for the information. if i use key.BACKSPACE in my script, it was giving error saying 'key' is not defined. i also tried with keyModifier.BACKSPACE, observing the same error.

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#5

type("\n") didnt work out. I want to pass Key inputs like Enter key and space key. please guide me to do that, from Sikuli documentation is not so clear.

Revision history for this message
nupur (nupur) said :
#6

Hi Satyamoorthy,

Use Key.BACKSPACE instead of key.BACKSPACE..... (K of Key must be in CAPS)

Revision history for this message
Bekir Dogru (bekirdogru) said :
#7

and try

paste("\n")

instead of

type("\n")

sikuli sometimes cause problems with special characters with type but paste is much more better...

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#8

Caps 'K' worked..
Thanks

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#9

Friends,
Nothing works. :(
my actual cases is , want to press Enter and Space keys on the screen during the Automation. Key.Enter and "\n" didnt worked

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

Its definitely hard, to hold you on the road ;-)

The general rule is:
Key.KEYTOPRESSINUPPERCASE

where Key is the class name, that contains defined key constants in uppercase.

So Key.Enter is either a typo (but should not happen in this case here), or you did not obey the above rule.

so:
type(Key.ENTER)

... and this can really be taken from the docs.

If you did it this way, then you have to take care, that the GUI element that should accept the Key.ENTER is the frontmost in that moment and ready (might need a wait(1) before).

And another possibility, that is not really clear:
should ENTER and SPACE be pressed together.
If yes, this is not possible with type() - use keyDown()/keyUp() (see docs) in this case.

Revision history for this message
Sathyamoorthy (sathyamoorthybe) said :
#11

Thanks RaiMan for details. I think my application causes problem. Key.ENTER works sometime and didnot some time.

Thanks for your help . I am closing this question