slow keyboard.send_keys

64 views
Skip to first unread message

Dave

unread,
Dec 23, 2011, 3:36:26 PM12/23/11
to autokey-users
Is keyboard.send_keys working slower now, or is this normal?

system.exec_command("gnome-screenshot -w", False)
time.sleep(1)
system.exec_command("xte 'mousemove 725 399'", False)
window.activate("Save Screenshot", switchDesktop=False)
time.sleep(1)
keyboard.send_keys("tomorrow")
time.sleep(3)
keyboard.send_key("<enter>")

i.e. if I put the "time.sleep(3)" any lower, the <enter> happens
before the "tomorrow" gets there.

-Dave

Chris D

unread,
Dec 25, 2011, 6:39:01 AM12/25/11
to autokey-users
Is there any reason why you can't put the <enter> with the 'tomorrow'?

Dave

unread,
Dec 25, 2011, 12:02:17 PM12/25/11
to autokey-users
Good point, I've always used this script before, but that does make
more sense, so it just works properly no matter how long it takes to
show up... (don't you just love working with amateurs - being an open
source developer not only takes smarts and generosity, but patience
too! :-)

thank you
(and Happy Christmas)
-Dave

Al

unread,
Dec 25, 2011, 3:30:40 PM12/25/11
to autokey-users
I've made your script faster, also I'm using 0.81.4 of Autokey in
Ubuntu 11.10.

system.exec_command("gnome-screenshot -w", False)
time.sleep(1)
#system.exec_command("xte 'mousemove 725 399'", False)
window.activate("Save Screenshot", switchDesktop=False)
time.sleep(1)
#keyboard.send_keys("tomorrow")
#time.sleep(3)
#There is a timestap already
keyboard.send_key("<enter>")

Note: I don't have xautomation installed nor do I want to use it.

Luke Faraone

unread,
Dec 25, 2011, 3:44:11 PM12/25/11
to autoke...@googlegroups.com
On 25/12/11 12:30, Al wrote:
> I've made your script faster, also I'm using 0.81.4 of Autokey in
> Ubuntu 11.10.
>
> system.exec_command("gnome-screenshot -w", False)
> time.sleep(1)
> #system.exec_command("xte 'mousemove 725 399'", False)
> window.activate("Save Screenshot", switchDesktop=False)
> time.sleep(1)
> #keyboard.send_keys("tomorrow")
> #time.sleep(3)
> #There is a timestap already

What were you trying to do? You commented out one of his send_keys and
mouse-movement commands.


--
Luke Faraone;; Debian & Ubuntu Developer; Sugar Labs, Systems
lfaraone on irc.[freenode,oftc].net -- http://luke.faraone.cc
PGP fprint: 5189 2A7D 16D0 49BB 046B DC77 9732 5DD8 F9FD D506

signature.asc

Dave

unread,
Dec 28, 2011, 11:33:25 AM12/28/11
to autokey-users
this is the fastest I've gotten it so far:

system.exec_command("gnome-screenshot -w", False)
window.wait_for_exist("Save Screenshot", timeOut=5)
system.exec_command("xte 'mousemove 725 399'", False)
window.activate("Save Screenshot", switchDesktop=False)
keyboard.send_keys("today<enter>")
time.sleep(.7)
keyboard.send_keys("<alt>+r")

I'd forgotten about the "wait_for_exist" function. It would help
further at the step taken up by the "time.sleep(.7)", but the window
there is a dialog window with the text "File already exists" asking to
confirm if you want to overwrite the file, at which point I need to
"alt-r" to replace the file

Is there a way to get "wait_for_exist" to work on a title-less
window?

(the window in question displays a big blue question mark if that
helps, or maybe there's a way to identify "the most recently opened
window"...)

Al

unread,
Dec 29, 2011, 5:23:24 AM12/29/11
to autokey-users
You can get around that whole "sleep and alt-r thing, if you just rm
the file in question prior", just do this instead:

#
# replace ~/Downloads with the location of where you told gnome-
screenshot to save the pic
#
system.exec_command("bash -c 'rm ~/Downloads/today.png'",False)
system.exec_command("gnome-screenshot -w", False)
window.wait_for_exist("Save Screenshot", timeOut=5)
system.exec_command("xte 'mousemove 725 399'", False)
window.activate("Save Screenshot", switchDesktop=False)
keyboard.send_keys("today<enter>")


Al

unread,
Dec 29, 2011, 5:30:15 AM12/29/11
to autokey-users
What I still don't understand, and I installed xautomation just so I
can run xte, is what are you accomplishing with moving the mouse
around? It looks as tho you moving it away from a column of text or
some-such on left. Near as I can tell, it has nothing to do with gnome-
screenshot window, because it is the '<enter>' command that depresses
the [save] button after you send "today".

On Dec 28, 10:33 am, Dave <cedardocs...@gmail.com> wrote:

Dave

unread,
Dec 29, 2011, 3:11:55 PM12/29/11
to autokey-users
>just rm
>the file in question prior

that's a great idea, I'll do that

re the mousemove thing, I've been having difficulty with focus
problems and at one point I had to position the mouse over the right
window, otherwise my VNC window (the one I'm taking a screenshot of)
would steal focus.

thanks for the ideas :-)
Reply all
Reply to author
Forward
0 new messages