Hide command on OS X

I’m added support for quitting and minimizing via the system keyboard shortcuts, ⌘ + Q & ⌘ + M. I want to implement the hide app as well but I’m not sure what needs to be done for that. I have a method set to the hotkey ⌘ + H, but I’m not sure what needs to be done to hide the game. I am using WindowProperties() to minimize the window so I thought that there might be something similar but would allow me to hide the app. Does anyone have any ideas on how to accomplish this within python and panda3d?

One idea was to run an AppleScript command and tell the app to hide, but id like to stick with python and not mix AppleScript into it.

Anyone have any ideas?

Won’t this work on OsX?

wp = WindowProperties()

That works for minimizing the window into the dock. There is an option on OS X to hide it via ⌘ + H. Disney has done this, I remember Toontown and Pirates both supported this, so I know its possible.

From Apple’s NSApplication API docs. developer.apple.com/library/mac … ation/hide:

Update: After spending hours or research and trying numerous things, I had to fallback to AppleScript. I didn’t want to have to do this, but it works pretty well.

For those interested, here is the script I came up with.

hideCommand = """osascript -e 'tell application "System Events" set frontProcess to first process whose frontmost is true set visible of frontProcess to false end tell'"""

If anyone does have a better solution, please let me know

Note that you can also instrument applescript via Python:

There are also other modules out there that can do things like that.