Humbug Posted July 10, 2009 Share Posted July 10, 2009 Hello folks, im new to the forums and i didnt found a proper place start because i dont seem to the any access to start a topic in the proper thread yet. i was searching for some mouse click counter so i could figure out if im going insane sooner or later while working with windoze all the time, however i didnt found anything adhoc thus i made this simple counter i'd like to share: #include <Misc.au3> HotKeySet("!{ESC}", "Quit") HotKeySet("!{HOME}", "Stats") $LOGFILE = "log.ini" $LCOUNT = IniRead($LOGFILE, "Count", "LCLICK", "Default") $RCOUNT = IniRead($LOGFILE, "Count", "RCLICK", "Default") While 1 Sleep(20) If _IsPressed("01") Then $LCOUNT=$LCOUNT+1 IniWrite($LOGFILE, "Count", "LCLICK", $LCOUNT) Sleep(100) EndIf If _IsPressed("02") Then $RCOUNT=$RCOUNT+1 IniWrite($LOGFILE, "Count", "RCLICK", $RCOUNT) Sleep(100) EndIf WEnd Func Quit() Exit EndFunc Func Stats() TrayTip("Count", "Left: " & $LCOUNT & @CRLF & "Right: " & $RCOUNT, 1, 0) EndFunc Link to comment Share on other sites More sharing options...
Humbug Posted July 11, 2009 Author Share Posted July 11, 2009 i made a little more advanced version, but encountered one issue, it seems that If _IsPressed("04", $DLL) Or _IsPressed("05", $DLL) Or _IsPressed("06", $DLL) Then is all the middle mouse button pressed but not scrolled, i'd like to recognize scrolling too, but cant find any matching virtual key code. feedback would be appreciated. here's the update: expandcollapse popup#include <Misc.au3> HotKeySet("!{ESC}", "Quit") HotKeySet("!{HOME}", "Stats") $LOGFILE = "log.ini" $LCOUNT = IniRead($LOGFILE, "Count", "LCLICK", "Default") $RCOUNT = IniRead($LOGFILE, "Count", "RCLICK", "Default") $MMBCOUNT = IniRead($LOGFILE, "Count", "MMB", "Default") $KEYCOUNT = IniRead($LOGFILE, "Count", "KEYS", "Default") Global $DLL = DllOpen("user32.dll") Local $KEYCODES[101] = [08,09,"0C","0D",10,11,12,13,14,"1B",20,21,22,23,24,25,26,27,28,29,"2A","2B","2C","2D","2E","2F",30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47,48,49,"4A","4B","4C","4D","4E","4F",50,51,52,53,54,55,56,57,58,59,"5A","5B","5C","5D","5E","5F",60,61,62,63,64,65,66,67,68,69,"6A","6B","6C","6D","6E","6F",70,71,72,73,74,75,76,77,78,79,"7A","7B","A0","A1","A2","A3","A4","A5"] While 1 Sleep(10) If _IsPressed("01", $DLL) Then $LCOUNT=$LCOUNT+1 IniWrite($LOGFILE, "Count", "LCLICK", $LCOUNT) Do Until Not _IsPressed("01", $DLL) EndIf If _IsPressed("02", $DLL) Then $RCOUNT=$RCOUNT+1 IniWrite($LOGFILE, "Count", "RCLICK", $RCOUNT) Do Until Not _IsPressed("02", $DLL) EndIf If _IsPressed("04", $DLL) Or _IsPressed("05", $DLL) Or _IsPressed("06", $DLL) Then $MMBCOUNT=$MMBCOUNT+1 IniWrite($LOGFILE, "Count", "MMB", $MMBCOUNT) Sleep(50) EndIf For $I In $KEYCODES If _IsPressed($I, $DLL) Then $KEYCOUNT=$KEYCOUNT+1 IniWrite($LOGFILE, "Count", "KEYS", $KEYCOUNT) Do Until Not _IsPressed($I, $DLL) EndIf Next TraySetToolTip("Counter Stats" & @CRLF & "Left: " & $LCOUNT & @CRLF & "Right: " & $RCOUNT & @CRLF & "MMB: " & $MMBCOUNT & @CRLF & "Keys: " & $KEYCOUNT) WEnd Func Quit() Exit DllClose($DLL) EndFunc Func Stats() TrayTip("Counter Stats", "Left: " & $LCOUNT & @CRLF & "Right: " & $RCOUNT & @CRLF & "MMB: " & $MMBCOUNT & @CRLF & "Keys: " & $KEYCOUNT, 1, 0) EndFunc Link to comment Share on other sites More sharing options...
Yashied Posted July 11, 2009 Share Posted July 11, 2009 1. Look at GetKeyboardState().2. Look at WM_MOUSEWHEEL. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Humbug Posted July 11, 2009 Author Share Posted July 11, 2009 thanks for the quick reply. i had a look but don't seem to fully understand how to work with it yet, i suppose i have to read up on DLL calls. while searching i found http://www.autoitscript.com/forum/index.php?showtopic=92027 which helped realizing the mousewheel count. i guess there can be done a lot more optimization, however here's the little snippet: expandcollapse popup#include <Misc.au3> #include <WinAPI.au3> HotKeySet("!{ESC}", "Quit") HotKeySet("!{HOME}", "Stats") $LOGFILE = "log.ini" $LCOUNT = IniRead($LOGFILE, "Count", "LCLICK", "0") $RCOUNT = IniRead($LOGFILE, "Count", "RCLICK", "0") $MMBCOUNT = IniRead($LOGFILE, "Count", "MMB", "0") $KEYCOUNT = IniRead($LOGFILE, "Count", "KEYS", "0") $MMBROUNDS = IniRead($LOGFILE, "Count", "MMBROUNDS", "0") Global $DLL = DllOpen("user32.dll") Dim Const $WM_MOUSEWHEEL = 0x020A Dim Const $tagMSLLHOOKSTRUCT = $tagPOINT&';dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo' $hFunc = DllCallbackRegister("Mouse_LL", "long", "int;wparam;lparam") $pFunc = DllCallbackGetPtr($hFunc) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, _WinAPI_GetModuleHandle(0)) Local $KEYCODES[101] = [08,09,"0C","0D",10,11,12,13,14,"1B",20,21,22,23,24,25,26,27,28,29,"2A","2B","2C","2D","2E","2F",30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47,48,49,"4A","4B","4C","4D","4E","4F",50,51,52,53,54,55,56,57,58,59,"5A","5B","5C","5D","5E","5F",60,61,62,63,64,65,66,67,68,69,"6A","6B","6C","6D","6E","6F",70,71,72,73,74,75,76,77,78,79,"7A","7B","A0","A1","A2","A3","A4","A5"] While 1 Sleep(10) If _IsPressed("01", $DLL) Then $LCOUNT+=1 IniWrite($LOGFILE, "Count", "LCLICK", $LCOUNT) Do Until Not _IsPressed("01", $DLL) EndIf If _IsPressed("02", $DLL) Then $RCOUNT+=1 IniWrite($LOGFILE, "Count", "RCLICK", $RCOUNT) Do Until Not _IsPressed("02", $DLL) EndIf If _IsPressed("04", $DLL) Then $MMBCOUNT+=1 IniWrite($LOGFILE, "Count", "MMB", $MMBCOUNT) Do Until Not _IsPressed("04", $DLL) EndIf For $I In $KEYCODES If _IsPressed($I, $DLL) Then $KEYCOUNT+=1 IniWrite($LOGFILE, "Count", "KEYS", $KEYCOUNT) Do Until Not _IsPressed($I, $DLL) EndIf Next TraySetToolTip("Counter Stats" & @CRLF & "Left: " & $LCOUNT & @CRLF & "Right: " & $RCOUNT & @CRLF & "MMB Clicks: " & $MMBCOUNT & @CRLF & "MMB Rounds: " & Int($MMBROUNDS/360) & @CRLF & "Keys: " & $KEYCOUNT) WEnd Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hFunc) DllClose($DLL) EndFunc Func Quit() Exit EndFunc Func Stats() TrayTip("Counter Stats", "Left: " & $LCOUNT & @CRLF & "Right: " & $RCOUNT & @CRLF & "MMB Clicks: " & $MMBCOUNT & @CRLF & "MMB Rounds: " & Int($MMBROUNDS/360) & @CRLF & "Keys: " & $KEYCOUNT, 1, 0) EndFunc Func Mouse_LL($iCode, $iwParam, $ilParam) Local $tMSLLHOOKSTRUCT = DllStructCreate($tagMSLLHOOKSTRUCT, $ilParam) If $iwParam = $WM_MOUSEWHEEL Then Local $VAL = DllStructGetData($tMSLLHOOKSTRUCT, 'mouseData')/2^16 If BitAND($VAL, 0x8000) Then $VAL = BitOR($VAL, 0xFFFF0000) $MMBROUNDS = $MMBROUNDS + Abs($VAL) IniWrite($LOGFILE, "Count", "MMBROUNDS", $MMBROUNDS) ;ConsoleWrite(Int($MMBROUNDS/360) & @CRLF) EndIf EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now