Hide cursor?

I am looking for a way to completely hide the cursor in Rhino via Python/RhinoCommon script.
Similar way to this WinApi function would do it:

I tried using System.Windows.Forms and ShowCursor/HideCursor, but it doesn’t work globally in Windows.
Any ideas?
I’d like to have run one script that hides the cursor, and another one that shows it, if at all possible.

Thank you,


Hi @Jarek,

I’ve tried it using:

rs.GetString("Press Enter to show the cursor")

Additionally i’ve setup a windows form and put this in the __init__ function:


both made the cursor hidden and i got pretty lost until i found the button to run another script for showing my cursor :wink:


Hey @clement,

Can you post the whole code?
The first 3 lines do nothing over here…
So have you managed to run the script that keeps the cursor globally (all windows) hidden, until another script runs and shows it? That’s precisely what I need. Thanks!


When messing with the cursor always remember to check that the current app is the correct instance of rhino and terminate if not :wink:

1 Like

thanks for the note, yes, that’s the level of scripting powers one has to be careful with :wink:

1 Like

I recall having some issues with that a few years ago, I can see if I find that code if you need it, but I can’t do so before next week though.

OK, maybe this is different in Win7 and Win10. I’ve tried on the first.

No, it only hides the cursor over Rhino and the form. I think that as i user i would really get pissed if anyone hides my cursor globally. How would you run the other script to show the cursor if you have no indication where your mouse is ?


I only care to hide it in current Rhino vport and can detect if the cursor is in viewport or not, and show it instantly once it hits the toolbars/panels area. I actually did that in RhinoScript / WinApi but now trying to reproduce it in Python with no luck. Windows 10 here, but I literally just tried the 3 lines, did not create the form

There is a master script that runs both of these scripts separately :slight_smile:

I guess the question is then how do I reference the main Rhino window as the form that the cursor hide/show is referencing… if that makes any sense?

Hi @Jarek, i take no responsibility if you cannot see your mouse cursor with below code. On my system, this hides the cursor over Rhino and the form and the python editor, it comes back if i manage to close the form. Note this is a modeless window…

import Rhino
import System.Drawing
import System.Windows.Forms
from System.Drawing import *
from System.Windows.Forms import *

class Form1(Form):
    def __init__(self):

    def InitializeComponent(self):
        self.Name = "Form1"
        self.Text = "Form1"
        self.FormClosed += self.Form1FormClosed
        self.Shown += self.Form1Shown

    def Form1Shown(self, sender, e):

    def Form1FormClosed(self, sender, e):

def DoSomething():
    form = Form1()



Hi @Clement - that works great (meaning: hides the cursor until I close the window), in Rhino only.
Now I need to figure out how to do it while not seeing this window, and show it not only when closing it. But it’s a good start. Thanks!

Hi @Jarek, you can hide a form using form.Hide() :wink: Alternatively you might apply some form styling eg:

self.FormBorderStyle = FormBorderStyle.None
self.BackColor = Rhino.ApplicationSettings.AppearanceSettings.ViewportBackgroundColor
self.TransparencyKey = self.BackColor

this will make your form invisible but still open and it responds to key shortcuts when the focus is on it. I would suggest to add some controls to the form or at least some text, otherwise it might be hard to find…

hi @clement,

Turns out, just two lines of code are enough, with no need to create the form:

    import System


    import System

The problem I have now is determining if cursor is hidden or shown since this is not just a boolean operation. Looking and the documentation, the number of hide and show calls must be equal, so if I run “Show” 3 times, the “Hide” needs to be ran 3 times before it hides. So far I don’t know how to ‘know’ what the state of the cursor is…

Hi @Jarek, you might keep track of the calls for Hide() so you know how often you need to call Show(). Some kind of a global counter maybe…


1 Like

yup, that’s what I am looking at. Should be easy since it is local to each Rhino instance…
Thanks again @clement for pointing me into right direction!

1 Like