0

I am working on an app, with speech to text functionality, in which I have to add text in third party app when user speak something ,in Mac osx. My question is , is there any way i can detect if user has focused on editing area only. I can detect which app it is using

NSWorkspace.shared.notificationCenter.addObserver(self,    // HERE, shared
            selector: #selector(printMe(_:)),
            name: NSWorkspace.didActivateApplicationNotification,  // HERE
            object:nil)

,which gives app name. But it's not that useful as if user open any non text editing app and start speaking.

Is there any way we can detect if user has focused on editor in third party app using AppleScript or Accessibility or any other way?

Krishna Maru
  • 164
  • 13
  • Does this answer your question? [How to find cursor position of a currently focused text editable element on Mac OS X?](https://stackoverflow.com/questions/40178040/how-to-find-cursor-position-of-a-currently-focused-text-editable-element-on-mac) – Willeke Jul 31 '20 at 15:44
  • @Willeke, by seeing that answer I feel, it uses Accessibility. and it gives element.AXSelectedTextRange. which can be non editable text also. I dont know I am right or not, but I think it won't work in all cases. and also for app which doesn't support accessibility full like chrome, mail, pages this won't work. – Krishna Maru Aug 04 '20 at 08:18
  • 1
    On closer inspection the linked answer is not usefull. How about this one [How to get global screen coordinates of currently selected text via Accessibility APIs](https://stackoverflow.com/questions/6544311/how-to-get-global-screen-coordinates-of-currently-selected-text-via-accessibilit)? Remove the "screen coordinates" part. – Willeke Aug 04 '20 at 09:51

0 Answers0