0

I am creating an app that will reside on the menubar?

I have a text on the clipboard.

I would like to be able to open an app like Safari, have the cursor inside a text field and select PASTE from my app and paste the text that is already on the clipboard to where the cursor is in the active app.

How do I do that?

If that was a normal paste operation inside the same app I would use something like

func pasteboardImage() -> String? {
    let pb = NSPasteboard.general
    let type = NSPasteboard.PasteboardType.string
    guard let string = pb.string(forType: NSPasteboard.PasteboardType(rawValue: "com.apple.flat")) else { return nil }

    return string
}

How do do I do that, to paste into the selected field of the active app?

NOTE: the suggestion answer does not work for me because I don't want to simulate a CMD V, that would paste the clipboard. I want to use my app to send text to another app.

Duck
  • 34,902
  • 47
  • 248
  • 470
  • Does this answer your question? [Swift macOS: How to paste into another application](https://stackoverflow.com/questions/40096457/swift-macos-how-to-paste-into-another-application) – Willeke Oct 22 '22 at 11:34

0 Answers0