Send a message to a running DesktopApplication

Under macOS, this may be achieved by sending an AppleEvent and receiving that via the AppleEventReceived handler.

How can I achieve something similar for Windows and Linux (OK, I could probably send a message via a socket but that seems rather heavy).

If you have the MBS plugins you might be able to use WinNotificationMBS on MS-Windows.

If you need a way to do this on all targets it might be best to create a custom solution.

No MBS.

For macOS, I just use the AppleEvent as I described, for which Xojo provides a handy event.

For Win/Lin there are two issues:

  1. how does one send a message to a running desktop app? What event does one use inside the application to detect that the message is available?

  2. for each of those two platforms, what would be the internal format of the message so I can decode to decide what to do.

Specifically, I’m trying to figure out how to get my app to respond to mailto events generated by, f’rinstance, a web browser when a user clicks on a mailto: link.

Register as the handler for mailto: then? That’s the way URI handlers are supposed to be done.

Theres blog posts for Mac and Windows, you’ll have to do your own research for Linux (I don’t have anything handy)

Specifically, I’m trying to figure out how to get my app to respond to mailto

at Windows 11 it is here

or use

Yes, I’m well aware of that. And if I knew how to do that I’d do it rather than asking here.

Yes, I found that some time ago. But it does not then list my app as one which can be selected as the default app for mailto. So, having found that, I am no further forward.

See my answer to @Tim_Parnell .

i found thunderbird via search mailto here


and here

and here

Yes. In a Win-11 system I was using earlier today, if I navigate there it lists OUTLOOK.EXE. Thanks, that looks more promising as while the first one appears to relate to the default, the others may be Thunderbird regsitering itself.

Again, for Mac and Windows it’s on the Xojo Blog.

could be this blog

Thank you both for the pointers. The one thing missing from the Windows one, but not the macOS one, is that the Windows blog talks about a way to start the app which will react to the URI, but says nothing about how to manage when the app is already running and is in the foreground, being used.

Under macOS you get an event, or the app is started and then you get the event; on Windows the assumption seems to be that the app is not running, but that the app is started, and it should then look at system.CommandLine to see what, if anything, it has been sent.

So there is this fundamental difference, it seems, between macOS and Windows.

And Linux is still to come!

The trick to managing the Windows behavior is to use a mutex and an IPCSocket to tell your already running process what to do. I learned that from one of the old Xojo team who mentioned this was how the Feedback app worked.

1 Like

As I hinted in my OP, I was afriad that this might be the case. But in any case it won’t be me telling my app what to do. It’ll be FireFox or Edge or Chrome - that is where the clickable mailto will be lurking. So what do they do, I wonder.