2

Using C++, how would I get the desktop window handle on Mac OS X?

fdh
  • 5,256
  • 13
  • 58
  • 101
  • On Windows there's a handle to a window representing the desktop but Mac OS X isn't the same. So what you need to do will depend on what exactly you want to accomplish. For example if you want to draw on the desktop: http://stackoverflow.com/questions/4982584/how-do-i-draw-the-desktop-on-mac-os-x Also much of Mac OS X's API is best accessed via Objective-C rather than C++. If it can be access in C++ it will be via the C API, and you may be better off just using Objective-C or Objective-C++. – bames53 Jan 06 '12 at 19:17
  • I'm trying to create something similar to Microsoft Office's Clippy (the annoying paperclip assistant), but I need it to be accessed throughout the OS. Kinda like a small animation that you can move around and interact with. If I cannot get the handle do you have any other idea on how I could do this? – fdh Jan 06 '12 at 19:34
  • Also your right, I'll do it in Obj-C – fdh Jan 06 '12 at 19:40

1 Answers1

2

You can't. It isn't owned by your process, and there's no way to access windows which aren't yours under Mac OS X unless you're Dock.app or the WindowServer. (Dock.app has some special privileges, which can't be duplicated by other processes, and WindowServer is directly responsible for the windows so it can do whatever it wants.)

Current versions of the Finder create desktop icons by creating a full-screen, mostly-transparent window with a very low level. If you're just trying to draw stuff on top of the desktop, you can probably do something similar.