Jump to content

send() problem


Guest PapyToxik
 Share

Recommended Posts

Guest PapyToxik

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 :dance: ) 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 :whistle: )

Edited by PapyToxik
Link to comment
Share on other sites

looked it up it the manual and it says ts supposed to tell how long the key is hold down. guess i was wrong :dance: that is very wierd. sorry, i cant help.

- Matt :whistle:

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

$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
WEnd

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

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 :dance: that is very wierd. sorry, i cant help.

- Matt :whistle:

<{POST_SNAPBACK}>

:dance:

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

With this code, the E key will be pressed for 10 seconds (that's what you thinkĀ  :whistle: ) 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.
Link to comment
Share on other sites

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... ;)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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Ā  :P ) 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}")
Link to comment
Share on other sites

nopper... doesn't work on mine

8)

<{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")
Link to comment
Share on other sites

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 seconds

8)

NEWHeader1.png

Link to comment
Share on other sites

does the same thing... it sends "e" one time..

the user wants to send "e" as many times a possible in the 10 seconds

8)

<{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...

Link to comment
Share on other sites

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 by Valuater

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...