Keeping command line tool alive and still get mouse and keyboard events

Hello,

I have swift dylib that I call from a simple c# program through mono. I need the dylib to stay alive and listen to keyboard, mouse, application events as well as receiving commands to move mouse, etc. Looking online I found some suggestion to keep the process running and while they do keep the process alive I'm unable to receive the events I add monitors for.

NSEvent.addGlobalMonitorForEvents(matching: mEvent.eventMask, handler: globalEventCallBack"

I have tried 'Runloop.main.run', DispatchGroup, Semaphore, and while I understand why some don't work (they block the main thread and that's where the events are delivered) I don't understand others.

So here I'm in search of suggestions of how to keep my process alive and still get the events.

Thank in advance and I apologize if I made any mistakes in the post, it is my first time in this forum.

Your quesiton is very specific to Apple technologies and so I’m going to recommend that you post it to Apple Developer Forums. Tag your post with AppKit and Command Line Tools and I’ll see you over there.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

Thanks @eskimo. I have posted it in the Apple Developer Forums. Should I delete here?
Here is the question Question