Jump to content

WayPointCreator for Games?


Zephir
 Share

Recommended Posts

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

  • Moderators

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)

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

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:

Link to comment
Share on other sites

  • Moderators

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.

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

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

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

  • Moderators

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?

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

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

  • Moderators

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

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

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