Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

mouse buttons as hotkey


  • Please log in to reply
14 replies to this topic
Byzoomi
  • Guests
  • Last active:
  • Joined: --
I have a logitech V470 bluetooth mouse that i paired with bluetooth. The scroller has left and right tilt which I would like to use as a hotkey to move forward and backward in my browser (Alt-left and Alt-right). However, even with InstallMouseHook and InstallKeybdHook, pushing the scroller left and right produces nothing in the key history. Any suggestions how I can accomplish this without installing the logitech software that came with it (I hate logitech software). Thanks

VxE
  • Moderators
  • 3622 posts
  • Last active: Dec 24 2015 02:21 AM
  • Joined: 07 Oct 2006
Logitech mice with more than 5 buttons generally use a virtual HID to interface the extra buttons with windows. That means that AHK might not detect some buttons on Logitech mice, whatever you do.

Fortunately, another AHK user decided to tweak the Logitech firmware and gave us UberOptions. That should let you redefine your mouse's extra buttons.

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007

Logitech mice with more than 5 buttons generally use a virtual HID to interface the extra buttons with windows. That means that AHK might not detect some buttons on Logitech mice, whatever you do.

Fortunately, another AHK user decided to tweak the Logitech firmware and gave us UberOptions. That should let you redefine your mouse's extra buttons.

UberOptions is great and I couldn't survive without it
But it still requires having the dreaded "Logitech Software" installed :(

P.S.
This thread has a solution that involves SetPoint combined with UberOptions
<!-- m -->http://www.autohotke...pic.php?t=20648<!-- m -->

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
On Windows XP, my Logitech MX610's wheel tilt uses the mouse HID, but sends empty messages. :?

Windows Vista natively supports horizontal scrolling, via WM_MOUSEHWHEEL. Wheel tilt can be detected on Vista via a HID script or mouse hook. Since AutoHotkey ignores the WM_MOUSEHWHEEL message, a separate mouse hook must be installed via script:
#Persistent
mhook := DllCall("SetWindowsHookEx", "int", 14 ; WH_MOUSE_LL
    , "uint", RegisterCallback("WheelHorzHook"), "uint", 0, "uint", 0)
return

WheelLeft:
    MsgBox WheelLeft
return

WheelRight:
    MsgBox WheelRight
return

WheelHorzHook(nCode, wParam, lParam)
{
    global mhook
    Critical
    if (wParam = 0x020E)  ; WM_MOUSEHWHEEL (Vista-only)
    {
        if (delta := NumGet(lParam+0,10,"Short"))
        {
            if (delta<0) {
                SetTimer, WheelLeft, -1
                return true
            } else {
                SetTimer, WheelRight, -1
                return true
            }
        }
    }
    return DllCall("CallNextHookEx", "uint", mhook, "int", nCode, "uint", wParam, "uint", lParam)
}
Fortunately for me, I use Vista almost exclusively. I also use a HID script to detect the "chat" button on my mouse. :)

(Edit: Added WH_MOUSE_LL keyword for search engines...)

Byzoomi
  • Guests
  • Last active:
  • Joined: --

On Windows XP, my Logitech MX610's wheel tilt uses the mouse HID, but sends empty messages. :?

Windows Vista natively supports horizontal scrolling, via WM_MOUSEHWHEEL. Wheel tilt can be detected on Vista via a HID script or mouse hook. Since AutoHotkey ignores the WM_MOUSEHWHEEL message, a separate mouse hook must be installed via script:

#Persistent
mhook := DllCall("SetWindowsHookEx", "int", 14
    , "uint", RegisterCallback("WheelHorzHook"), "uint", 0, "uint", 0)
return

WheelLeft:
    MsgBox WheelLeft
return

WheelRight:
    MsgBox WheelRight
return

WheelHorzHook(nCode, wParam, lParam)
{
    global mhook
    Critical
    if (wParam = 0x020E)  ; WM_MOUSEHWHEEL (Vista-only)
    {
        if (delta := NumGet(lParam+0,10,"Short"))
        {
            if (delta<0) {
                SetTimer, WheelLeft, -1
                return true
            } else {
                SetTimer, WheelRight, -1
                return true
            }
        }
    }
    return DllCall("CallNextHookEx", "uint", mhook, "int", nCode, "uint", wParam, "uint", lParam)
}
Fortunately for me, I use Vista almost exclusively. I also use a HID script to detect the "chat" button on my mouse. :)


I use vista, and this works like a charm! And no logitech software either! Thanks a lot!

steliyan
  • Members
  • 48 posts
  • Last active: Jan 29 2015 04:14 PM
  • Joined: 20 Apr 2007
Doesn't anybody have any progress with hooking those horizontal scroll buttons with Logitech's dlls?

schmiki
  • Members
  • 2 posts
  • Last active: Feb 09 2009 01:29 PM
  • Joined: 07 Feb 2009

On Windows XP, my Logitech MX610's wheel tilt uses the mouse HID, but sends empty messages. :?

Windows Vista natively supports horizontal scrolling, via WM_MOUSEHWHEEL. Wheel tilt can be detected on Vista via a HID script or mouse hook. Since AutoHotkey ignores the WM_MOUSEHWHEEL message, a separate mouse hook must be installed via script:

