Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate 'enter' key in Python (on a Mac)

I'm creating test automation for an application. I am using a testing tool to do most of the testing, but in order to get to that point I first need to automate one 'enter' key click in Python. I am using a mac, so pywin32 is not available. Any suggestions?

like image 804
Roger Avatar asked Nov 13 '22 21:11

Roger


1 Answers

Appscript makes this pretty easy:

from appscript import app
app('System Events').keystroke('\r')

This will send the keystroke to whichever application is in front.

like image 200
zeekay Avatar answered Dec 06 '22 20:12

zeekay