Joern Posted July 23, 2007 Share Posted July 23, 2007 I asked the question in another posting as well, but it was kinda missplaced. I want to let AutoIt press down AND hold down a key. In the documentation you find something like the following: Send('{w down}') Sleep(5000) Send('{w up}') This always hits the key only 1 time even if I use SPACE instead. Any ideas? I am using XP SP2 and downloaded AutoIt 2 days ago if that matters jb Link to comment Share on other sites More sharing options...
MHz Posted July 23, 2007 Share Posted July 23, 2007 That is correct. "w" or SPACE does not support a held down state at the API level. Your keyboard driver may allow continuous presses while the key is held down but that is the KB driver doing that. Only the modifier keys such as SHIFT, CTRL... support the DOWN and UP condition. If you want other keys to act like your KB does, then you may need to use a loop. To get the held DOWN effect using a loop Opt('SendKeyDelay', 50); Default speed _Send('w', 5000) Func _Send($text, $milliseconds) $time = TimerInit() Do Send($text) Until TimerDiff($time) > $milliseconds EndFunc Link to comment Share on other sites More sharing options...
ofLight Posted July 23, 2007 Share Posted July 23, 2007 Opt("SendKeyDownDelay", 5000) ;5 second delay Send("w") Opt("SendKeyDownDelay", 5) ;reset to default when done There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
SadBunny Posted July 23, 2007 Share Posted July 23, 2007 That is correct. "w" or SPACE does not support a held down state at the API level. Your keyboard driver may allow continuous presses while the key is held down but that is the KB driver doing that. Only the modifier keys such as SHIFT, CTRL... support the DOWN and UP condition. If you want other keys to act like your KB does, then you may need to use a loop. To get the held DOWN effect using a loop Opt('SendKeyDelay', 50); Default speed _Send('w', 5000) Func _Send($text, $milliseconds) $time = TimerInit() Do Send($text) Until TimerDiff($time) > $milliseconds EndFunc Just puzzled here... You are contradicting the help file on two things, what is the story here? I was trying to use something like this too, would like to understand it better. 1) To hold a key down (generally only useful for games) Send("{a down}") ;Holds the A key down Send("{a up}") ;Releases the A keyLooks like you should be able to hold down a letter? What else would this mean? 2) SendKeyDelay - <...> Time in milliseconds to pause (default=5)I guess this might be a typo? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Siao Posted July 23, 2007 Share Posted July 23, 2007 (edited) Not to mention that _IsPressed (which uses API to get key state) returns true during that 5 second sleep between {w DOWN} and {w UP}. Edited July 23, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Joern Posted July 28, 2007 Author Share Posted July 28, 2007 No one has a solution? jb Link to comment Share on other sites More sharing options...
MHz Posted July 28, 2007 Share Posted July 28, 2007 Just puzzled here... You are contradicting the help file on two things, what is the story here? I was trying to use something like this too, would like to understand it better.1)Looks like you should be able to hold down a letter? What else would this mean?2) I guess this might be a typo?I am not contradicting the help file. The help states a tip on a method for generally useful for games. That does not state the same use of a keyboard into a application such as notepad. If you try your shown code then try my example I have shown then you will see a difference. Testing my example compared to the help file example in notepad will show the difference.1) It means that you can hold down a letter, but it will not repeat sending like a keyboard driver does normally. If software (such as a game) hooks the keyboard input then a different effect can happen with a key press. A concept comes to mind in games is analog and digital input which affects the operation of the keyboard.2) The comment relates to the code usage. "Pause" affects the send speed, correct? @JoernCan you describe how you are using the Send function so others do not have to play the game of guessing a solution for you? Link to comment Share on other sites More sharing options...
Joern Posted August 6, 2007 Author Share Posted August 6, 2007 @JoernCan you describe how you are using the Send function so others do not have to play the game of guessing a solution for you?Sure I can but I thouhgt I already did. Maybe I miss the point. For the controling of an avatar in a computer game I would like to press and hold down a specific key. I found something about this in the documentation. I tried thisSend('{w down}')Sleep(5000)Send('{w up}')This does not work. It sends the key "w" here only once. Is this specific enough? If not, please let me know what infos would be needed.Thanks for taking your time.jb Link to comment Share on other sites More sharing options...
Ghoul2020 Posted January 31, 2020 Share Posted January 31, 2020 On 7/23/2007 at 10:35 AM, Joern said: I asked the question in another posting as well, but it was kinda missplaced. I want to let AutoIt press down AND hold down a key. In the documentation you find something like the following: Send('{w down}') Sleep(5000) Send('{w up}') This always hits the key only 1 time even if I use SPACE instead. Any ideas? I am using XP SP2 and downloaded AutoIt 2 days ago if that matters jb Greetings Opt("SendKeyDownDelay", 5000) Send('{RWIN DOWN}' & '{D DOWN}') ; in this example I used the RIGHT "windows" key down + "D" down (Minimize&Maximize active window) Send ("{D UP}") Send("{RWIN UP}") :) Greetings KowalBrudu 1 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 31, 2020 Moderators Share Posted January 31, 2020 @Ghoul2020 did you notice this thread is 13 years old? I doubt the OP is hanging about hoping for an answer still. Please refrain from resurrecting ancient threads. Ghoul2020 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts