Recently I bought an ergonomic mouse Logitech Trackman Marble. Mainly because I started to feel pain in my wrist and it didn’t go away over time. Probably because I spent 8+ hours per day on computer and incorrect hand positions/movement can lead to Carpal tunnel syndrome.
Trackman Marble is a great mouse. It’s symmetrical, meaning you can use it if you are left or right handed. You need couple of weeks to get used to it, but then it’s simple to use like any other mouse. I even play FPS games with no problems. The only real big downside of the mouse is, that it lacks the scrolling wheel. Logitech has provided an alternative solution for scrolling, but it’s non intuitive to use, in other words, useless.
I decided to write a small program, code name MarbleScroll, that would simulate wheel like scrolling. The main idea is scrolling with pressing the back button and turning the marble. If you don’t turn the marble, then it acts just like normal back button. After digging around I found out it can be done with capturing low level mouse events in OS. I decided to go with C#, as windows is my primary OS for workstation.
Desired MarbleScroll functionality:
- support for scrolling in all applications without modifying them
- back button + marble turn = scroll
- back button = normal back operation
- scrolling is done on application with mouse focus and without the need of clicking on application to gain focus
You can download MarbleScroll here. If you use SetPoint, you need to set Generic button as Button task for the back button (demonstration). MarbleScroll is really simple to use. You just need to run it. Place it in any folder on your hard drive and create shortcut in Startup folder for auto start at reboot. If you get an error about missing .NET framework, you can install it from here.
Few details about MarbleScroll:
- works on Windows XP, Vista, 7, 8, 8.1, 10, …
- build for .NET framework 4.5, but it should compile on any other if you choose it in project source
- compiled for right handed mouse, but it works for left handed too.
- runs in system tray where you can close it if you require to
- vertical and horizontal scrolling with back button + marble movement
- back button without marble movement produces normal back operation
- scrolls the windows under mouse pointer without focusing it
In windows we can capture low level mouse events in User32.dll with SetWindowsHookEx function (WH_MOUSE_LL). We need this to detect back button press and marble movement. For simulating a scrolling wheel we can use mouse_event function (MOUSEEVENTF_WHEEL and MOUSEEVENTF_HWHEEL).
The idea behind scrolling in non focused window under mouse pointer is to find underlying window with WindowFromPoint function and compare it to focused window from GetForegroundWindow function. If they aren’t equal, we focus the underlying window with SetForegroundWindow function. If we focus it every time, scrolling won’t work in drop-down lists. That is because drop-down list is normally a child window and we are focusing the parent window. Therefore it isn’t enough to compare foreground window and window from point, but we have to compare their root owners, which can be done with GetAncestor function.
I created a MarbleScroll.cs class for scrolling and Visual Studio project which includes MarbleScroll.cs and code for background application running in system tray. You can tweak the source code for vertical and horizontal sensitivity or for general code improvement. In second case please share the code (:
Update 30.7.2015: The app didn’t work well on Windows 10. The problem was in mouse_event() taking too much time to execute inside low level hook and windows doesn’t like that. I moved the code to another thread and it works fine now. It should work better on other versions of windows too. Code and updated app is available for download in attachments.
Update 8.2.2017: It doesn’t work with task manager or your app? Try running MarbleScroll as administrator (right click, run as administrator). MarbleScroll only works for applications run by the same user.
Update 26.5.2018: If you have problems with MarbleScroll on HiDPI display, you can right-click MarbleScroll.exe and go to Properties, Compatibility Tab and select “Override high DPI scaling behavior. Scaling performed by” and select “Application”. (credits go to Simon Lang)
or bitcoin donation: 1AZpTrJbUNHGSaXfG1AwzCxSRRTZGEJQck