Phylonia Posted January 21 Share Posted January 21 Hello all, I searched for the same thing and had trouble finding how to do it with AutoIt : The subject dates from 2020 and is not resolved. I won't comment on the answers which shock me a little... So I bring the answer to the subject and a new question. To be able to hold a key "{a down}" is not enough, in reality it only sends a key press event. To do a repetition you must return this example: HotKeySet("a","pressInput") $stop= True Func pressInput() $stop= Not $stop If ($stop) Then Send("{a up}") EndIf EndFunc While True If (not $stop) Then Send("{a down}") EndIf Sleep(10) WEnd Now, can someone please explain to me out of curiosity why it is necessary to return a "down" repeatedly? I tested this on several software programs, several games where you have to keep a key pressed and it works perfectly. So this system makes it possible to consider that the key is not released. Thank Link to comment Share on other sites More sharing options...
Solution Nine Posted January 21 Solution Share Posted January 21 (edited) It is the physical keyboard that sends multiple keys when you keep pressing a key. It is not an interpretation of Windows. But Windows knows if a key is pressed or not. So in order to send multiple keys (like a keyboard would do), you need to send multiple down. If you just send a key without the down option then up is also sent. Here an illustration of it : #include <WinAPISys.au3> #include <Misc.au3> Run("notepad") WinWait("[CLASS:Notepad]") Send("{a down}") For $i = 1 To 20 ConsoleWrite(_IsPressed("41") & @CRLF) Sleep(100) If $i = 10 Then Send("a") Next ConsoleWrite("======= next phase ========" & @CRLF) Send("{a down}") For $i = 1 To 20 ConsoleWrite(_IsPressed("41") & @CRLF) Sleep(100) Send("{a down}") Next ConsoleWrite("======= final phase ========" & @CRLF) Send("{a up}") ConsoleWrite(_IsPressed("41") & @CRLF) Edited January 21 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now