TTrayIcon for MacOS? - macos

In Windows VCL, I have the TTrayIcon to be able to (partially) hide my application. Is there a similar method to have an application being outside the normal task list on MacOS and only accessible in an alternate location normally reserved for background applications?
The specifics is a TCP/IP server listening on a port for incoming traffic, but one that doesn't need a UI interface (except for setup purposes). On Windows, I manage this with TTrayIcon and a TPopupMenu, but I am at a loss on how to implement similar functionality on MacOS.

What you are looking for is called Menu Bar app for Mac OSX. A search for "macos menu bar app source code" will yield lots of examples, but I have only found one (partial?) example written in Delphi. The main API to use is NSStatusItem.
EDIT: There is an example statusitem.pas for Lazarus / Free Pascal which might be useful for your purposes.

Related

How can I use Go to make a GUI window?

I am in need to make a simple window in Go to display some text,
there is no need for a real GUI like interface.
How can I make a window like this using Go?
walk is the most common library used for basic GUI development.
You can import the package using:
go get github.com/lxn/walk
I assume you are working at windows OS so create an exe and run it.
More Information about this can be gathered from its source.
Visit https://github.com/lxn/walk
A nice-looking cross-platform UI can be created using HTML5/CSS/JS. You may open a native window with a full-screen browser engine (webview) in it showing your UI.
There is a tiny wrapper library for webviews on Windows, MacOS and Linux - https://github.com/zserge/webview
You can connectyour UI and the core app parts using Go-to-JS bindings (webview library provides those) or a websocket.

Wrapper around web-app under Windows

I have an application with web interface. Unfortunately, it has all disadvantages of being a web page:
It doesn't have a standalone window, so users cannot manage it via the taskbar.
Users see the address line with something like 'http://localhost:8080' that is not a good idea for home users.
If users click on a tray icon, there is no way to activate the tab in a browser, which contain the application interface.
So, it would be nice to have a wrapper application with a browser within.
In case of IE I know it's possible to create a window with Trident ActiveX component. But what if it's Windows XP with IE6 but installed latest Chrome? I'd like to prefer Chrome since it supports a lot more features which the user will never see.
So, is there a way to wrap a page into Chrome/Firefox and make it look like a standalone application, if one of them is presented in the user's system? (The application shouldn't install anything large, so Chromium build is not an option).
P.S. I'm not interested in supporting other platforms than Windows.
Regards,
Take a look at Chrome Apps.
I hope helps you.

How to make an Invisible / Hidden Cocoa Application

I want to develop a application like http://orbicule.com/undercover/ or
http://hiddenapp.com/.
I know how I could do that for windows but I have totally no clue, what kind
of approach I would need for mac os x, cocoa/xcode.
Is there anything I should be aware of when building applicatons / background services
with no GUI for mac os x?
The service will post data to the webpage with the usual data like geo location & IP
information about the machine so it should be able to access the internet too.
Please lead me to the right path.
It's fairly straightforward.
Go to:
Information Property List Key Reference
http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Introduction/Introduction.html
in the Launch Services Keys, you will see one called "LSBackgroundOnly" simply define this in your Info.plist and set it to true.
<key>LSBackgroundOnly</key>
<true/>
From the documentation:
LSBackgroundOnly (Boolean - Mac OS X)
specifies whether this application
runs only in the background. If this
key exists and is set to “1”, Launch
Services runs the application in the
background only. You can use this key
to create faceless background
applications. You should also use this
key if your application uses
higher-level frameworks that connect
to the window server, but are not
intended to be visible to users.
Background applications must be
compiled as Mach-O executables. This
option is not available for CFM
applications.
Your application will be a background application.
Give System Startup Programming Topics a read. Create a command line tool project, not a Cocoa Application nor a Cocoa Document-Based application. To provide a GUI to interface with it you'll want to use a separate application (ideally one you don't have to install with the "hidden" app, since you seem not to want it to be easily discoverable).
With the exception of AppKit (UI) stuff, the rest of the basic Cocoa frameworks is still available to you via the command line. This means you'd write the main logic of your app (the non-GUI parts) the same as you would otherwise.

How to get a list of all open NSWindow from all running application?

Is there a way to get list of open or visible NSWindow from mac desktop?
Note that not all windows are necessarily NSWindows, and that NSWindow only provides an interface to windows in your own address space.
The supported way to access every window is the CGWindow API. Take a look at the Son of Grab sample code to see how it's done.
You can use the accessibility API (accessibility must be enabled under System Preferences for it to work) to get information on windows (and other UI elements) from other processes. This question might be just what you're looking for.
ALL running applications? No. You can only get the NSWindows of your own app. You may be able to use Universal Access or Core Graphics APIs to get some information about windows of other apps, but not full access.

What is the keyword for Mac OS X Service-like applications?

I need to build an application on Mac OS X that runs on the background, windowless and provides a status icon in the top-right corner of the menu bar. It should launch on a specific action initiated by the user (not at system start up) and interact solely through the status bar icon.
On Windows this is very close to Services, on Unix - to daemons. What should i search for in Mac documentation? I just need a few keywords.
Nothing so strictly defined. Mac OS X considers the parts of your question to be separate concepts:
The icon on the right side of the menu bar (i.e., in the status bar) is a status item. Any application can create any number of them, using the NSStatusItem class.
An application with no Dock tile is usually an agent. An application with no UI at all is a daemon. A status item counts as UI, so an application with only a status item is an agent. The typical way to make an agent (with or without a status item) is to set LSUIElement to the string "1" in its Info.plist.
Having never programmed DOS or Windows, I have no idea what “resident” means to you. On Mac OS X, it simply means “in RAM”, which any running application at least partially is.
Services on Windows are not at all connected to this concept. A status item-only utility is the simile for something running solely from the system tray (like one of those delightfully useless nuggets that you get for seemingly every trackpad, audio card or GPU that you have the bad luck to be outfitted with). Services are just background programs a) without UI and b) that support or provide system or application functions. Dozens flare in and out of existence as you use Windows, mostly at startup, and most of them provide completely abstract functionality, such as providing network APIs for other services to use.
That said, Peter's answer is likely what you meant to find out, but I think it should be spelled out that it's not necessarily connected to the equivalent of Windows Services. (If you're looking to build such a thing on OS X, look up daemons and launchd.)
"launchd"
See http://en.wikipedia.org/wiki/Launchd

Resources