Get Application badge of running applications - macos

I'm not sure if this is possible, but I want to get the application badges of other running applications. So I'd like to get the text from Mail's badge or other apps like Adium. I've looked in NSWorkspace and NSRunningApplication and was not able to find this. Any help would be great.

This could happen someday for applications that use NSDockTile's setBadgeLabel:, but, AFAIK, it's not currently possible. You might want to file a request.
There is no way to do this to applications like Adium that composite the badged Dock icon together themselves and set it, badge and all, as a single image.

Related

How to make screen reader announce text when app is not active?

My requirement is, I have an app that is running in the background and is not having the focus. The user might be using some other applications, and based on certain events in my app, I want the screen reader to announce the text based on my liking. I dont want my app to get the focus, user should be able to continue with the other application, I just want screen reader to announce some texts. I already tried sending QAccessibleEvent with different Events like Alert, NameChanged, ObjectShow etc. But I think since my app is not in focus, it may not be passing through. Could it be possible to achieve my requirement without my app getting focus? Thank you. I am using Qt 5.15 with Windows 10
One possible solution is to directly call screen reader specific API.
However, if you are presenting some text on screen as well, you should rather preferably use the so called toasts, or the notification system, if it's suited to your application.
QT probably provides access to them.
Just in case, I'm the author of a DLL that allows to make several screen readers speak text.
Note that it doesn't show anything on screen.
http://github.com/qtnc/UniversalSpeech

Nesting an application inside OS X subview

I'm looking for a way to embed another application into my own view.
The business reason is that the company has many small Electron apps (basically a small portable web program with a self-contained browser) that the company wants to embed inside an OS X program. These Electron apps would ideally integrate and display inside a subview seamlessly, so they look like little web frames inside our larger program.
I think programatically it would be easiest to open another program as a subview, but I'll take whatever I can get. Maybe even capturing it's NSWindow somehow. (Electron source is available so it is easily discoverable.) Maybe a way to dock the other program inside mine, or (getting more desperate) finding its view and sending commands to constrain it's size and location on top of mine.
So far all I've found says it is not really possible. I've found I can take the more desperate course. I can launch a process, find its view, and position it inside a spot on my display; when the window is moved or the content is scrolled send messages to move the other window. But that isn't really integrated, the menu stays separate, etc., but I cannot incorporate it.
Any ideas or helpful implementation details?
EDIT 1: Thanks for those responses. How about if we could have the electron apps expose their NSWindow somehow? Could that be leveraged? I'm thinking the application could send messages and (somehow, not sure exactly) to set the parent window inside this one. In Windows API it is much easier since you can call SetParent on anything, even items inside different processes. But Cocoa seems more difficult.
This isn't really a thing you can do in Mac OS X. Applications are not "composable" in the way you're hoping for - while it is possible to share a view with a subprocess under certain very specific circumstances (e.g, Safari or Chrome tab renderers), this requires the subapplication to be written in a very specific way to permit that. It's not something that would be feasible in the situation you're describing.
If you have access to the source of these Electron apps, consider combining them into a single overarching Electron application. Alternatively, if it's not possible for these applications to coexist within a single Electron app, you may want to consider using something like Chromium Embedded Framework to build your wrapper application; note, however, that this may require you to implement parts of the Electron framework yourself.
You cannot do that. Cocoa requires you to have only one NSApplication instance per UI app. So you will to fork/exec out new process and launch your applications.
If you can recompile the source code then you can create custom subclass of NSApplication and use that custom class in all the applications or you can create NSthread of other applications without NSApplication instance and go from there.

Sharing images between iOS8 containing app and Custom Keyboard

What is the best way to send images between the containing app and a custom keyboard?
is there a best practice that apple talk about?
is there a hacky way that apple will hate?
is there a framework already that somebody built in github that helps this?
thanks!
You can save images in NSUserDefaults, see Save images in NSUserDefaults? . And since you have access to NSUserDefaults from the keyboard and the app, it works. See my answer in Can a custom keyboard extension identify a user of my companion application in any way? .
Note that in order to enable the sharing of a defaults container you have to follow Apple's docs in the App Extensions programming guide.
It's a very simple and effective solution, but I would only recommend it for a few very small images like icons, etc... Don't make NSUserDefaults a repository for your camera photos!
If you want to do more complex data sharing, I would contend that a custom keyboard is probably not the correct structure.

Is it possible to add custom Data Detectors to OSX Cocoa applications? (such as Mail.app / Safari)

As the title suggests...
Is it possible to add custom Data Detectors to Cocoa apps?
If so, a gentle nudge in the right direction would be great.
Note: To be clear. I want to add new detectors to currents apps. I am not writing a new app.
Thankyou
W
It's not even possible to build a custom data detector on anything but iOS 4. NSDataDetector is only available on iOS 4 and above.
If they existed on OS X and were a plug-in class like Spotlight importers, that'd be a nice feature. Perhaps filing a request at bugreport.apple.com would help it along?
Later update
I think the reason this hasn't been opened up with an API is because they're only meant to find common data (contact info, dates, URLs) for which there is only one (or just a few) uses. That is, contact info can be stored or used in "the" system-designated app. URLs can be auto-highlighted so they're linkable (clicks invoke the system-designated handler - Safari, an app registered to a protocol, etc.). But there's only one direction to funnel those actions and the endpoint is always a major "convenience app" meant to manage this common information (contacts, calendar, browser, email app, phone app...)
On the other hand, consider app-specific information. Data formatted a certain way for use with one app or platform might mean something else entirely to another application. In fact, this is rather common. So what happens when a string like %%SOMESTRING%% is detected? To one app, it might be a placeholder token. To another, it might be a user name. To another still, it might be interpreted as %%USERNAME followed by %%. Suddenly the simple system-wide UI for handling basic data types has to account for multiple actions and/or multiple "data detector plugins" claiming all or part of a format.
I'm not sure we'll ever see custom data detector APIs on iOS or Mac for this reason alone.
While custom data detectors aren't available at the OS level, there is a mechanism that will get you almost there. One possibility is to create a Workflow in Automator and save it in the Services menu.
It can be configured to be active when text is highlighted. You'd either go to the current app's main menu and select the Workflow under "Services", or else right click on the text and go to the "Services" menu from there. Not as easy as clicking on the text as you would a URL, but pretty close.
Create a workflow in Automator on Mac

Anyone know what program the Apple store demos likely use to make their interactive desktop

I have a project that I am attempting to do and we want something similar to what the Apple store does. We thought it was a Quartz Composer interactive desktop but I've been putting together an xcode cocoa solution to do it too.
Here is an image of what I'm wondering about it is just a Title and 3 images that link out to url locations. If anyone can point me in the direction they believe can make something like this I would appreciate it.
I have used Quartz Desktop to display a .qtz but it isn't interactive. If anyone knows of another quartz desktop displaying .app that does use the interactive parts such as mouse and keyboard, it would be appreciated.
Applestore demo http://img707.imageshack.us/img707/614/dsc03934y.jpg
It's a custom proprietary program called, if I remember correctly, Concierge. But it's not doing anything tricky. You can make any NSWindow appear on the desktop by setting its window level to kCGDesktopWindowLevel.

Resources