Guest PapyToxik Posted September 8, 2005 Posted September 8, 2005 (edited) Hi everyone, I'm using AutoIt in a game and I'm really happy about it. But I've a little problem using the send() function. opt("SendKeyDownDelay",10000) send("e") With this code, the E key will be pressed for 10 seconds (that's what you think ) but in fact the program waits 10 seconds, and then press the key for 10 seconds. That's really really weird and I don't know why it does that... I'd like the key to be pressed for 10 seconds as quick as possible... Thanks, PapyToxik (sorry for my poor English ) Edited September 8, 2005 by PapyToxik
theguy0000 Posted September 8, 2005 Posted September 8, 2005 thats what its supposed to do The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
Guest PapyToxik Posted September 8, 2005 Posted September 8, 2005 Are you sure it's supposed to wait before holding the key down ?
theguy0000 Posted September 8, 2005 Posted September 8, 2005 (edited) looked it up it the manual and it says ts supposed to tell how long the key is hold down. guess i was wrong that is very wierd. sorry, i cant help.- Matt Edited September 8, 2005 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
CodeMaster Rapture Posted September 8, 2005 Posted September 8, 2005 I know people are against showing exactly how to do it, but since it would take alot of reading, I'll break it down for ya. So you want to send "E" as often as possible for 10 seconds? If that is the case, then let's try this: ;Check the helpfile for TimerInit() and TimerDiff(). $Start = TimerInit() $End = 0 While 1 $End = TimerDiff($Start) If ($End < 10000) Then Send("e") $Start = TimerInit() $End = 0 EndIf Sleep(10) WEnd This will achieve 2 things. One, it will send E about 900 times in 10 seconds. Second, it will allow you do run the rest of your script ---without pausing it until your keypresses are done. Method 2: While 1 For $loop = 0 to 200 Step 1 Send("e") Sleep(50) Next WEnd Smaller code, but will pause your script while it is sending E. This will only send E 200 times, but you can fiddle with the loop and Sleep(). Hope this helps, -CMR
jefhal Posted September 8, 2005 Posted September 8, 2005 thats what its supposed to do<{POST_SNAPBACK}>Looks to me like it should work as Popytoxik expects:SendKeyDownDelay: Alters the length of time a key is held down before released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default.Time in milliseconds to pause (default=1).What TheGuy0000 describes looks more like:SendKeyDelay: Alters the the length of the brief pause in between sent keystrokes.Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead. ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Valuater Posted September 8, 2005 Posted September 8, 2005 (edited) $Start = TimerInit() $End = 0 While 1 $End = TimerDiff($Start) If ($End < 10000) Then Send("e") $Start = TimerInit() $End = 0 EndIf Sleep(10) WEnd<{POST_SNAPBACK}>This doesn't work because you keep resetting but this will$begin = TimerInit() While 1 Send("e") $dif = TimerDiff($begin) if $dif >= 10000 Then MsgBox(0,"Time Difference",$dif) ExitLoop EndIf WEnd8) Edited September 8, 2005 by Valuater
theguy0000 Posted September 8, 2005 Posted September 8, 2005 Looks to me like it should work as Popytoxik expects:What TheGuy0000 describes looks more like:<{POST_SNAPBACK}>-->looked it up it the manual and it says ts supposed to tell how long the key is hold down. guess i was wrong that is very wierd. sorry, i cant help.- Matt <{POST_SNAPBACK}> The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
LxP Posted September 8, 2005 Posted September 8, 2005 With this code, the E key will be pressed for 10 seconds (that's what you thinkĀ ) but in fact the program waits 10 seconds, and then press the key for 10 seconds. That's really really weird and I don't know why it does that...<{POST_SNAPBACK}>Yes, I receive the same behaviour. I think that perhaps it is a bug.
jpm Posted September 8, 2005 Posted September 8, 2005 I face this problem long time ago and the Jon answer is NO BUG. the SendKeyDelay apply to each stroke and in this case they are 2 of them. I don't remember why. But at that time I was convinced. Perhaps Jon can reexplain...
LxP Posted September 8, 2005 Posted September 8, 2005 I can understand the logic behind this behaviour, however to me it would make more sense for the extra pause to occur after the key is released, i.e. key down, pause, key up, pause and not the current behaviour of pause, key down, pause, key up.Even then, I was heavily under the impression that the SendKeyDelay directive would control the delay between keys.
Moderators SmOke_N Posted September 8, 2005 Moderators Posted September 8, 2005 Even then, I was heavily under the impression that the SendKeyDelay directive would control the delay between keys.<{POST_SNAPBACK}>"Ditto"I've used the method that CMR and Valauter have posted to do things of this nature. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
jpm Posted September 8, 2005 Posted September 8, 2005 There is 2 different delays SendKeyDelay and SendKeyDownDelay so no confusion I check the code and perhaps there is a bug an extra SendKeyDownDelay at the end. I am checking before Jon explanation.
jpm Posted September 8, 2005 Posted September 8, 2005 I did a correction for 3.1.1.75. I hope the gamer's will not be affected by the suppression of extra delay. The bug is also in the official release.
seandisanti Posted September 8, 2005 Posted September 8, 2005 Hi everyone,I'm using AutoIt in a game and I'm really happy about it.But I've a little problem using the send() function.opt("SendKeyDownDelay",10000) send("e")With this code, the E key will be pressed for 10 seconds (that's what you thinkĀ ) but in fact the program waits 10 seconds, and then press the key for 10 seconds. That's really really weird and I don't know why it does that...I'd like the key to be pressed for 10 seconds as quick as possible...Thanks,PapyToxik(sorry for my poor EnglishĀ )<{POST_SNAPBACK}>i would :Send("{e down}") $start = TimerInit() while TimerDiff($start) < 10000 sleep(100) wend Send("{e up}")
Valuater Posted September 8, 2005 Posted September 8, 2005 i would :Send("{e down}") $start = TimerInit() while TimerDiff($start) < 10000 sleep(100) wend Send("{e up}")<{POST_SNAPBACK}>nopper... doesn't work on mine8)
seandisanti Posted September 8, 2005 Posted September 8, 2005 nopper... doesn't work on mine8)<{POST_SNAPBACK}>are you sure? i added some debugging steps here to test... _ispressed is required, or beta#include <ispressed.au3> Send("{e down}") ToolTip("e down") $start = TimerInit() while TimerDiff($start) < 10000 sleep(100) if not _IsPressed(45) then msgbox(0,"oops","e key is not down") wend Send("{e up}") if not _IsPressed(45) then msgbox(0,"oops","e key is now up")
Valuater Posted September 8, 2005 Posted September 8, 2005 are you sure? i added some debugging steps here to test... _ispressed is required, or beta#include <ispressed.au3> Send("{e down}") ToolTip("e down") $start = TimerInit() while TimerDiff($start) < 10000 sleep(100) if not _IsPressed(45) then msgbox(0,"oops","e key is not down") wend Send("{e up}") if not _IsPressed(45) then msgbox(0,"oops","e key is now up")<{POST_SNAPBACK}>does the same thing... it sends "e" one time..the user wants to send "e" as many times a possible in the 10 seconds8)
seandisanti Posted September 8, 2005 Posted September 8, 2005 does the same thing... it sends "e" one time..the user wants to send "e" as many times a possible in the 10 seconds8)<{POST_SNAPBACK}>i think one of us may be misinterpretting his intent... (would not be a first for me) to me it looks like he wants the key held for ten seconds, but is unhappy with the 10 second delay prior to the send.With this code, the E key will be pressed for 10 seconds (that's what you thinkĀ ) but in fact the program waits 10 seconds, and then press the key for 10 seconds. That's really really weird and I don't know why it does that...
Valuater Posted September 8, 2005 Posted September 8, 2005 (edited) i think one of us may be misinterpretting his intent... (would not be a first for me) to me it looks like he wants the key held for ten seconds, but is unhappy with the 10 second delay prior to the send.<{POST_SNAPBACK}>it's the next line that states "pressed for 10 seconds as quickly as possible..."opt("SendKeyDownDelay",10000) send("e")With this code, the E key will be pressed for 10 seconds (that's what you thinkĀ ) but in fact the program waits 10 seconds, and then press the key for 10 seconds. That's really really weird and I don't know why it does that...I'd like the key to be pressed for 10 seconds as quick as possible...<{POST_SNAPBACK}>but your are correct with your code "holding down" the "e" key.8) Edited September 8, 2005 by Valuater
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