Sign in to follow this  
Followers 0
elitesoldier

how to hold down a key

10 posts in this topic

hi i want to use the send command to hold down a key and let go after a certain amount of time that i set. I was thinking of doing it this way but don't know how to make autoit v3 hold down a key.

Send ("{END}") (---but holds it down and doesn't let go.

Sleep ("5000") (----delay, while still holding down END key.

Send ("{END}") (----lets go of END key.

thx for your time and help :whistle:

Share this post


Link to post
Share on other sites



nvm guys i just remapped my keyboard to work with the commands that allow to hold a key down.

Share this post


Link to post
Share on other sites

That's exactly the syntax that Robert Yaklin and I came up with for AutoHotkey, though it hasn't yet been added. When you think about it, I guess it's the about the only logical way to do it.

Share this post


Link to post
Share on other sites

I;ve justed added something to the unstable version that may work in games:

http://www.hiddensoft.com/autoit3/files/unstable/

Send ("{END down}")
Sleep (5000) 
Send ("{END up}")
Jon, Did you do the same for {LEFT ...}{RIGHT ....}{UP ...}{DOWN ...} ??? (Gave it a try but didn't work...)

see: http://www.hiddensoft.com/forum/index.php?...t=15entry1966


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Jon, Did you do the same for {LEFT ...}{RIGHT ....}{UP ...}{DOWN ...} ??? (Gave it a try but didn't work...)

see: http://www.hiddensoft.com/forum/index.php?...t=15entry1966

It's doesn't "do" anything in windows (and it would be no use anyway), but in games it does - I tried it in "Call of Duty" and made it hold down the left key for 5 seconds (right into a bullet :whistle: )

It works for all keys, Larry, for A it would be:

Send("{a down}")

Share this post


Link to post
Share on other sites

Just for some smaller syntax possible to change to this

send("what to send",[optional duration])

It would send each key seperately holding it down and then releasing after optional time.

I don't know.... just thinking.

red

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Maybe this would be an example of a user function.

run("notepad.exe")
sleep(2000)
HoldSend("abcde",2000)
exit

Func HoldSend($a,$b)

$count = stringlen($a)
for $i = 1 to $count
  $letter = stringmid($a,$i,1)
  Send("{" & $letter & " down}")
  sleep($b)
  Send("{" & $letter & " up}")
next
EndFunc

This was pretty much off the top of my head so there could be errors but I am sure you get the idea.

red

There was problems when I tested this it doesn't repeatedly send characters so maybe it works or maybe not. I can see how it would be not very usefull.

Edited by redndahead

Share this post


Link to post
Share on other sites

i like red's idea, for a duration, that would be pretty nice. or perhaps until something is true? like Send("{w LiftUp=1}"), though i suppose the keyup could just be done with a hotkey or something. i probably will never use anything but the down and up, and possibly the durations

Share this post


Link to post
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
Sign in to follow this  
Followers 0