Cntrl+S

Asked by lemonia

I want to know how to send a command to a browser or text editor to save a page. I tried these options, but it doesn't work:
hover(Location(984, 469))
#type("s", KEY_CTRL)
type("s", Key.CTRL)
wait(7)

SikuliX 2.0.5, Jython 2.7.1.

Question information

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

This only works in a text editor, not in a browser. Here the letter S is uppercase.
hover(Location(984, 469))
type("S", KEY_CTRL)
#type("S", Key.CTRL)
wait(7)

Revision history for this message
lemonia (russianbear77) said :
#2

Unfortunately, next time it didn’t work in the text editor either.

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

To use type(), the target window must have focus, which is not the case at script start.

You might use click() to activate the target window.
You seem to have tried with hover(), which does not do the job (no action, only mouse move)

To handle apps, you might use the app features:
https://sikulix-2014.readthedocs.io/en/latest/appclass.html#the-application-class-app

Generally it is worth to read across the docs, to get a feeling about the features available.

One more thing: type("S", Key.CTRL) should be type("s", Key.CTRL): for those combinations use lowercase, since uppercase adds a Key.SHIFT, which might not be correct.
Look: https://sikulix-2014.readthedocs.io/en/latest/keys.html#key-constants

Revision history for this message
lemonia (russianbear77) said :
#5

Thanks RaiMan, that solved my question.