Hawkysoft Posted September 20, 2014 Share Posted September 20, 2014 Good morning all, As stated above in the title, I'm curious if it's even possible to have a mousehook strictly on the xbutton1 and xbutton2 so i can basically remap the entire function in my tool without it still responding and trying to go to the next or last page in explorer... Also obviously if it's possible how >.< been searching my ... off With regards, Hawkysoft Link to comment Share on other sites More sharing options...
computergroove Posted September 20, 2014 Share Posted September 20, 2014 What is xbutton1 and xbutton2? Are these variables defined by you? What exactly are you trying to do? I dont understand the request. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Hawkysoft Posted September 20, 2014 Author Share Posted September 20, 2014 What is xbutton1 and xbutton2? Are these variables defined by you? What exactly are you trying to do? I dont understand the request. Xbutton1 and 2 are the side buttons on the mouse mate. Basically I assigned new functions to them, however they still have their original functions (page back and foreward) I would like to know how to make en hook for this so I'd be capable to block it's normal function. Hope this makes more sense Link to comment Share on other sites More sharing options...
computergroove Posted September 20, 2014 Share Posted September 20, 2014 https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_UnhookWindowsHookEx.htm is all I could find. Is there a utility for your mouse that would allow you to modify the actions of the buttons? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
j0kky Posted September 20, 2014 Share Posted September 20, 2014 (edited) You can disable mouseclicks or you can add a function to the existent click. But you can't block the normal click function and replace it with yours. But maybe there is a workaround: #include <GUIConstantsEx.au3> HotKeySet("{ESC}", "_Exit") Opt("GUIOnEventMode", 1) WinSetTrans(GUICreate("some"), "", 1) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_PrimaryDown") GUISetState(@SW_MAXIMIZE) While 1 Sleep(1000) WEnd Func _PrimaryDown() ConsoleWrite("The primary mouse button was pressed." & @CRLF) EndFunc Func _Exit() Exit EndFunc Edited September 20, 2014 by j0kky Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
j0kky Posted September 20, 2014 Share Posted September 20, 2014 I've to correct myself: you can block the normal click function and replace it with yours. Here is how you can do it: #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Cleanup") Global $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "LRESULT", "int;wparam;lparam") $hMod = _WinAPI_GetModuleHandle(0) Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod) While 1 Sleep(10) WEnd Func _KeyProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndIf Switch $wParam Case $WM_LBUTTONDOWN, $WM_LBUTTONUP, $WM_RBUTTONDOWN, $WM_RBUTTONUP ConsoleWrite("something" & @CRLF) Return 1 Case Else Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndSwitch EndFunc ;==>_KeyProc Func Cleanup() _WinAPI_UnhookWindowsHookEx($g_hHook) DllCallbackFree($g_hStub_KeyProc) Exit EndFunc ;==>Cleanup Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
mikell Posted September 20, 2014 Share Posted September 20, 2014 Here it is for Xbuttons #include <winapi.au3> #include <WindowsConstants.au3> HotKeySet('{ESC}', '_Close') Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global $hHook Local $hFunc, $pFunc, $hMod $hFunc = DllCallbackRegister('_MouseProc', 'long', 'int;wparam;lparam') $pFunc = DllCallbackGetPtr($hFunc) $hMod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, $hMod) While 1 Sleep(20) WEnd Func _MouseProc($iCode, $iwParam, $ilParam) If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) Local $info = DllStructCreate($MSLLHOOKSTRUCT, $ilParam) Switch $iwParam Case $WM_XBUTTONDOWN MsgBox(4096, "", "XButton " & _WinAPI_HiWord(DllStructGetData($info, "mouseData"))) EndSwitch Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) EndFunc Func _Close() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hHook) Exit EndFunc Link to comment Share on other sites More sharing options...
j0kky Posted September 20, 2014 Share Posted September 20, 2014 (edited) @Mikell: your function doesn't block the default click, also it's not good using a blocking function as MsgBox in a processing-message function. Edited September 20, 2014 by j0kky Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
mikell Posted September 20, 2014 Share Posted September 20, 2014 Hawkysoft asked for "a mousehook strictly on the xbutton1 and xbutton2" And obviously the Msgbox is intended for testing purpose only Link to comment Share on other sites More sharing options...
j0kky Posted September 20, 2014 Share Posted September 20, 2014 @Mikell: I didn't read for XButtons. However if you want to block the default click function you need to Return something different from 0. Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
Hawkysoft Posted September 20, 2014 Author Share Posted September 20, 2014 @Mikell: I didn't read for XButtons. However if you want to block the default click function you need to Return something different from 0. Thanks so far for the help mate, however it's not actually blocking the function yet ;/ #include <winapi.au3> #include <WindowsConstants.au3> HotKeySet('{ESC}', '_Close') Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global $hHook Local $hFunc, $pFunc, $hMod $hFunc = DllCallbackRegister('_MouseProc', 'long', 'int;wparam;lparam') $pFunc = DllCallbackGetPtr($hFunc) $hMod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, $hMod) While 1 Sleep(20) WEnd Func _MouseProc($iCode, $iwParam, $ilParam) If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) Local $info = DllStructCreate($MSLLHOOKSTRUCT, $ilParam) Switch $iwParam Case $WM_XBUTTONDOWN Local $test = _WinAPI_HiWord(DllStructGetData($info, "mouseData")) If $test = "1" Then Beep(500,500) ;also tried to Return 0 under it but didnt do the job either ;/ EndIf EndSwitch Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) EndFunc Func _Close() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hHook) Exit EndFunc Link to comment Share on other sites More sharing options...
mikell Posted September 20, 2014 Share Posted September 20, 2014 You don't get the beep by pressing xbutton1 ? Link to comment Share on other sites More sharing options...
Solution j0kky Posted September 21, 2014 Solution Share Posted September 21, 2014 (edited) however it's not actually blocking the function yet ;/ Because, as I wrote, you don't Return the correct value. This is the right version of the script: expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Cleanup") Global $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "LRESULT", "int;wparam;lparam") $hMod = _WinAPI_GetModuleHandle(0) Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod) Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" While 1 Sleep(10) WEnd Func _KeyProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndIf Local $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) Switch $wParam Case $WM_XBUTTONDOWN, $WM_XBUTTONUP, $WM_XBUTTONDBLCLK, $WM_NCXBUTTONDOWN, $WM_NCXBUTTONUP, $WM_NCXBUTTONDBLCLK If _WinAPI_HiWord(DllStructGetData($info, "mouseData")) = 1 Then ConsoleWrite("The first X button was pressed or released." & @CRLF) Else ConsoleWrite("The second X button was pressed or released." & @CRLF) EndIf Return 1 Case Else Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndSwitch EndFunc ;==>_KeyProc Func Cleanup() _WinAPI_UnhookWindowsHookEx($g_hHook) DllCallbackFree($g_hStub_KeyProc) Exit EndFunc ;==>Cleanup Edited September 21, 2014 by j0kky Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
Hawkysoft Posted September 21, 2014 Author Share Posted September 21, 2014 Because, as I wrote, you don't Return the correct value. This is the right version of the script: expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Cleanup") Global $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "LRESULT", "int;wparam;lparam") $hMod = _WinAPI_GetModuleHandle(0) Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod) Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" While 1 Sleep(10) WEnd Func _KeyProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndIf Local $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) Switch $wParam Case $WM_XBUTTONDOWN, $WM_XBUTTONUP, $WM_XBUTTONDBLCLK, $WM_NCXBUTTONDOWN, $WM_NCXBUTTONUP, $WM_NCXBUTTONDBLCLK If _WinAPI_HiWord(DllStructGetData($info, "mouseData")) = 1 Then ConsoleWrite("The first X button was pressed or released." & @CRLF) Else ConsoleWrite("The second X button was pressed or released." & @CRLF) EndIf Return 1 Case Else Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndSwitch EndFunc ;==>_KeyProc Func Cleanup() _WinAPI_UnhookWindowsHookEx($g_hHook) DllCallbackFree($g_hStub_KeyProc) Exit EndFunc ;==>Cleanup Thank you so much!!! Link to comment Share on other sites More sharing options...
j0kky Posted September 22, 2014 Share Posted September 22, 2014 You are welcome Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs 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