SSSNIPD
SSSNIPD

Reputation: 103

Can I run a python script from a keyboard shortcut?

I want to be able to run a python script like a keyboard macro, just by pressing a certain combination of buttons. Is it possible, if yes, how?

Upvotes: 7

Views: 16660

Answers (4)

Brett La Pierre
Brett La Pierre

Reputation: 533

Depending on your operating system there will be different ways to run scripts via hot keys. If you create and run a script with "key listeners" you can use that to execute other scripts. There are a few libraries you could use and I've attached a couple of them below.

PyAutoGUI

Pynput

Upvotes: 5

Scott
Scott

Reputation: 132

Yes, if you're on a Mac, you can create a 'quick action' in Automate using an apple script to tell Terminal to do something like 'tell application "Terminal" to do script "python myscript.py"'. Then, you can go into your keyboard shortcut preferences and add a hotkey to the action.

Upvotes: 0

tan
tan

Reputation: 1

Try Ctrl + F5. It worked for me.

Upvotes: -1

Habib Ismail
Habib Ismail

Reputation: 47

you click f5 if you have windows

Upvotes: -2

Related Questions