Jump to content

How to use Send("{space}") and hold key down


Recommended Posts

ok im tring to make this basic program thingy for fun and i never tried holding down a key. this basic expamle of what i mean

while 1

Send("{space}") ; i want it to hold down this space for 3 secs

sleep(1000)

wend

I seen the opt("holdkeydown") or w/e command but i didnt know how to use it. Can someone show me what i have to do please.

Thanks Kevin,

Link to comment
Share on other sites

ok im tring to make this basic program thingy for fun and i never tried holding down a key. this basic expamle of what i mean

while 1

Send("{space}")  ; i want it to hold down this space for 3 secs

sleep(1000)

wend

I seen the opt("holdkeydown") or w/e command but i didnt know how to use it. Can someone show me what i have to do please.

Thanks Kevin,

<{POST_SNAPBACK}>

you mean something like?

Run("notepad")
WinWait("Untitled - Notepad")
WinActivate("Untitled - Notepad")
$timer = TimerInit()
while 1
    Send("{space}"); i want it to hold down this space for 3 secs
    If(TimerDiff($timer) > 3000) then ExitLoop
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

No, I think that will tap the space key for 3 seconds.

Try this:

Send('{space down}')
Sleep(3000)

<{POST_SNAPBACK}>

:( already tried that and other variations, the timer worked, couldn't find anything to hold it down for 3 seconds, just keep tapping it for 3 seconds

the keydowndelay will hold the keydown, but doesn't space for that time.

Edit: the above loop would only give you 3 spaces.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

So you're saying the down keyword doesn't work? ... What's the use of it then?

<{POST_SNAPBACK}>

No it does hold it down, just doesn't work in the way your thinking it would work, not like when we hit the key and hold it down.

It is worth something, showed someone else how to use it when sending alot of text to word, without setting the delay the cpu was at 98%, set a delay of about 10ms instead of 5ms and the cpu usage dropped below 50%.

Edit: correction it was KeyDelay in that example, either way not going to work for this.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • 10 years later...
On ٢١‏/٥‏/٢٠٠٥ at 4:13 AM, GaryFrost said:

Opt("SendKeyDownDelay",3000)

THANK YOU.

 

God, why isn't this part mentioned in the send key doc ? Many programs cannot register a key press reliably - if at all - without it. It could save people a lot of time and nerve damage. 

 

While searching this problem I found tons of threads with the same exact problem with no solution, I almost gave up thinking it can't be done directly with AutoIt, and I'm sure many people actually did.

 

Sorry for the necro by the way, had to vent.

Link to comment
Share on other sites

It already is in the help documentation for Send()

https://www.autoitscript.com/autoit3/docs/functions/Send.htm

Quote

Opt("SendKeyDelay",...) alters the the length of the brief pause in between sent keystrokes.
Opt("SendKeyDownDelay",...) alters the length of time a key is held down before being released during a keystroke.
Set both "SendKeyDelay" and "SendKeyDownDelay" to 0 to remove all delays when sending keystrokes. This may be required under certain circumstances, for example, when locking the system ("#l") it may be necessary to remove the delays in order to prevent the WIN key from being stuck down.

 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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