This is the code I tried.It gives the mouse Click event in macOS
let eventObserver = NSEvent.addGlobalMonitorForEvents(matching: NSEvent.EventTypeMask.leftMouseDown) { (event) -> Void in
Swift.print("Event is \(event)")
}
when I clicked any place. It gives output
Event is NSEvent: type=LMouseDown loc=(248.664,269.775) time=12673.2 flags=0 win=0x0 winNum=91 ctxt=0x0 evNum=905 click=1 buttonNumber=0 pressure=1 deviceID:0x300000014400000 subtype=NSEventSubtypeTouch
when I checked the output type it says NSEvent type. Does anyone know how to convert this to a string array or string object? Because After that I want to convert it to JSON.