macosquickaction

How to print a specified text using Quick Actions


I am trying to make a quick action to be able to paste a specified text (like: 'print('Hello')') on anywhere I can type. So I want to (using my TouchBar) click on a button which will then print a text on (for example Notes). Is there a way to do that? Thanks!


Solution

  • I find a way

    if you write this command in the AppleScript inside the Quick Actions, you can paste 'hello' so you just have to change 'hello'

    tell application "System Events"
        keystroke "hello"
    end tell
    

    But you need to allow the accessibility security for the app you want in system preferences > security& privacy > Privacy. If the app is not shown in the list you can add it manually by pressing the + button right underneath.