Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

macos - 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!

question from:https://stackoverflow.com/questions/65914556/how-to-print-a-specified-text-using-quick-actions

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I find a way

if you rite 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...