heshan Posted April 29, 2010 Posted April 29, 2010 Hi everyone. im new to autoit and having some issues write a script ive tried all over the net,trying putting code segment together but had no luck all i want to do is while im holding down the 4 key (not the number pad 4) i want it to send the keystroke 4 every 1second repeatedly until i take my finger of the 4 key im trying to make a general macro for a game, where in-game holding down a key wont repeat thanks in advance
GEOSoft Posted April 29, 2010 Posted April 29, 2010 #Include<misc.au3> HotKeySet("4", "_Send4") Func _Send4() HotKeySet("4") While _IsPressed("34") Send("4") Sleep(1000) WEnd HotKeySet("4", "_Send4") EndFunc That will be close but might need adjusting. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Fulano Posted April 29, 2010 Posted April 29, 2010 (edited) That will be close but might need adjusting.Interesting thing with that solution, it will continually send the key between the sent key presses. I don't know if that behavior will make any difference in this case or not, but on the off chance that it does, here's a version that will generally only repeat once or twice per interval (at the cost of complexity and an array lookup).Edit: I redacted the code, as it was (correctly) pointed out that it could have been used to make a keylogger, my apologies for the mistake. Edited April 29, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!
GEOSoft Posted April 29, 2010 Posted April 29, 2010 I read it as being; Once he presses the 4 key, he wants to continually sent 4 on a once per second basis. That's what it should do after the hotkey has been unset and it enters the loop. Once the 4 key is released it should exit the loop and reset the hotkey. Unless I screwed up either in the loop or in my interpretation of the request. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Fulano Posted April 29, 2010 Posted April 29, 2010 (edited) Once the Hotkey is unset the OS is free to do it's normal key repetition as it's no longer bound to AutoIt. At least that's what the behavior I observed while testing it seemed to indicate.Setting it to a dummy function was the best compromise I could come up with to block that key until the next send came due. It's a little erratic as sometimes the OS will get an extra one in between releasing the block and resetting it.It's kind of a weird behavior and certainly not what I expected, but it makes sense once you know it's there.Edit: Couldn't resist quoting your sig, '"In theory, theory and practice are the same. In practice, they are not."- Albert Einstein' Edited April 29, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!
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