Jump to content

Mouse wheel scroll as hotkey


Lej
 Share

Recommended Posts

Try this: Its a snippit from the Mouse Hook by Larry. Get it in the above post,

Const $WH_MOUSE = 7
$gui = GUICreate("test")
Global $n,$buffer = ""
Const $WM_AUTOITMOUSEWHEELUP = 0x1400 + 0x0D30
Const $WM_AUTOITMOUSEWHEELDOWN = 0x1400 + 0x0D31

GUIRegisterMsg($WM_AUTOITMOUSEWHEELUP,"MouseWheelUp")
GUIRegisterMsg($WM_AUTOITMOUSEWHEELDOWN,"MouseWheelDown")

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])

Func MouseWheelDown($hWndGUI, $MsgID, $WParam, $LParam)
        $n += 1
    If $n > 25 Then
        $n = 25
        $buffer = StringTrimLeft($buffer,StringInStr($buffer,@LF))
    EndIf
    $buffer &= "Mouse: " & $MsgID & "," &  $WParam & "," &  $LParam & @LF
    ToolTip($buffer)
EndFunc

Func MouseWheelUp($hWndGUI, $MsgID, $WParam, $LParam)
    
EndFunc

While 1
        $msg = GUIGetMsg()
    If $msg = -3 Then ExitLoop
WEnd
Link to comment
Share on other sites

Yes, this seems to be exaclty what I needed. Wondering about one thing tho:

Func MouseWheelDown($hWndGUI, $MsgID, $WParam, $LParam)
        $n += 1
    If $n > 25 Then
        $n = 25
        $buffer = StringTrimLeft($buffer,StringInStr($buffer,@LF))
    EndIf
    $buffer &= "Mouse: " & $MsgID & "," &  $WParam & "," &  $LParam & @LF
    ToolTip($buffer)
EndFunc

Is the stuff in the function just for showing? When i make my program it can be removed without causing troubles and I just add my code?

Link to comment
Share on other sites

Yes, this seems to be exaclty what I needed. Wondering about one thing tho:

Func MouseWheelDown($hWndGUI, $MsgID, $WParam, $LParam)
        $n += 1
    If $n > 25 Then
        $n = 25
        $buffer = StringTrimLeft($buffer,StringInStr($buffer,@LF))
    EndIf
    $buffer &= "Mouse: " & $MsgID & "," &  $WParam & "," &  $LParam & @LF
    ToolTip($buffer)
EndFunc

Is the stuff in the function just for showing? When i make my program it can be removed without causing troubles and I just add my code?

Yes it was just for showing. :)
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...