Jump to content

While _IsPressed Help


AwAke
 Share

Recommended Posts

Ok I want a function to, while the key 'A' or 'D' is pressed it will count the amount of miliseconds until the key is then released.

After it gets the time I would then like to log it into a file.

I have a script atm I just cant get out of the loop, all help is appreciated;

#include <Misc.au3>
Opt("WinTitleMatchMode", 4)
$hwnd = WinGetHandle("classname=GxWindowClassD3d")
$dll = DLLOpen("user32.dll")
Global $start, $ExitLoop

While 1 
    While _IsPressed("41" OR "44", $dll)
        $start = TimerInit()
        $ExitLoop = 1
    WEnd
    If $ExitLoop = 1 Then
        ExitLoop
    EndIf
Wend
$end = TimerDiff($start)
$file = FileOpen("C:\txt.txt", 1)
Filewrite($file, $end)
Edited by AwAke
Link to comment
Share on other sites

This should work, but only for the a key, im sure you can add the d key yourself :)

#include "misc.au3"
Dim $key = 0
Dim $dll = 'user32.dll'
while (true)
if (_IsPressed(41, $dll)) Then
    $long = TimerInit()
    while (_IsPressed(41, $dll))
    $d = 1
    WEnd
    $time = TimerDiff($long)
    msgbox(0, "long", "You pressed key for " & $time & " milliseconds")
EndIf
WEnd
global $warming = true
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...