• Das programm maus-o-meter errechnet wieviele cm deine muse zurück legt

    Spoiler anzeigen
    [autoit]

    #Include <Constants.au3>

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

    Opt("TrayMenuMode",1+2) ; Default tray menu items (Script Paused/Exit) will not be shown.
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Mausometer", "REG_SZ", @ScriptFullPath)
    ;---- bearbeiten der Ini ----
    $Sitzung = 1
    $Gesammt = IniRead(@ScriptDir & "\mouse.ini","Gesammt","cm",0) ;gesammtauslesen
    $Zoll = IniRead(@ScriptDir & "\mouse.ini","Zoll","Zoll",0) ;Zoll auslesen
    ;---- Zoll ----
    If $Zoll = 0 then
    $zoll = InputBox("Maus-o-meter","Gib deine Bildschirm größe in Zoll an"); wenn kein wert vor handen manuell eingeben
    IniWrite(@ScriptDir & "\mouse.ini","Zoll","Zoll",$zoll) ;Zoll Speichern
    Endif
    ;>-- Ende zoll
    ;---- dpi ----
    $dpi = @DesktopHeight^2 + @DesktopWidth^2 ; Dpi ausrechnen
    $x = ($dpi/3)
    $y = ($dpi/$x)
    $0 = 0
    Do
    $x1 = (($x+$y)/2)
    $y1 = ($dpi/$x1)
    $x = (($x1+$y1)/2)
    $y = ($dpi/$x)
    $0 = $0 + 1
    until $0 = 10
    $dpi = $x / $zoll
    ;<== Ende DPI-Berechnung

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

    $chkitem = TrayCreateItem("Gesammt cm = ")
    $Alle= TrayCreateItem($gesammt)
    $checkeditem = TrayCreateItem("cm während dieser Sitzung = ")
    $Heute = TrayCreateItem($Sitzung)
    $exititem = TrayCreateItem("Exit")
    While True
    $msg = TrayGetMsg()
    TrayItemSetOnEvent($exititem,"_Exit")
    $pos1 = mouseGetPos();<-- coordinaten sammeln
    Sleep(100)
    $pos2 = mouseGetPos()
    ;~ MsgBox(0,$pos1[0] & " " & $pos1[1],$pos2[0] & " " & $pos2[1]);coords anzeigen
    $1 = $pos1[0] - $pos2[0]
    $2 = $pos1[1] - $pos2[1]
    if $1 == 0 then
    if $2 == 0 then
    ;~ msgbox(0,"Maus-o-meter", "Du hast die Maus nicht bewegt.")
    ContinueLoop

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

    EndIf
    EndIf
    if $pos2[0]>=$pos1[0] and $pos1[1]>=$pos2[1] Then; + steigung
    $1 = $pos1[0] - $pos2[0];826- 169
    $2 = $pos2[1] - $pos1[1];1183- 471
    ;~ MsgBox(0,"Seiten in pixeln",$1& @crlf & $2)
    $1 = $1^2
    $2 = $2^2
    ;~ MsgBox(0,"Seiten im quadrat",$1& @crlf & $2)
    $a = $2+ $1
    $0 = 0
    $x = ($a/3)
    $y = ($a/$x)
    Do
    $x1 = (($x+$y)/2)
    $y1 = ($a/$x1)
    $x = (($x1+$y1)/2)
    $y = ($a/$x)
    $0 = $0 + 1
    until $0 = 10
    ;~ MsgBox(0,"pixel",$x)
    $cm = $x*2.54/$dpi
    ;~ MsgBox(0,"",$cm)
    $Gesammt = $Gesammt+$cm
    IniDelete(@ScriptDir & "\mouse.ini","Gesammt","cm")
    IniWrite(@ScriptDir & "\mouse.ini","Gesammt","cm",$Gesammt)
    $Sitzung = $Sitzung +$cm

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

    ;---- ende + Steigung
    Elseif $pos1[0]>=$pos2[0] and $pos2[1]>=$pos1[1] then; - Steigung
    $1 = $pos2[0] - $pos1[0];826- 169
    $2 = $pos1[1] - $pos2[1];1183- 471
    ;~ MsgBox(0,"Seiten in pixeln",$1& @crlf & $2)
    $1 = $1^2
    $2 = $2^2
    ;~ MsgBox(0,"Seiten im quadrat",$1& @crlf & $2)
    $a = $2+ $1
    $0 = 0
    $x = ($a/3)
    $y = ($a/$x)
    Do
    $x1 = (($x+$y)/2)
    $y1 = ($a/$x1)
    $x = (($x1+$y1)/2)
    $y = ($a/$x)
    $0 = $0 + 1
    until $0 = 10
    ;~ MsgBox(0,"pixel",$x)
    $cm = $x*2.54/$dpi
    ;~ MsgBox(0,"",$cm)
    $Gesammt = $Gesammt+$cm
    $Sitzung = $Sitzung +$cm
    IniDelete(@ScriptDir & "\mouse.ini","Gesammt","cm")
    IniWrite(@ScriptDir & "\mouse.ini","Gesammt","cm",$Gesammt)

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

    Elseif $pos2[0]>=$pos1[0] and $pos2[1]>=$pos1[1] then; - Steigung
    $1 = $pos2[0] - $pos1[0];826- 169
    $2 = $pos2[1] - $pos1[1];1183- 471
    ;~ MsgBox(0,"Seiten in pixeln",$1& @crlf & $2)
    $1 = $1^2
    $2 = $2^2
    ;~ MsgBox(0,"Seiten im quadrat",$1& @crlf & $2)
    $a = $2+ $1
    $0 = 0
    $x = ($a/3)
    $y = ($a/$x)
    Do
    $x1 = (($x+$y)/2)
    $y1 = ($a/$x1)
    $x = (($x1+$y1)/2)
    $y = ($a/$x)
    $0 = $0 + 1
    until $0 = 10
    ;~ MsgBox(0,"pixel",$x)
    $cm = $x*2.54/$dpi
    ;~ MsgBox(0,"",$cm)
    $Gesammt = $Gesammt+$cm
    $Sitzung = $Sitzung +$cm
    IniDelete(@ScriptDir & "\mouse.ini","Gesammt","cm")
    IniWrite(@ScriptDir & "\mouse.ini","Gesammt","cm",$Gesammt)

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

    Elseif $pos1[0]>=$pos2[0] and $pos1[1]>=$pos2[1] then; - Steigung
    $1 = $pos1[0] - $pos2[0];826- 169
    $2 = $pos1[1] - $pos2[1];1183- 471
    ;~ MsgBox(0,"Seiten in pixeln",$1& @crlf & $2)
    $1 = $1^2
    $2 = $2^2
    ;~ MsgBox(0,"Seiten im quadrat",$1& @crlf & $2)
    $a = $2+ $1
    $0 = 0
    $x = ($a/3)
    $y = ($a/$x)
    Do
    $x1 = (($x+$y)/2)
    $y1 = ($a/$x1)
    $x = (($x1+$y1)/2)
    $y = ($a/$x)
    $0 = $0 + 1
    until $0 = 10
    ;~ MsgBox(0,"pixel",$x)
    $cm = $x*2.54/$dpi
    ;~ MsgBox(0,"",$cm)
    $Gesammt = $Gesammt+$cm
    $Sitzung = $Sitzung +$cm
    IniDelete(@ScriptDir & "\mouse.ini","Gesammt","cm")
    IniWrite(@ScriptDir & "\mouse.ini","Gesammt","cm",$Gesammt)
    EndIf
    TrayItemSetText($Alle,$gesammt)
    TrayItemSetText($Heute,$Sitzung)
    If $msg = $exititem Then
    _Exit()
    Endif
    WEnd
    Func _Exit()
    Exit
    EndFunc
    ;MsgBox(0,"Maus-o-meter","Deine Gesammt Strecke beträgt = " &$Gesammt & " cm"& @crlf & "Während dieser Sitzung hat deine Maus " & $Sitzung &" zurückgelegt.")

    [/autoit]

    die Ini dazu

    Spoiler anzeigen
    PHP
    [Zoll]
    Zoll=
    [Gesammt]
    cm=


    es können noch fehler enthalten sein

    mfg Buphy :thumbup:

  • Meine Version ist kürzer :P. Außerdem schreibt man "Gesammt" nur mit einem m :whistling: .
    Und die PPI Berechnung ist ein wenig umständlich. :huh: Abgesehen davon (und von der Tatsache, dass es sich ohne Taskmanager nicht beenden lässt :D) funktioniert es recht gut. :)

    • Offizieller Beitrag

    Entscheide dich mal in welchem Modus dein Script laufen soll.
    Entweder du benutzt den TrayOnEventMode oder du fragst in der Hauptschleife mit TrayGetMsg ab.
    Beides zusammen funktioniert nicht. Hab es mal abgeändert und zusätzlich die ESC Taste als Hotkey
    zum verlassen gesetzt.

    Spoiler anzeigen
    [autoit]

    #include <Constants.au3>
    HotKeySet("{ESC}","_Exit");Verlassen der Programms mit Escape
    Opt("TrayOnEventMode",1);TrayOnEvent einchalten /Wichtig kann nicht mit dem TrayMsg Mode kombiliert werden
    Opt("TrayMenuMode", 1 + 2)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Mausometer", "REG_SZ", @ScriptFullPath)
    ;---- bearbeiten der Ini ----
    $Sitzung = 1
    $Gesammt = IniRead(@ScriptDir & "\mouse.ini", "Gesammt", "cm", 0) ;gesammtauslesen
    $Zoll = IniRead(@ScriptDir & "\mouse.ini", "Zoll", "Zoll", 0) ;Zoll auslesen
    ;---- Zoll ----
    If $Zoll = 0 Then
    $Zoll = InputBox("Maus-o-meter", "Gib deine Bildschirm größe in Zoll an"); wenn kein wert vor handen manuell eingeben
    IniWrite(@ScriptDir & "\mouse.ini", "Zoll", "Zoll", $Zoll) ;Zoll Speichern
    EndIf
    ;>-- Ende zoll
    ;---- dpi ----
    $dpi = @DesktopHeight ^ 2 + @DesktopWidth ^ 2 ; Dpi ausrechnen
    $x = ($dpi / 3)
    $y = ($dpi / $x)
    $0 = 0
    Do
    $x1 = (($x + $y) / 2)
    $y1 = ($dpi / $x1)
    $x = (($x1 + $y1) / 2)
    $y = ($dpi / $x)
    $0 = $0 + 1
    Until $0 = 10
    $dpi = $x / $Zoll
    ;<== Ende DPI-Berechnung

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

    $chkitem = TrayCreateItem("Gesammt cm = ")
    $Alle = TrayCreateItem($Gesammt)
    $checkeditem = TrayCreateItem("cm während dieser Sitzung = ")
    $Heute = TrayCreateItem($Sitzung)
    $exititem = TrayCreateItem("Exit")
    TrayItemSetOnEvent($exititem, "_Exit")
    While True
    $pos1 = MouseGetPos();<-- coordinaten sammeln
    Sleep(100)
    $pos2 = MouseGetPos()
    $1 = $pos1[0] - $pos2[0]
    $2 = $pos1[1] - $pos2[1]
    If $1 == 0 Then
    If $2 == 0 Then
    ContinueLoop
    EndIf
    EndIf
    If $pos2[0] >= $pos1[0] And $pos1[1] >= $pos2[1] Then; + steigung
    $1 = $pos1[0] - $pos2[0];826- 169
    $2 = $pos2[1] - $pos1[1];1183- 471
    $1 = $1 ^ 2
    $2 = $2 ^ 2
    $a = $2 + $1
    $0 = 0
    $x = ($a / 3)
    $y = ($a / $x)
    Do
    $x1 = (($x + $y) / 2)
    $y1 = ($a / $x1)
    $x = (($x1 + $y1) / 2)
    $y = ($a / $x)
    $0 = $0 + 1
    Until $0 = 10
    $cm = $x * 2.54 / $dpi
    $Gesammt = $Gesammt + $cm
    IniDelete(@ScriptDir & "\mouse.ini", "Gesammt", "cm")
    IniWrite(@ScriptDir & "\mouse.ini", "Gesammt", "cm", $Gesammt)
    $Sitzung = $Sitzung + $cm
    ;---- ende + Steigung
    ElseIf $pos1[0] >= $pos2[0] And $pos2[1] >= $pos1[1] Then; - Steigung
    $1 = $pos2[0] - $pos1[0];826- 169
    $2 = $pos1[1] - $pos2[1];1183- 471
    $1 = $1 ^ 2
    $2 = $2 ^ 2
    $a = $2 + $1
    $0 = 0
    $x = ($a / 3)
    $y = ($a / $x)
    Do
    $x1 = (($x + $y) / 2)
    $y1 = ($a / $x1)
    $x = (($x1 + $y1) / 2)
    $y = ($a / $x)
    $0 = $0 + 1
    Until $0 = 10
    $cm = $x * 2.54 / $dpi
    $Gesammt = $Gesammt + $cm
    $Sitzung = $Sitzung + $cm
    IniDelete(@ScriptDir & "\mouse.ini", "Gesammt", "cm")
    IniWrite(@ScriptDir & "\mouse.ini", "Gesammt", "cm", $Gesammt)

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

    ElseIf $pos2[0] >= $pos1[0] And $pos2[1] >= $pos1[1] Then; - Steigung
    $1 = $pos2[0] - $pos1[0];826- 169
    $2 = $pos2[1] - $pos1[1];1183- 471
    $1 = $1 ^ 2
    $2 = $2 ^ 2
    $a = $2 + $1
    $0 = 0
    $x = ($a / 3)
    $y = ($a / $x)
    Do
    $x1 = (($x + $y) / 2)
    $y1 = ($a / $x1)
    $x = (($x1 + $y1) / 2)
    $y = ($a / $x)
    $0 = $0 + 1
    Until $0 = 10
    $cm = $x * 2.54 / $dpi
    $Gesammt = $Gesammt + $cm
    $Sitzung = $Sitzung + $cm
    IniDelete(@ScriptDir & "\mouse.ini", "Gesammt", "cm")
    IniWrite(@ScriptDir & "\mouse.ini", "Gesammt", "cm", $Gesammt)
    ElseIf $pos1[0] >= $pos2[0] And $pos1[1] >= $pos2[1] Then; - Steigung
    $1 = $pos1[0] - $pos2[0];826- 169
    $2 = $pos1[1] - $pos2[1];1183- 471
    $1 = $1 ^ 2
    $2 = $2 ^ 2
    $a = $2 + $1
    $0 = 0
    $x = ($a / 3)
    $y = ($a / $x)
    Do
    $x1 = (($x + $y) / 2)
    $y1 = ($a / $x1)
    $x = (($x1 + $y1) / 2)
    $y = ($a / $x)
    $0 = $0 + 1
    Until $0 = 10
    $cm = $x * 2.54 / $dpi
    $Gesammt = $Gesammt + $cm
    $Sitzung = $Sitzung + $cm
    IniDelete(@ScriptDir & "\mouse.ini", "Gesammt", "cm")
    IniWrite(@ScriptDir & "\mouse.ini", "Gesammt", "cm", $Gesammt)
    EndIf
    TrayItemSetText($Alle, $Gesammt)
    TrayItemSetText($Heute, $Sitzung)
    WEnd
    Func _Exit()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Edit: Ich hab noch die ganzen Messageboxen gekillt und dein Script mal mit Tidy formatiert, damit man das Script besser lesen kann.