Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <Misc.au3>
- ; - Author: name22 (www.autoit.de)
- $iGUIWidth = 165
- $iGUIHeight = 290
- $iX = @DesktopWidth - $iGUIWidth + $iGUIWidth / 2
- $iY = @DesktopHeight - $iGUIHeight + $iGUIHeight / 2
- $iDeskDiag = IniRead("Data.ini", "Const", "DeskDiagInch", "Error")
- If $iDeskDiag = "Error" Then
- $iDeskDiag = InputBox("Bildschirmdiagonale", "Länge der Bildschirmdiagonale in Zoll: ", "17")
- If StringReplace($iDeskDiag, " ", "") = "" Then Exit
- IniWrite("Data.ini", "Const", "DeskDiagInch", $iDeskDiag)
- EndIf
- $PPI = Sqrt(@DesktopWidth ^ 2 + @DesktopHeight ^ 2) / $iDeskDiag
- $PPCm = Sqrt(@DesktopWidth ^ 2 + @DesktopHeight ^ 2) / ($iDeskDiag * 2.54)
- $hWnd = GUICreate("MouseMeter", $iGUIWidth, $iGUIHeight, $iX - $iGUIWidth / 2, $iY - $iGUIHeight / 2, $WS_POPUP, $WS_EX_TOPMOST)
- GUISetBkColor(0x545454, $hWnd)
- $Label1 = GUICtrlCreateLabel("Zurückgelegte Strecke:", 10, 10, 155)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label2 = GUICtrlCreateLabel("Zentimeter:", 10, 40)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label3 = GUICtrlCreateLabel("0", 10, 55, 70)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label4 = GUICtrlCreateLabel("Meter:", 10, 75)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label5 = GUICtrlCreateLabel("0", 10, 90, 70)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label6 = GUICtrlCreateLabel("Inch:", 10, 110)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label7 = GUICtrlCreateLabel("0", 10, 125, 70)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label8 = GUICtrlCreateLabel("Pixel:", 10, 145)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label9 = GUICtrlCreateLabel("0", 10, 160, 70)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label10 = GUICtrlCreateLabel("Geschwindigkeit:", 10, 180, 155)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- GUICtrlSetFont(-1, 10)
- $Label11 = GUICtrlCreateLabel("Meter/Sekunde:", 10, 205)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label12 = GUICtrlCreateLabel("0", 10, 220, 70)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label13 = GUICtrlCreateLabel("Meter/Sekunde (Durchschnitt):", 10, 235, 100, 50)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Label14 = GUICtrlCreateLabel("0", 10, 265, 70)
- GUICtrlSetFont(-1, 10)
- GUICtrlSetColor(-1, 0xFFFFFF)
- $Reset = GUICtrlCreateButton("Zurücksetzen", 90, 75, 70, 25)
- $Exit = GUICtrlCreateButton("Beenden", 90, 105, 70, 25)
- GUISetState()
- WinSetTrans($hWnd, "", 200)
- $aPosOld = MouseGetPos()
- $iDistance = 0
- $iTime = TimerInit()
- AdlibRegister("_Update", 30)
- While 1
- $nMsg = GUIGetMsg(1)
- Switch $nMsg[0]
- Case $GUI_EVENT_CLOSE, $Exit
- Exit
- Case $Reset
- $iTime = TimerInit()
- $iDistance = 0
- _Update()
- Case $GUI_EVENT_PRIMARYDOWN
- _SetPos()
- EndSwitch
- WEnd
- Func _Update()
- $iTime2 = TimerInit()
- $aPosNew = MouseGetPos()
- $iDiff = _GetPointsDistance($aPosOld[0], $aPosOld[1], $aPosNew[0], $aPosNew[1])
- $iDistance += $iDiff
- GUICtrlSetData($Label3, Floor($iDistance / $PPCm))
- GUICtrlSetData($Label5, Floor($iDistance / $PPCm / 100))
- GUICtrlSetData($Label7, Floor($iDistance / $PPI))
- GUICtrlSetData($Label9, Floor($iDistance))
- GUICtrlSetData($Label12, Round(($iDiff / $PPCm / 100) / (TimerDiff($iTime2) / 1000), 4))
- GUICtrlSetData($Label14, Round(($iDistance / $PPCm / 100) / (TimerDiff($iTime) / 1000), 4))
- $aPosOld[0] = $aPosNew[0]
- $aPosOld[1] = $aPosNew[1]
- EndFunc ;==>_Update
- Func _SetPos()
- Sleep(200)
- While _IsPressed("01")
- $aPosMouse = MouseGetPos()
- $iDiffX = $iX - $aPosMouse[0]
- If $iDiffX < 0 Then $iDiffX *= -1
- $iDiffY = $iY - $aPosMouse[1]
- If $iDiffY < 0 Then $iDiffY *= -1
- $iSpeedX = $iDiffX / 10
- $iSpeedY = $iDiffY / 10
- If $iX < $aPosMouse[0] Then
- $iX += $iSpeedX
- ElseIf $iX > $aPosMouse[0] Then
- $iX -= $iSpeedX
- EndIf
- If $iY < $aPosMouse[1] Then
- $iY += $iSpeedY
- ElseIf $iY > $aPosMouse[1] Then
- $iY -= $iSpeedY
- EndIf
- WinMove($hWnd, "", $iX - $iGUIWidth / 2, $iY - $iGUIHeight / 2)
- Sleep(30)
- WEnd
- EndFunc ;==>_SetPos
- Func _GetPointsDistance($iPointX1, $iPointY1, $iPointX2, $iPointY2)
- Return Sqrt(($iPointX1 - $iPointX2) ^ 2 + ($iPointY1 - $iPointY2) ^ 2)
- EndFunc ;==>_GetPointsDistance
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement