3

I know how to set the current cursor, but how do I check on the operating-system level if Windows is displaying the Busy cursor? Otherwise, how do I check if Windows is in the "busy" state?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
deavon
  • 53
  • 6
  • Please don't add " (C#)" to your titles. That's what the tags are for. – John Saunders Feb 24 '12 at 19:24
  • 1
    If you're using winforms: http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.current.aspx – Bridge Feb 24 '12 at 20:19
  • Is there even a proper definition for the Windows "busy" state? – zmbq Feb 24 '12 at 20:20
  • I dont know if there is any API for this. If you are desparate and need to know it then read framebuffer pixel by pixel at the location where busy cursor should be located and compare it with known bitmap. – marcinj Feb 24 '12 at 20:34
  • Sorry for the above, for some reasons I thought you were taking about Windows CE, where this theoretically would be possible. – marcinj Feb 24 '12 at 20:42
  • @Bridge: Unfortunately when checking the value of System.Windows.Forms.Cursor.Current, it is only returning "Default" as the current cursor, even if the cursor has changed between Arrow and WaitCursor. I basically utilized a DispatcherTimer to check the Cursor.Current value, and it's only returning Default. Is there a way to check if Windows itself is in the state that would make it display the WaitCursor? – deavon Feb 24 '12 at 20:43
  • 1
    Windows doesn't have its own state as such, it uses the state of the window underneath the mouse point. Move your mouse from a busy app to a non-busy one and the cursor changes. – Mark Ransom Feb 24 '12 at 20:52
  • Understood. Is there a way that I could check the current cursor for another process? – deavon Feb 24 '12 at 21:28

1 Answers1

1

You can use the GetCursorInfo API to do this.

Patrick
  • 5,526
  • 14
  • 64
  • 101
  • I thought about that, but realized that it doesn't provide sufficient information. Perhaps I'm supposed to use the IntPtr value of hCursor to acquire this "busy" information? – deavon Feb 24 '12 at 19:28
  • -1: this API does not tell you if the cursor is in the busy state. – demoncodemonkey Feb 24 '12 at 19:30
  • 1
    @deavon, hCursor is really all the information the system has about the style of the cursor. It's never required to interpret the cursor, only to draw it, and the handle is sufficient for that task. You might compare it to the handle you get back from loading a cursor with the ID IDC_WAIT (32514) and see if it's the same. – Mark Ransom Feb 24 '12 at 19:39
  • Even that might not be enough as some apps (and even frameworks) provide their own (sometimes exact duplicate) busy cursor. – Luke Feb 24 '12 at 22:16