Sign in to follow this  
Followers 0
Guest PapyToxik

send() problem

28 posts in this topic

#1 ·  Posted (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 :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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Are you sure it's supposed to wait before holding the key down ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 :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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#7 ·  Posted (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
WEnd

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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... ;)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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}")

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

i would :

Send("{e down}")
$start = TimerInit()
while TimerDiff($start) < 10000
sleep(100)
wend
Send("{e up}")

<{POST_SNAPBACK}>

nopper... doesn't work on mine

8)


NEWHeader1.png

Share this post


Link to post
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")

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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

Share this post


Link to post
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...


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#20 ·  Posted (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 by Valuater

NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0