#Persistent
mhook := DllCall("SetWindowsHookEx", "int", 14 ; WH_MOUSE_LL
    , "uint", RegisterCallback("WheelHorzHook"), "uint", 0, "uint", 0)
return

WheelLeft:
    MsgBox WheelLeft
return

WheelRight:
    MsgBox WheelRight
return

WheelHorzHook(nCode, wParam, lParam)
{
    global mhook
    Critical
    if (wParam = 0x020E)  ; WM_MOUSEHWHEEL (Vista-only)
    {
        if (delta := NumGet(lParam+0,10,"Short"))
        {
            if (delta<0) {
                SetTimer, WheelLeft, -1
                return true
            } else {
                SetTimer, WheelRight, -1
                return true
            }
        }
    }
    return DllCall("CallNextHookEx", "uint", mhook, "int", nCode, "uint", wParam, "uint", lParam)
}
Fortunately for me, I use Vista almost exclusively. I also use a HID script to detect the "chat" button on my mouse. :)

(Edit: Added WH_MOUSE_LL keyword for search engines...)


WOW the solution I was looking for long ago!!!
I'm using an MSI Starmouse GS-502 under MS Vista and this script enabled hotkeying the left and right mouse wheel-tilt. Unfortunately the bundled software only supports programing of mousebutton4 and 5.

I've just changed the lines "MsgBox WheelLeft" and "MsgBox WheelRight" to "Send [Key1]" and "Send [Key2]" where [Key1] and [Key2] were my hotkeys.

I've made a shortcut to the script file, gave it an eyecandy mouse icon and voila! :D I have hotkeys but only when I need them.

YUHUU! ^^
Thanks a lot guys!!!

evandevon2
  • Guests
  • Last active:
  • Joined: --
Thanks Lexikos for this script,
Even though I've written scripts before I always get confused by dll calls. I'll be using this to make software for a hacked mouse (GPL of course) so that 5 switches can be plugged into it and programmed with any function so that people with physical and intellectual disabilities can interact with a computer much more and for much cheaper than other ways available. So thankyou again for this - I'll upload the software when its finished and put you in the credits list.

schmiki
  • Members
  • 2 posts
  • Last active: Feb 09 2009 01:29 PM
  • Joined: 07 Feb 2009
Another request: How to extend the above script if I want to bind Shift-Wheeltilt to a Shift-[key]?
This script sends [key] even if I hold down shift and tilt the wheel.
Thanks in advance!

evandevon2
  • Guests
  • Last active:
  • Joined: --
I'm not sure but I think whats happening is that the send/sendplay/ that you're probably using is blocking any keyboard input while sending the simulated keypress. I think there's a setting to turn that off, or you could just make it send shift+key?

wamaslamabama
  • Members
  • 6 posts
  • Last active: May 22 2009 05:41 PM
  • Joined: 22 May 2009

WOW the solution I was looking for long ago!!!
I'm using an MSI Starmouse GS-502 under MS Vista and this script enabled hotkeying the left and right mouse wheel-tilt. Unfortunately the bundled software only supports programing of mousebutton4 and 5.

I've just changed the lines "MsgBox WheelLeft" and "MsgBox WheelRight" to "Send [Key1]" and "Send [Key2]" where [Key1] and [Key2] were my hotkeys.

I've made a shortcut to the script file, gave it an eyecandy mouse icon and voila! :D I have hotkeys but only when I need them.

YUHUU! ^^
Thanks a lot guys!!!


Any reason why this trick would NOT work with Windows 7? Isn't it built on top of Vista? I've been pulling my hair out trying to get this working in the Release Candidate. I plugged in "Send {Browser_back}" to map to WheelLeft but it's a no-go.

The horizontal scroll is being picked up by the system though, because when I'm on a site that needs to scroll horizontally, it works.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
For anyone still using this hook method, AutoHotkey v1.0.48 and later support WheelLeft and WheelRight natively as hotkeys on Vista and later.
WheelLeft::MsgBox Left!
WheelRight::MsgBox Right!
Not sure about wamaslamabama's problem. The above works for me on Windows 7 beta with SetPoint installed but not running.

ingenious
  • Members
  • 3 posts
  • Last active: Apr 28 2010 11:29 PM
  • Joined: 30 Mar 2008
I put a MsgBox inside the WheelHorzHook function and it turned out the function is not executed at all when I tilt the wheel. All other events (mouse move, buttons, wheel up/down) trigger the function and I get the message box.

This is using AutoHotkey 1.0.48.03 on a freshly installed Windows 7. I don't have SetPoint installed because I hate this piece of software and want to avoid it altogether using AutoHotkey. Any suggestions? I'll try installing some other driver now...

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Any suggestions?

Install SetPoint, close it, try WheelUp/WheelDown. If it doesn't work, try AHKHID. If that doesn't work either, I guess you're out of luck.

forumdude1
  • Members
  • 2 posts
  • Last active: Feb 14 2013 07:00 AM
  • Joined: 14 Feb 2013

I'm running Windows 7 64-bit and have a Logitech Mouse M505.

 

AutoHotkey receives the mouse wheel events for me as long as I terminate SetPoint.exe. So, I disabled SetPoint.exe from starting at startup. I can always start it if I need it to change some mouse settings.

 

These implement the standard behavior:

WheelLeft::Send {Browser_Back}
WheelRight::Send {Browser_Forward}

 

and you can add definitions for other combinations.