Hello, I am creating a key counter for a friend to measure actions per second, I've been stuck on this for quite some time and have been looking for some solutions.
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
global $mouseCount
global $keyCount
global $isEnabled
global $timeEnabled
global $roundedKey
global $roundedMouse
global $roundedTotal
global $Label1
ShowGUI()
TimeEnabled()
while 1
global $dll = DllOpen("user32.dll")
if _IsPressed("01", $dll) or _IsPressed("02", $dll) then CountMouse()
if _IsPressed("41", $dll) or _IsPressed("42", $dll) or _IsPressed("43", $dll) or _IsPressed("44", $dll) or _IsPressed("45", $dll) or _IsPressed("46", $dll) or _IsPressed("47", $dll) or _IsPressed("48", $dll) or _IsPressed("49", $dll) or _IsPressed("4A", $dll) or _IsPressed("4B", $dll) or _IsPressed("4C", $dll) or _IsPressed("4D", $dll) or _IsPressed("4E", $dll) or _IsPressed("4F", $dll) or _IsPressed("50", $dll) or _IsPressed("51", $dll) or _IsPressed("52", $dll) or _IsPressed("53", $dll) or _IsPressed("54", $dll) or _IsPressed("55", $dll) or _IsPressed("56", $dll) or _IsPressed("57", $dll) or _IsPressed("58", $dll) or _IsPressed("59", $dll) or _IsPressed("5A", $dll) then CountKey()
WEnd
Func Enabled()
if $isEnabled = 0 Then
$isEnabled = 1
TimeEnabled()
else
$isEnabled = 0
EndIf
EndFunc
Func TimeEnabled()
Sleep(1000)
$timeEnabled = $timeEnabled + 1
TimeEnabled()
Average()
EndFunc
Func CountKey()
if $isEnabled = 1 Then
$keyCount = $keyCount + 1
EndIf
EndFunc
Func CountMouse()
if $isEnabled = 1 Then
$mouseCount = $mouseCount + 1
EndIf
EndFunc
Func Average()
$keyAverage = $timeEnabled / $keyCount
$mouseAverage = $timeEnabled / $mouseCount
$totalAverage = ($keyCount + $mouseCount) / $timeEnabled
$roundedKey = Round($keyAverage,0)
$roundedMouse = Round($mouseAverage,0)
$roundedTotal = Round($totalAverage,0)
GUICtrlSetData($Label1, "KPS: " & $roundedKey & " MPS: " & $roundedMouse & " TPS: " & $roundedTotal)
EndFunc
Func ShowGUI()
$Form1 = GUICreate("Key Counter by AlwaysUltra", 201, 101, 192, 124, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), 0)
GUISetBkColor(0xC0C0C0)
GUICtrlSetFont(-1, 10, 600, 0, "Segoe UI")
GUICtrlSetColor(-1, 0xFF0000)
$Label1 = GUICtrlCreateLabel("KPS: "&$roundedKey&" MPS: "& $roundedMouse & " TPS: " &$roundedTotal, 0, 8, 196, 17)
$Button1 = GUICtrlCreateButton("Toggle", 0, 72, 75, 25)
$Button2 = GUICtrlCreateButton("Exit", 120, 72, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button2
Exit
Case $Button1
Enabled()
EndSwitch
WEnd
EndFunc
I tried switching up the function enabled by calling TimeEnabled() at the beginning of the program, but that didn't seem to work either. Thank you so much for reading over this, I appreciate it.