Sign in to follow this  
Followers 0
Lej

Mouse wheel scroll as hotkey

5 posts in this topic

Is it possible to use mwheelup and mwheeldown as hotkeys?

Can't find anything in HotKeySet() or _IsPressed() :/

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
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?

Share this post


Link to post
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. :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0