fr4ddy1 Posted January 25, 2013 Posted January 25, 2013 hi there, i got a question : is there a way to make a check of the kind of ''_IsPressed'' but that wouldn't take care of the ''fake key pressed'' by that i mean like when you send a mouse click from autoit, i have also tried with GetKeyState and GetAsyncKeyStat but both had the same result so in small word's it would only check for the mouse click that the person pressed himself not the one send by the script, and if the person pressed then do the rest of the script i have checked and haven't found a post for this, but i found ''_WinAPI_setWindowsHookEx'' i actually don't understand it, i also checked for it in the msnd but still haven't understand help would be appreciated **Sorry for my bad english**
PhoenixXL Posted January 25, 2013 Posted January 25, 2013 (edited) _WinAPI_setWindowsHookEx can help using a global mouse hookflags, element in MSLLHOOKSTRUCT will tell if the event was injected [i.e. LLMHF_INJECTED ]If you dont understand, try searching the forum for "MouseSetOnEvent" by MrCreator Edited January 25, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
fr4ddy1 Posted January 25, 2013 Author Posted January 25, 2013 (edited) _WinAPI_setWindowsHookEx can help using a global mouse hookflags, element in MSLLHOOKSTRUCT will tell if the event was injectedIf you dont understand, try searching the forum for "MouseSetOnEvent" by MrCreatorPlus : Its not possible to distinguish a simulated and real mouse clickthanks for fast answer, sorry if i took time before answer but i was trying everything,ive tried ''MouseSetOnEvent'' and this isn't what i am looking for, why?because 1. i don't want to block the mouseclick and 2. because even using the variables and value of it, it still detect the mouse click send by my script as a ''real'' clickso i restarted some research, then found this : http://pastebin.com/3P0ZKj5Gbut again it take the ''fake'' mouse click as a real.now am really out of idea, i searched/tried for about 8h from now today, am really tired ... if you got any other's idea, it would be much appreciated**Sorry for my bad english** Edited January 25, 2013 by fr4ddy1
PhoenixXL Posted January 25, 2013 Posted January 25, 2013 Good to hear that you tried so much I you didnt found anything here is something to get you started The following will detect fake and real mouse clicksexpandcollapse popup#cs Currently monitors Left Clicks Press ALT+a to generate a fake Left Mouse Click #ce #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> HotKeySet("{ESC}", "Terminate") HotKeySet("!a", "SendInput") OnAutoItExitRegister("Cleanup") Global Const $tagMSLLHOOKSTRUCT = 'int x;int y;DWORD mouseData;DWORD flags;DWORD time;ULONG_PTR dwExtraInfo' Global $hModule = _WinAPI_GetModuleHandle(0) Global $hMouseProc = DllCallbackRegister("LowLevelMouseProc", "long", "int;wparam;lparam") Global $pMouseProc = DllCallbackGetPtr($hMouseProc) Global $hMouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pMouseProc, $hModule) Global $iCheck = $WM_LBUTTONUP While 1 Sleep(10) WEnd ; http://msdn.microsoft.com/en-us/library/ms644986(v=vs.85).aspx Func LowLevelMouseProc($nCode, $wParam, $lParam) If $nCode >= 0 And ($wParam = $iCheck ) Then ; http://msdn.microsoft.com/en-us/library/ms644970(v=vs.85).aspx Local $MSLLHOOKSTRUCT = DllStructCreate($tagMSLLHOOKSTRUCT, $lParam) Local $x = DllStructGetData($MSLLHOOKSTRUCT, 1) Local $y = DllStructGetData($MSLLHOOKSTRUCT, 2) ConsoleWrite('Click at (' & $x & ', ' & $y & ') ' & "Real? " & (DllStructGetData($MSLLHOOKSTRUCT, 'flags' ) = 0) & @CRLF) EndIf Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) EndFunc Func SendInput() MouseClick('left') EndFunc Func Cleanup() _WinAPI_UnhookWindowsHookEx($hMouseHook) DllCallbackFree($hMouseProc) EndFunc Func Terminate() Exit EndFunc Use Alt+a to generate a fake mouse click and see if it gets detected Regards My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
fr4ddy1 Posted January 25, 2013 Author Posted January 25, 2013 (edited) Good to hear that you tried so much I you didnt found anything here is something to get you started The following will detect fake and real mouse clicksexpandcollapse popup#cs Currently monitors Left Clicks Press ALT+a to generate a fake Left Mouse Click #ce #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> HotKeySet("{ESC}", "Terminate") HotKeySet("!a", "SendInput") OnAutoItExitRegister("Cleanup") Global Const $tagMSLLHOOKSTRUCT = 'int x;int y;DWORD mouseData;DWORD flags;DWORD time;ULONG_PTR dwExtraInfo' Global $hModule = _WinAPI_GetModuleHandle(0) Global $hMouseProc = DllCallbackRegister("LowLevelMouseProc", "long", "int;wparam;lparam") Global $pMouseProc = DllCallbackGetPtr($hMouseProc) Global $hMouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pMouseProc, $hModule) Global $iCheck = $WM_LBUTTONUP While 1 Sleep(10) WEnd ; http://msdn.microsoft.com/en-us/library/ms644986(v=vs.85).aspx Func LowLevelMouseProc($nCode, $wParam, $lParam) If $nCode >= 0 And ($wParam = $iCheck ) Then ; http://msdn.microsoft.com/en-us/library/ms644970(v=vs.85).aspx Local $MSLLHOOKSTRUCT = DllStructCreate($tagMSLLHOOKSTRUCT, $lParam) Local $x = DllStructGetData($MSLLHOOKSTRUCT, 1) Local $y = DllStructGetData($MSLLHOOKSTRUCT, 2) ConsoleWrite('Click at (' & $x & ', ' & $y & ') ' & "Real? " & (DllStructGetData($MSLLHOOKSTRUCT, 'flags' ) = 0) & @CRLF) EndIf Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) EndFunc Func SendInput() MouseClick('left') EndFunc Func Cleanup() _WinAPI_UnhookWindowsHookEx($hMouseHook) DllCallbackFree($hMouseProc) EndFunc Func Terminate() Exit EndFunc Use Alt+a to generate a fake mouse click and see if it gets detected Regards work perfeclty like i wanted, thank you so much Also thank's for the msdn link,i will can understand completly what you did, and see where my error was Edited January 25, 2013 by fr4ddy1
PhoenixXL Posted January 25, 2013 Posted January 25, 2013 Glad i could help you My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
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