MarbleScroll for Logitech Trackman Marble

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

Solution

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

Detailed solution:

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)

 Attachments:


or bitcoin donation: 1AZpTrJbUNHGSaXfG1AwzCxSRRTZGEJQck

Share Button

94 thoughts on “MarbleScroll for Logitech Trackman Marble

  1. It’s really great solution! Thank you! And it’s working even in VisualStudio!
    But how i can set it for left hand? I would like replace back and forward buttons.

  2. Oh, no when I set Back fuction for Forward button via SetPoint it dosn’t work (
    But mouse message doesn’t change!

    • In SetPoint you need to set Forward button to Generic button and modify source code in MarbleForm.cs. I will add WM_FORWARDBUTTON (it is missing) to the code and recompile it when I return home… in couple of hours (:

    • I checked and it is actually WM_XBUTTON and not WM_FORWARDBUTTON. It is the same event for back and forward button, so it should work with back and forward button without any program modification Just make sure you select Generic button in SetPoint for Forward button and it should work. If you still have any problems, let me know

    • Thanks. I am using it with windows 7, 8.1 and it’s working in Chrome, Firefox and IE. There are some problems with select dropdown lists inside browsers, but I can live with that (:

  3. Fantastic job!..THANK YOU!!!… I almost bought a trackball for twice the cost if I didn’t run into this nice little app!

    Again thank you for the great job!

  4. Marble TrackBall 의 Scroll 을 편리하게 – Marble Scroll App – 15000RPM

  5. It doesn’t work in new task manager application and likes of it. I wonder if it did before. But thanks a lot anyway.

  6. It works perfectly with windows 10 and more importantly with all my games. Thank you so much! It’s very good app and the explanations on how to install it are clear and precise. 10/10

  7. I’ve got multiple screens (Windows 10, Surface Pro 2), it works great for my main screen, but not other screens. Any ideas?

    • Strange. I am also using Windows 10 and it’s working fine in all screens. It only has problems with certain apps like task manager,…

  8. Wow this is amazing! Miles better than Logitech’s crappy Auto and Universal scroll and even better than X-Button control. Having the scroll and back/forward buttons is a stroke of genius. You’ve just turned an good mouse into a great one. Cheers!

  9. I’ve resurrected my trackball and was really missing this function. I’m on Windows 7, and it’s working great! Thanks so much 🙂

  10. Great work! I’ve been using MarbleScroll by Simon M and it isn’t compatible with new versions of Windows anymore.

    The scrolling doesn’t work in applications like Stream. Do you think that this is something you would be interested in fixing.

    Thank you very much,
    Saif

  11. Thank you sooooo much for creating this!!! As you stated, the scroll functions in SetPoint suck, I didn’t like having to toggle it on and off. Logitech really should have thought of this functionality.
    I’m also really thankful that you made this to be portable, so I don’t need to contact my company’s IT department and convince them to install software!

  12. I have been using this for 8 months and never had a problem, until now. It does not work online anymore. I can open a document and it works fine. Online, it simply goes back a page and does not scroll anymore. It worked on Aug. 31, 2016, but when I went online on Sep. 1, 2016, it would not scroll anymore. Did Firefox do something that is interfering with the program? I know they did an upgrade on their browser today, but how would that affect the mouse scrolling function? If I can’t find a solution, I will have to revert back to a scrolling wheel mouse to replace the marble mouse.

    • I have just tested the updated firefox and it’s working fine on updated Windows 10. You need to run MarbleScroll and firefox with the same user. For example, don’t run firefox as administrator and MarbleScroll as normal user.

  13. There’s an old MarbleScroll app — https://sites.google.com/site/marblescroll/home
    It’s a little buggy, but it has configuration app and allows to setup single press of scrolling X-button as middle click.

  14. Hello there,
    I would like to say thank you for saving my Trackman, I was seriously considering to get rid of it without scroll. It is amazing how used I am to scrolling in documents. However I tend to use middle click a lot, reprogrammed instead of Forward. Is there any chance to create a version where I could use the Forward button as middle click and scroll?

  15. I love the idea of this because i LOVE my Logitech marble, but after installing it I find that I can scroll down in apps like Outlook and Access, but I can’t scroll back up. do you know what the problem is?
    It works ok in File Explorer and on the Web but I need the other apps as well. I have installed the SetPoint and set the back button to generic.

    • I have no idea why you can’t scroll up. It should work if you can scroll down. Let me know if you find the problem. I am using it daily without any problems in outlook.

  16. Hi Primoz,

    how can I simulate the middle click on the logitech marble trackball T-BC21? In some other forums they talk about holding both left and right click buttons. Does your app has that functionality?
    Other than that the scrolling works perfect, thanks for creating it.

    • You can set it in SetPoint settings, but you will lose one button. If you want to simulate middle click with holding both buttons, you need to program some additional logic to the MarbleScroll application.

      • Thanks for the info, also do I have to do something to the logic to get the marblescroll to work on secondary monitor? it only works on my laptop screen but if I hook a secondary monitor and I use it to extend my desktop, it doesn’t work on the monitor

        • It should work on multiple displays without any problems as long as the MarbleScroll is run by the same user as an application you are trying to scroll. Try tunning MarbleScroll as Administrator.

          • You’re right, it did work on another monitor, what I had to do was add a shortcut of it to the “shell:common startup” so it will boot up as Administrator, I’m using windows 10 64-bits. On a side note, I went and bought the kensington orbit with scroll ring and didn’t like a bit, I returned it to the store. I rather keep using the logitech marble with your marblescroll script, more ergonomic to use and the back & fwd buttons work perfect along with the scrolling. Which that logitech will make it wireless. Thanks again for this script, works perfect.

  17. I love this program, it makes this mouse a great mouse I want it to be.

    However, in some programs like slack and outlook (sometimes) it recognizes the back button on press instead of on release (just guessing here) but it doesn’t let me scroll because it hits the back button before I can start trying to scroll. Any ideas?

    Thanks,
    -ShadyHippo 🙂

    • EDIT: it seems I was wrong about slack, I meant Skype for business. Also, after a reboot Outlook and Skype seem to be working. I will let you know if things go south however.

  18. holy crap you deserve a medal for this program. it was exactly what i was looking for. this functionality should come standard on the logitech marble. makes my workday a whole lot smoother, don’t know how i lived without it for so long!

  19. I’m having an issue in games when using this app. The mouse wheel emulation works fine, but the back and forward buttons no longer function as they normally would just by pressing them so anything I have bound to those buttons won’t work. I’ve made sure that the game and the app are both running under the same user. Any ideas?

    • Games sometimes override default button behaviour, or it just simply doesn’t like additional processing done by MarbleScroll to detect scrolling. Unfortunately, I have no suggestions how to fix this for your specific game, beside to experiment with different approaches in code.

  20. Middle click still not working (tested in Yandex and Chrome).
    And there’s no ability to set different x-buttons to click and to scroll (needed for some software like Autodesk’s).

    • Source code is published with the program. Feel free to modify it to meet your needs and please share it afterwards.

  21. I don’t understand how this works. I’ve extracted it and clicked on the application and nothing happens. Only thing that shows up is my marble mouse’s icon in the icons section on the bottom right and the only thing I can do with it is exit.

    I have an Acer Windows 10 PC. How do I use this? Thank you.

    • Run the MarbleScroll application, open another application where you wish to scroll (Word, Chrome, …). Make sure there is enough content to scroll (scroll bar visible). Click and hold left mouse button (back button) and simultaneously move marble on the mouse up and down to scroll. If it doesn’t scroll, then install/open setpoint and set back button to generic button.

      • I opened the application and tried scrolling – this didn’t work.

        However, I then opened setpoint and changed the back button to the generic button, as you said, and now it works!

        I have some questions.

        Can this scrolling work on editing programs like DaVinci or Final Cut Pro X?

        Also, is it possible to have the application automatically turn on whenever I turn on the computer?

        Thank you, Primož!

        • It depends on the program. Try scrolling and if it doesn’t work you can try to run MarbleScroll as an administrator and try again.

          To run MarbleScroll on startup just put it in startup folder. Check on google/youtube how to do that based on you version of Windows.

  22. Hi Primož, I am currently staring at the code to try and get the right small button to act as the scroll so I can keep the left small button as the middle mouse button. I have done some programming but I am a bit stumped with this code. I think that it has to do with this initial if statement but I can’t seem to figure it out.

    if (type == MouseMessages.WM_BACKBUTTONDOWN || type == MouseMessages.WM_MBUTTONDOWN && !simulatingMiddleClick)
    {
    isScroll = true;
    disableBackButton = false;
    startX = hookStruct.pt.x;
    startY = hookStruct.pt.y;
    dx = 0;
    dy = 0;

    // for scrolling in window under mouse pointer
    POINT p = new POINT();
    p.x = startX;
    p.y = startY;
    IntPtr focusWindow = WindowFromPoint(p);
    IntPtr foregroundWindow = GetForegroundWindow();

    // only focus is window is not already focused
    if (GetAncestor(foregroundWindow, 3) != GetAncestor(focusWindow, 3))
    SetForegroundWindow(focusWindow);

    return new IntPtr(1);
    }

    Or it may be as simple as changing the value in the bottom WM_BACKBUTTONDOWN = 0x020B, but I am not sure.

    Any pointers would be great.

    Thanks

    • When you are in Visual Studio just print ‘type’ to console and see what codes you get when you click down or up on buttons. Then just change WM_BACKBUTTONDOWN code, or add another variable and replace WM_BACKBUTTONDOWN.

      • When I put a watch on Type all I get is WM_MOUSEMOVE. I am pretty much stumped on this. I am trying to find a way to see the value of the button i press but I am totally stumped. Sorry for bothering you…Any ideas?

  23. Hi,
    is there someone who can help me?
    I use a Logitech Trackball Marple FX since some years. Now in connection to a Windows 10 Pro machine over a PS/II to UBB-converter. It workes well, but there is no function of the smal red button. ;-(
    MarbleScroll seems to be a very good prog, but will not help me, for the computer (Win 10) does not recognize the action of this small red button.
    I tried many things, but it will not work. I think its a driver problem.

    Hopely someone can give me a tip.

    Regards Tom

  24. Thank you, Primož!

    I’ve spent hours trying to cobble together solutions to this problem. I *need* my Marble Mouse to scroll reliably. ;^)

    Everything I tried was only a partial solution — working in some apps but not others. Yours appears to work consistently, everywhere I need it.

    Thanks again.

  25. This has worked flawlessly for me and I really appreciate you putting together such a great solution. Using Windows 10 and haven’t found a program that it doesn’t work with yet. Thanks again.

  26. Using Windows 10 right now, and for some reason it doesn’t work no matter what I do. I changed it’s compatibility settings, as well as running it as administrator, and nothing happens. A program does start running though, which I can find with the task manager, but for some reason the scrolling feature never seems to kick in. The back button just does it’s original function even if I start moving the ball before I release the button.

  27. Do you have SetPoint installed? Choose “Generic button” for back and forward buttons in SetPoint and try if it works.

    I am on updated Windows 10 and MarbleScroll still works .

  28. Do you think you can pull off something that scroll the page with “rotation” of the ball? I believe Kensington’s Slimblade is doing that; consider X axis is left/right for the mouse, Y axis is up/down, Z axis will be for scroll up/scroll down. I’m not exactly sure if we need a secondary sensor to get the Z axis rotation.

  29. Great app, but using it disables my “forward” mapping to middle mouse button (windows 10). Is this a known issue? Thank you!

  30. This is a terrific service. I like the Logitech Marble because I’ve already had carpal release surgery, and the symptoms are returning.
    I have a problem, however. While the software engages seamlessly, when I scroll using the mouse, the page moves in leaps that are much too long, skipping information on the page. I have verified this occurs in both Chrome and Word 2019
    Any suggestions? I’m not a techie — be gentle!
    Thanks again, and best regards

    • MarbleScroll only sends number of scrolls you do on the mouse. Scroll sensitivity, how much it moves the page up and down, is defined in the OS. You can set the scroll sensitivity in the SetPoint program from Logitech or in Windows mouse settings.

  31. Hi 🙂 I have been using your program for a few years now and am currently switching to Linux. Do you know how hard it would be to port over to Linux? I am not familiar with C# but am a Computer Science student and would be willing to attempt the Linux port myself. Do you have any guidance for where to start? Is it possible to just run your code on Linux myself? When I attempted to run the exe with mono it didn’t work. It gave a fatal error “System.EntryPointNotFoundException: GetModuleHandle at(…….”

  32. Excellent. Worked immediately and on windows apps as well as in a virtual network connection to a linux server. Unlike setpoint, the scrolling stops when you stop holding the “back” button.

  33. I love you man, this is a must for a thinkpad, where the middle button can be either a 3rd button click OR scroll but not both things at once, in linux that’s the default (and obvious) behavior.

    Once more, THANKS!!!

  34. Great helper! Thank you for making this.

    I have RSI in my right hand and am trying to offload the scrolling to the left hand. Pretty much like in this use case (https://superuser.com/questions/1341871/windows-10-use-a-second-mouse-just-for-scrolling). Since I already own a Marble, I’d like to try using it without buying new hardware. The AHK solution provided there seems to be an inferior version to yours.

    In the two-device setup, it would be even more comfortable if the Marble movement is always scrolling, without the need to hold a button.

    I’ve looked into the code but am not knowledgable enough to do this myself. The scroll modifier button converts all movement to scrolling, i.e. the primary regular mouse as well. So it’s not a simple case of keeping isScroll = true.

    Is there a way to process mouse movement of a specific device?

    • I think that is not possible with current implementation. MarbleScroll just intercepts system events for mouse movement without any knowledge where did the event came from.

      You should also take into account small non intentional mouse movements and don’t initiate scrolling.

      Maybe cheapest second mouse with standard wheel?

      • Thanks for the response! I actually first considered using a touchpad for the left hand, but then stumpled upon that linked discussion and your tool. Just wanted give Marble a try first since it had been lying around uselessly anyway.

  35. Is there any way to make the program function in the opposite direction? That is, if I move the trackball down, it will scroll up?

  36. Not sure if this is the same app I used years ago but it works great on my new Marble TrackMan, old one broke a long time ago, but it works great! Logitech should include it on their site and pay you royalties! Whoever heard of any kind of pointing device with no scroll? In fact using the ball to scroll is better than a separate scroll-wheel.

    THANK YOU!!!

Leave a Reply to Reggie Audibert Cancel reply

Your email address will not be published. Required fields are marked *