Jump to content
Sign in to follow this  
AwAke

While _IsPressed Help

Recommended Posts

AwAke

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

Share this post


Link to post
Share on other sites
LimeSeed

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

Share this post


Link to post
Share on other sites
AwAke

Wow, Ty mate. Perfect. Thats exactly what I wanted thanks alot :)

Share this post


Link to post
Share on other sites
LimeSeed

Wow, Ty mate. Perfect. Thats exactly what I wanted thanks alot :)

np


global $warming = true

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  

×