I have just started learning Python and this is my first script:
import os, time
class Key(object):
def __init__(self):
self.key = 'Hello World! '
time.sleep(3)
for x in range(10):
self.simulate()
def simulate(self):
cmd = "osascript -e 'tell application \"System Events\" to keystroke \"" + self.key + "\"'"
os.system(cmd)
key = Key()
key
It will simply type Hello World!
10 times after 3 seconds.
This works great but my method simulate(self)
only works on OS X. How can I make it work on Windows as well?