Jump to content

Recommended Posts

Posted

Hello all.  So I am trying to write what I thought was going to be a simple script, but I am having a surprisingly hard time with it.  I want to have this script just hold down the enter key for a particular length of time.  That is it.  I was initially thinking about using something like this:

Send ( "{ENTER DOWN}", 0 )
Sleep ( 10000 )
Send ( "{ENTER UP}", 0 )

Seemed like something that would work in theory, but in practice (using a notepad document to test) the key does not appear to be held down at all, but simply pressed, as only one line is added to the notepad document.  I even tried something like this hoping it might work:

Opt ("SendKeyDownDelay", 15000)
Send ( "{ENTER DOWN}", 0 )
Sleep ( 5000 )
Send ( "{ENTER UP}", 0 )

But it does the same thing: adding only one line to the notepad document as you would expect when the enter key is pressed, not held down.  Am I doing something wrong/misunderstanding something as to how to do this?

  • Developers
Posted

There is a big difference between the auto-repeat function of the keyboard when a key is pressed and the DOWN function.

Simply make a for...next loop with a Send enter and a Sleep() for the appropriate period to simulate what a keyboard does. :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)
  On 6/4/2019 at 9:10 PM, Jos said:

There is a big difference between the auto-repeat function of the keyboard when a key is pressed and the DOWN function.

Simply make a for...next loop with a Send enter and a Sleep() for the appropriate period to simulate what a keyboard does. :)

Jos

Expand  

Would you mind explaining the difference?  I guess i want to understand why the "down" function is even available if the actions which are normally associated with holding the key down (the auto-repeat) aren't emulated too.  What's the use?😕

Edited by MattHiggs
Posted
  On 6/5/2019 at 1:58 AM, MattHiggs said:

What's the use?

Expand  

Try to imagine how you would implement this : while key A is pressed, press key B.  Without the "down" function it would not be possible to implement it with the Send function.  You would need to use some more sophisticated ways to do it like hooks or messages.

  • Developers
Posted

As stated: The auto repeat is a keyboard function not a system function, so the keyboard sends the repeated keydown/up when holding a key down. 
Since you emulate the keystrokes now with AutoIt3, you need to implement the repeat function in the program. 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...