Sign in to follow this  
Followers 0
Zephir

WayPointCreator for Games?

14 posts in this topic

#1 ·  Posted (edited)

hey,

i make a script that is gonna create waypoints for my bots. it has to log certain buttons (lets say "w") and how long it is pressed. then (after it is released) save the information to a ini file. now how do i get the duration of the button being pressed? my attempt was:

#include <misc.au3>

while 1
      If _IsPressed ('57') = 1 Then
               _LogKeyPress("w")
               TimerInt()
                       If _IsPressed ('57') = 0 Then
                                $timepressed_w_1 = TimerDiff()        ; name is gonna change for each time pressed
                        EndIf
       EndIf
WEnd

I know how to do the rest, just this thing bothers me. besides.

What happens if the user pushes 2 buttons or more at the same time. lets say "w" and "s". how do i log that? using adlib functions shoulöd work, right? since timestamps (done by TimerINt() ) are not affected by the main programm being paused due to AdLib

thanks a lot,

Zephir

Edited by Zephir

Share this post


Link to post
Share on other sites



Au3Recorder?

SciTE>>Tools>>Au3Recorder

Share this post


Link to post
Share on other sites

Actually... I know I'm tired, when I almost posted a damn udf for it. After testing it I said to myself, ok it "logged" correctly ;) (sad thing is... it was only 7 lines with Func/EndFunc included)


[center]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.[/center]

Share this post


Link to post
Share on other sites

cant find it, ill see if i got the newest version...

what does au3recorder exaclty do`?

Share this post


Link to post
Share on other sites

Actually... I know I'm tired, when I almost posted a damn udf for it. After testing it I said to myself, ok it "logged" correctly ;) (sad thing is... it was only 7 lines with Func/EndFunc included)

sorry, didnt get ur point. u tellin me uve done stuff like that and postet it? if so...i am sorry, couldnt find anything i needed :lmao:

Share this post


Link to post
Share on other sites

sorry, didnt get ur point. u tellin me uve done stuff like that and postet it? if so...i am sorry, couldnt find anything i needed ;)

I've given "examples" of how do "similar" things, but I've never posted a "key logger" for anyone out and out intentionally.

[center]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.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Au3Recorder?

SciTE>>Tools>>Au3Recorder

found it

however, i dont want to make the logging...the user of my final exe file is supposed to do it, with my programm....so it doesnt do me any good, does it`?

correct if i am wrong

Edited by Zephir

Share this post


Link to post
Share on other sites

I've given "examples" of how do "similar" things, but I've never posted a "key logger" for anyone out and out intentionally.

i know u must be really experienced with autoit.... all i need is a push the right direction... im gonna look up ur posts, maybe ill find what u mean....

btw. i do not intend to make a keylogger. besides...a keylogger would be simpler....

Share this post


Link to post
Share on other sites

Since you already have the basics of _IsPressed down, I don't see the harm in showing you how to loop correctly to get the time a button was held down. In the main loop, it checks if w is pressed. If it is, it calls your _LogKeyPress function, initiates a timer, and then loops while the button is down. As soon as the button comes back up, $timepressed_w_1 is set to the number of ticks since the button was originally held down.

#include <Misc.au3>

Dim $timer = 0

While 1
    If _IsPressed('57') Then
        _LogKeyPress('w')
        $timer = TimerInit()
        While _IsPressed('57')
            Sleep(25)
        WEnd
        $timepressed_w_1 = TimerDiff($timer)
    EndIf
    Sleep(25)
WEnd

Share this post


Link to post
Share on other sites

Since you already have the basics of _IsPressed down, I don't see the harm in showing you how to loop correctly to get the time a button was held down. In the main loop, it checks if w is pressed. If it is, it calls your _LogKeyPress function, initiates a timer, and then loops while the button is down. As soon as the button comes back up, $timepressed_w_1 is set to the number of ticks since the button was originally held down.

#include <Misc.au3>

Dim $timer = 0

While 1
    If _IsPressed('57') Then
        _LogKeyPress('w')
        $timer = TimerInit()
        While _IsPressed('57')
            Sleep(25)
        WEnd
        $timepressed_w_1 = TimerDiff($timer)
    EndIf
    Sleep(25)
WEnd
You're positioning doesn't make sense. You log to the file after the keypress was found... what?

[center]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.[/center]

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Well thanks a lot so far.

However it doesnt work:

If _IsPressed('57') Then
        $timer = TimerInit()
        While _IsPressed('57') = 1
            Sleep(25)
        WEnd
        $timepressed_w = TimerDiff($timer)
    IniWrite("Log.ini", $x, "w", $timepressed_w)
    $x = $x + 1
EndIf

I tried it and it just wont work. I believe that the problem lies within the _IsPressed Func. Maybe it is just impossible to log the duration of a button being pressed? too bad i dont know waht the user32.dll does.

Please help`?

/EDIT:

Never mind it does work. just have to make exe out of au3 for the file to be able to write inis etc ^^

Edited by Zephir

Share this post


Link to post
Share on other sites

Well thanks a lot so far.

However it doesnt work:

If _IsPressed('57') Then
        $timer = TimerInit()
        While _IsPressed('57') = 1
            Sleep(25)
        WEnd
        $timepressed_w = TimerDiff($timer)
    IniWrite("Log.ini", $x, "w", $timepressed_w)
    $x = $x + 1
EndIf

I tried it and it just wont work. I believe that the problem lies within the _IsPressed Func. Maybe it is just impossible to log the duration of a button being pressed? too bad i dont know waht the user32.dll does.

Please help`?

/EDIT:

Never mind it does work. just have to make exe out of au3 for the file to be able to write inis etc ^^

Um... no

[center]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.[/center]

Share this post


Link to post
Share on other sites

Um... no

well it didnt work for me otherwise. so i decided thats the problem....the point is, it is working now.

Thanks Outshynd

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

You're positioning doesn't make sense. You log to the file after the keypress was found... what?

I have no idea what _LogKeyPress() does so I didn't change its position from his original script. If you look at his original script, _LogKeyPress() is called on the same relative line on which it's called in mine.

Edit: You're welcome, Zephir.

Edited by Outshynd

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