Jump to content

Disable mousewheel


Recommended Posts

For a specifiec application I need to create a script that will disable the mousewheel and replace the up and down messages with messages to the statusbar control. So far I am able to capture the mousewheel messages (using hook.dll) and redirect them to the statusbar control, but in addition I need the original mousewheel movement disabled. This last bit does not work. The result is that both actions take place and this is not good enough. This is my script so far. I hope someone can help me out.

;Initilize
Const $WH_MOUSE = 7
Const $WM_AUTOITMOUSEWHEELUP = 0x1400 + 0x0D30
Const $WM_AUTOITMOUSEWHEELDOWN = 0x1400 + 0x0D31

;Mousescroll loop
$gui = GUICreate("")

Global $msg
Global $DLLinst = DllCall("kernel32.dll", "hwnd", "LoadLibrary", "str", ".\hook.dll")
Global $mouseHOOKproc = DllCall("kernel32.dll", "hwnd", "GetProcAddress", "hwnd", $DLLinst[0], "str", "MouseProc")
Global $hhMouse = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE, "hwnd", $mouseHOOKproc[0], "hwnd", $DLLinst[0], "int", 0)

DllCall(".\hook.dll", "int", "SetValuesMouse", "hwnd", $gui, "hwnd", $hhMouse[0])

GUIRegisterMsg($WM_AUTOITMOUSEWHEELUP, "ScrollMouse")
GUIRegisterMsg($WM_AUTOITMOUSEWHEELDOWN, "ScrollMouse")


While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then ExitLoop
WEnd

Func ScrollMouse($hWndGUI, $MsgID, $WParam, $LParam)
    If $MsgID = "8497" And WinActive("<my window>") Then
        ControlSend("<my window>", "", "[CLASS:ScrollBar; INSTANCE:2]", "{DOWN 1}")
    ElseIf $MsgID = "8496" And WinActive("FileMaker Pro") Then
        ControlSend("<my window>", "", "[CLASS:ScrollBar; INSTANCE:2]", "{UP 1}")
        Return
    EndIf
    
EndFunc  ;==>ScrollMouse
Link to comment
Share on other sites

there was some way to remap keyboard and mouse inputs to somthing else (even nothing)... try searching google for KeyTweak( Keybaord remaper that might do mouse also) and AutoHotKey (an autoit-ish clone that has built it macros for key and mouse remapping)

KeyTweak does not do mouse remappings. I tried AutoHotKey before but it was unstable with my clients configuration. Is there no way to do this in AutoIt?

Thanks.

Link to comment
Share on other sites

HotKeySet("k","test_k")

while 1
    Sleep(200)
wend

func test_k()
send("j")
EndFunc

Keyboard input/blocking is pretty easy. This code will take away your "k" keystroke and replace it with "j".

If you remove the send, it will just simply block the letter "k".

Edited by Supercross
Link to comment
Share on other sites

  • 3 weeks later...

HotKeySet("k","test_k")

while 1
    Sleep(200)
wend

func test_k()
send("j")
EndFunc

Keyboard input/blocking is pretty easy. This code will take away your "k" keystroke and replace it with "j".

If you remove the send, it will just simply block the letter "k".

That is not the issue. The mousewheel is not a standard key you can access with HotKeySet()
Link to comment
Share on other sites

you have code to get mouse wheel up and down??? that works?

The code in post #1, modified so I can try the scroll detection, detects scroll down but nothing for scroll up.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...