Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make a keyboard input command from a python script

is there any way to make keyboard input from my program. suppose my program reeives "1" from a socket. how this data can be converted to a real time keyboard hit. means when "1" would receive , the computer would think that i pressed "1" .

like image 546
arifcse10 Avatar asked Jan 27 '26 09:01

arifcse10


1 Answers

In Windows, you can use pywin32 to make a keypress. See this previous answer for a code example.

In Linux, this previous answer has you covered, using xsendkey or xsendkeycode

And for Macs, another previous answer using PyQt or wxPython.

like image 152
Wehrdo Avatar answered Feb 03 '26 08:02

Wehrdo