DesireDenied Posted October 22, 2011 Share Posted October 22, 2011 Can anyone tell me what is wrong with this code? #include <WinAPI.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> OnAutoItExitRegister("Cleanup") Global $hHook, $hStub_MouseProc _Main() Func _Main() $hStub_KeyProc = DllCallbackRegister("_MouseProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub_MouseProc), $hmod) If Not @error Then ConsoleWrite( StringFormat("Hook installed [%s]", $hHook) & @CRLF) Else ConsoleWrite( StringFormat("Error code: %s", @error) & @CRLF) EndIf While 1 Sleep(10) WEnd EndFunc Func _MouseProc($nCode, $wParam, $lParam) ConsoleWrite( StringFormat("nCode=%d\twParam=%08X\tlParam=%08X\n", $wParam, $lParam) ) Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc Func Cleanup() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_MouseProc) EndFunc ;==>Cleanup Link to comment Share on other sites More sharing options...
Developers Jos Posted October 22, 2011 Developers Share Posted October 22, 2011 (edited) Just post your found the solution when you have in stead of reporting it to request deletion. Tnx Jos Edited October 23, 2011 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DesireDenied Posted October 23, 2011 Author Share Posted October 23, 2011 The problem was: $hStub_KeyProc = DllCallbackRegister("_MouseProc", "long", "int;wparam;lparam") Now I got another problem. I was trying to block all LMB inputs if TimmerDiff < 50ms but something is still wrong because LMB clicks are still beeing sent. expandcollapse popup#include <WinAPI.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> OnAutoItExitRegister("Cleanup") Global $hHook, $hStub_MouseProc, $iTimer = TimerInit() _Main() Func _Main() $hStub_MouseProc = DllCallbackRegister("_MouseProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub_MouseProc), $hmod) If Not @error Then ConsoleWrite( StringFormat("Hook installed [%s]", $hHook) & @CRLF) Else ConsoleWrite( StringFormat("Error code: %s", @error) & @CRLF) EndIf While 1 Sleep(10) WEnd EndFunc Func _MouseProc($nCode, $wParam, $lParam) Switch $wParam Case $WM_LBUTTONDOWN If TimerDiff($iTimer) < 50 Then BlockInput(1) BlockInput(0) EndIf Case $WM_LBUTTONUP $iTimer = TimerInit EndSwitch Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc Func Cleanup() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_MouseProc) EndFunc ;==>Cleanup Link to comment Share on other sites More sharing options...
Skitty Posted October 24, 2011 Share Posted October 24, 2011 The problem was: $hStub_KeyProc = DllCallbackRegister("_MouseProc", "long", "int;wparam;lparam") Now I got another problem. I was trying to block all LMB inputs if TimmerDiff < 50ms but something is still wrong because LMB clicks are still beeing sent. If you haven't found a solution, it would help a little if you told us what exactly it is you're trying to do. And what is "LMB"? Left mouse button? Somehow you've managed to make simple thinks very confusing and I'm left wondering how you do it. Link to comment Share on other sites More sharing options...
DesireDenied Posted October 24, 2011 Author Share Posted October 24, 2011 oh, my fault, sorry. What I am trying to do is to block user from using Left Mouse Button more than ~20x times a second (every 50ms) and to log info if he was trying to do so. Link to comment Share on other sites More sharing options...
FaridAgl Posted October 24, 2011 Share Posted October 24, 2011 maybe: While 1 InputBox(1) Sleep(50) InputBox(0) Sleep(50) WEnd http://faridaghili.ir Link to comment Share on other sites More sharing options...
DesireDenied Posted October 24, 2011 Author Share Posted October 24, 2011 BlockInput(1) ; instead of InputBox(1) :P Thanks for giving a try but this won't work for sure. By the way, trying to type anything on keyboard, using mouse will be pain in the ass if you run script like this one. What I need to do is to block left mouse button only if second mouse click was sent in less than 50ms from the first one. There is no need to block any other key/mouse inputs. Link to comment Share on other sites More sharing options...
Skitty Posted October 24, 2011 Share Posted October 24, 2011 BlockInput(1) ; instead of InputBox(1) :P Thanks for giving a try but this won't work for sure. By the way, trying to type anything on keyboard, using mouse will be pain in the ass if you run script like this one. What I need to do is to block left mouse button only if second mouse click was sent in less than 50ms from the first one. There is no need to block any other key/mouse inputs. All of a sudden, I can imagine that you are attempting to block automated mouse clicks using another script, who is going to be sending mouse clicks that fast if not a script. So why not recreate the script that you're using to do that clicking instead? Link to comment Share on other sites More sharing options...
DesireDenied Posted October 24, 2011 Author Share Posted October 24, 2011 A friend of mine got a problem with his laptop since last storm and power blackout something has happened to his motherboard. Does not matter if he is using touch pad or a mouse plugged into USB port his laptop is recieving multiple left mouse button clicks, even if you use left mouse button just once. We were trying to fix the laptop but many different computer/laptop services said they don't really know what is going on. So I thought I can fix it using autoit by blocking duplicated mouse clicks. I did some measurements and I have discovered that duplicated mouse clicks are appearing from 3-30 ms after real click. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 24, 2011 Share Posted October 24, 2011 (edited) I also had (well, have, if I connect that damn mouse again) a " of problem. I fixed it by getting a new mouse, but until that, I did a lot of googling around and found this ahk script. Under some conditions, it helped a lot. Edited October 24, 2011 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
DesireDenied Posted October 24, 2011 Author Share Posted October 24, 2011 we have already tried like 5 different mouses but the problem is still here. thanks for your help, once i will get some things done i will take a look on that script. 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