topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 16, 2018, 10:34 AM
  • Proudly celebrating 13 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: delay IN sendkeys?  (Read 1015 times)

Herchi

  • Participant
  • Joined in 2014
  • *
  • Posts: 10
    • View Profile
    • Donate to Member
delay IN sendkeys?
« on: January 15, 2018, 04:11 AM »
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.
« Last Edit: January 15, 2018, 04:17 AM by Herchi »

anandcoral

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 578
    • View Profile
    • App, to help you : Overlap Wallpaper, Park Cursor Aside, Stick A Note, Merge CSV and Text and many more.
    • Donate to Member
Re: delay IN sendkeys?
« Reply #1 on: January 15, 2018, 04:49 AM »
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

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,292
    • View Profile
    • Donate to Member
Re: delay IN sendkeys?
« Reply #2 on: January 15, 2018, 05:55 AM »
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

  • Participant
  • Joined in 2014
  • *
  • Posts: 10
    • View Profile
    • Donate to Member
Re: delay IN sendkeys?
« Reply #3 on: January 15, 2018, 06:34 AM »
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?
{sendkeys}myname{TAB}{SLEEP 1}password{ENTER}
it works ALWAYS. (with 1 in SLEEP). it's strange. Thanks :D

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,292
    • View Profile
    • Donate to Member
Re: delay IN sendkeys?
« Reply #4 on: January 15, 2018, 01:00 PM »
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 :)