Mausabfrage in Whileschleife - was ist falsch - Hilfe?

  • Bei meinem Skript ist was falsch, aber was. Es misst die zurückgelegte Strecker der Maus in Metern. Aber eben nur die x- und nicht die y-Abweichung, was geht nicht?

    Spoiler anzeigen
    [autoit]

    HotKeySet("{ESC}", "terminate")
    $run = 0
    $pxconst = 0.026458333
    While 1
    $pos = MouseGetPos()
    Sleep(1)
    $tx = MouseGetPos(0)
    $ty = MouseGetPos(1)
    If $tx < $pos[0] Then
    $run = $run + $pos[0] - $tx
    EndIf
    If $tx > $pos[0] Then
    $run = $run + $tx - $pos[0]
    EndIf
    If $ty < $pos[1] Then
    $run = $run + $pos[1] - $ty
    EndIf
    If $ty < $pos[1] Then
    $run = $run + $ty - $pos[1]
    EndIf
    ToolTip("Meter: "&Round($run*$pxconst/100, 2))
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func terminate()
    Exit
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von campweb (12. Februar 2011 um 10:23)

  • Hey Campweb,
    dein Fehler ist ein '<' in Zeile 18. Dort müsste, damit es funktioniert ein '>' sein.
    Tipp: deine pxconst ist bei mir glaubich falsch 0.o.
    Hier das korrigierte Script:

    Spoiler anzeigen
    [autoit]


    HotKeySet("{ESC}", "terminate")
    $run = 0
    $pxconst = 0.026458333
    While 1
    $pos = MouseGetPos()
    Sleep(1)
    $tx = MouseGetPos(0)
    $ty = MouseGetPos(1)
    If $tx < $pos[0] Then
    $run = $run + $pos[0] - $tx
    EndIf
    If $tx > $pos[0] Then
    $run = $run + $tx - $pos[0]
    EndIf
    If $ty < $pos[1] Then
    $run = $run + $pos[1] - $ty
    EndIf
    If $ty > $pos[1] Then
    $run = $run + $ty - $pos[1]
    EndIf
    ToolTip("Meter: "&Round($run*$pxconst/100, 2))
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func terminate()
    Exit
    EndFunc

    [/autoit]

    P.S.: Mein Rekord liegt bei ~1000m in 5 Sek (natürlich mit Autoit Script xD)

    Meine Werke


    EasyScreen (teilweise Crocoframe): <EasyScreen>
    Spotify2Title: <Spotify2Title> (zur Info, dies ist KEIN Spotify-Downloader! Wer das dachte... :rofl: sowas gibts hier nicht :thumbdown: )

  • danke, ich werds jetzt releasen :D

    EDIT: Bei mir krieg ich höchstens 8 meter in 5 sec hin, versuch doch mal mein 3000 Pixel Lauf skript :D