Jump to content

Send key error in Do loop


Recommended Posts

So I'm having it read which key to hold down for a certain time. What I got in my .ini file is:

[Msg]
msgbox=no
[Coords]
sd1=key
time1=817.722764719572
key1=H
held1=104.254291545085
sd2=key
time2=10.6058828162761
key2=E
held2=107.66813268649
sd3=key
time3=125.206094412918
key3=Y
held3=54.5377780562468

Which is fine... But when I replay it, it replays something like this (not to the exact letter, but you get the idea :o)

HHHHHHHHHEEEEEEEEEEEEEEEEEEYYYYYYYYYYYYYYYYYYY

My code thats messing it up:

$hold = IniRead($inir, "Coords", "held"&$read, "" )
        $initre = TimerInit()
        Do
            Send("{"&$replaykey&"}");-- 
            $diffre = TimerDiff($initre)
        Until $diffre >= $hold

It SHOULD stop the Do loop once it reads that the timer = or > $hold... Which $hold = the time that the key was held down... So I really have no idea what is going on ><.

P.S. I tried adding a Sleep(100), but that slowed down the key presses dramatically and STILL it did not work... It went like:

HHEEYY

So better but it was much slower... To type all that it took 500 milliseconds, which it shouldn't have to take that long.

If you want to hold the key down, it would be:
$initre = TimerInit()
Send("{" &  $replaykey & " down}")
Do
Until TimerDiff($initre) >= $hold
Send("{" &  $replaykey & " up}")

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

If you want to hold the key down, it would be:

$initre = TimerInit()
Send("{" &  $replaykey & " down}")
Do
Until TimerDiff($initre) >= $hold
Send("{" &  $replaykey & " up}")

:)

I thought of that but does just putting (space)down work for EVERY key... So like these ALL would work?

F1 Down

A Down

Space Down

etc

And what about keys such as CTRL, those have a certain function for using them: CTRLDOWN... Won't I need to devise something else to read if its those such keys or will it still work as: Ctrl Down ?

Link to comment
Share on other sites

Fixed it... but a new problem...

Beings AutoIt cannot read multiple lines at one time, how can I have it say hold SHIFT down for 30 seconds and then type aaaaaa (which would normally read at AAAAAA), but when Shift if held down, it ONLY does that for 30 seconds, THEN it moves on and does the A's.... which its too late :)

Any ideas?

Also in my record, when I hold down Shift and type aaaa, it doesn't records the A's because while Shift is being held its doing the timer to get how long its being held down then writes the held down in the .ini... So it doesn't even record the A's.... would I have to create multiple timers for more keys to be able to be pressed?

Link to comment
Share on other sites

Fixed it... but a new problem...

Beings AutoIt cannot read multiple lines at one time,

What does that mean? What are you trying to do? Multiple lines of what?

how can I have it say hold SHIFT down for 30 seconds and then type aaaaaa (which would normally read at AAAAAA), but when Shift if held down, it ONLY does that for 30 seconds, THEN it moves on and does the A's.... which its too late :o

Any ideas?

Also in my record, when I hold down Shift and type aaaa, it doesn't records the A's because while Shift is being held its doing the timer to get how long its being held down then writes the held down in the .ini... So it doesn't even record the A's.... would I have to create multiple timers for more keys to be able to be pressed?

Explain what you are doing. None of that made sense. Send() will not trigger the keyboard's auto-repeat. And what are you recording, and how? Is this for a game?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

What does that mean? What are you trying to do? Multiple lines of what?

Explain what you are doing. None of that made sense. Send() will not trigger the keyboard's auto-repeat. And what are you recording, and how? Is this for a game?

:)

Its not a keylogger... I'm just making a macro-recorder program, on top of all the other ones on the internet... But this way I can adapt the hotkeys to what I LIKE and I can change the program to what I LIKE and add other stuff maybe for a game I used to play and code in some Memory with the record functions.

If you would like me to send you my script, I can do it in a PM... I suppose with some fine-tuning this bot COULD become a keylogger which is why I am not releasing the script here in the full source. You will be able to tell easily with some of the options in the recording it has no intention of being used as a key logger.

Post #4 of mine has the last 2 problems of my script... The last problem stated where it cannot record both keys at once (I gave an example of Shift and a) that COULD be solved by doing If _IsPressed(shift) AND _IsPressed(a) Then: blah..... I know thats not the correct coding, but you get the idea.

The only problem with doing that though is I would have to have a combination of ALL keys and thats probably millions beings you can hold down 2+ at once to do a task... Thats why I created the DOWN function so I can have a key held down, have how long its recorded and also then record other keys (which don't work with more than 1 key being held down right now, need help on that too :S) so when its replayed it will go like: SHIFTDOWN *10 seconds down*, a, a, a, a *10 seconds up*.

I hope you can understand what I am getting at, I just need help with FIRST recording more than 1 key, I'm guessing I will need to incorporate more timers? And then second to replay these by having it hold 1 key down, WHILE it is moving on with the script, EX: pressing the A's.

What MadMan gave is sort of like what I need but I what if I would have multiple keys being held down, the program wouldn't know which Send($variable from .ini) to use.

If someone trusted (I'm not giving my script to some noob) would like to help me, I can send you my script in a PM so you have a whole picture of what it looks like and where my problems are occuring.

Thanks

/rant

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