ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Clipboard Help+Spell

delay IN sendkeys?

(1/1)

Herchi:
I have an app in java and my login is
{sendkeys}myname{SLEEP 1000}{TAB}password{ENTER}

I dont understand why I need "SLEEP". Sometimes the delay is bigger and I must to increase the miliseconds because it DOESN'T WORK SOMETIMES.

In other program, like AutoHotkeys (https://autohotkey.com/) I don't need this dirty trick.
In AutoHotkeys it's a simple:
!^k::
    Send, myname{tab}password{enter}
Return

and it works ALWAYS.

anandcoral:
Hi Herchi,

Most probably the java app is processing slowly and this delay gives it time to focus at next get before input of the keyboard keys. I have encountered this type of scenario, not only in java but other languages too, and sleep does helps here. 

Regards,

Anand

Ath:
If you swap the {SLEEP 1000} and {TAB} around, then the Tab could start the 'on change' event that takes a little time, wait the 1000msec and then fill in the password.
Maybe that's a better timing model?

Herchi:
If you swap the {SLEEP 1000} and {TAB} around, then the Tab could start the 'on change' event that takes a little time, wait the 1000msec and then fill in the password.
Maybe that's a better timing model?
-Ath (January 15, 2018, 05:55 AM)
--- End quote ---
{sendkeys}myname{TAB}{SLEEP 1}password{ENTER}
it works ALWAYS. (with 1 in SLEEP). it's strange. Thanks :D

Ath:
Well, actually it's not strange, but as to be expected:
old situation:
- type username
- wait awhile
- send tab-key and a password and enter-key all at once
== no time for processing

new situation:
- type username and leave field to trigger processing
- allow other processing to run by giving a time-slice back to the system by using sleep
- send password and enter-key so second field can be processed and login handled
== timing is no issue as all processing is allowed when required by the system

voila :)

Navigation

[0] Message Index

Go to full version