0

I'm making a Tkinter program where the user can capture an image from the screen through mouse dragging.

When program is running, I want to change the mouse cursor to cross type. I looked up how I can do it, but I could only find codes that change the cursor type when it is only inside the Tk window. I wish the cursor to be cross type wherever it is, even when it's outside of Tk window.

I also tried,

ctypes.windll.user32.SetSystemCursor(hcur, 32515)

but it gets an error saying 'hcur' is not defined.

What should I do?

toyota Supra
  • 3,181
  • 4
  • 15
  • 19
  • 1
    You can get a handle to the current cursor with `hcur = ctypes.windll.user32.GetCursor()`. You could also try `ctypes.windll.user32.GetCursorInfo()`. That said, I haven't had much luck with either...further digging required! There may be some useful information [here](https://learn.microsoft.com/en-us/windows/win32/menurc/cursors) – JRiggles May 02 '23 at 19:56
  • 1
    @JRiggles Worked! I didn't know I had to declare hcur first. Thank you so much! – josephyumss May 04 '23 at 16:06
  • 1
    Glad I could help! And just to clarify, you can use any name you like - it doesn't *have* to be `hcur`, so long as you refer to the same variable name where needed. E.g.: `banana = ctypes.windll.user32.GetCursor(); ctypes.windll.user32.SetSystemCursor(banana, 32515)` :) – JRiggles May 04 '23 at 16:10
  • Does this answer your question? [How to change cursor image in Python](https://stackoverflow.com/questions/55954005/how-to-change-cursor-image-in-python) – relent95 May 09 '23 at 05:11

0 Answers0