import win32com.client as comclt import win32gui import datetime import time import random wsh = comclt.Dispatch("WScript.Shell") p1 = "Xaviera Kirby was keying a computer program when she realized she kept making the mistake of keying a \ for a /. The symbol / is called the diagonal, the slash, or occasionally, the virgule. Xaviera didn't know that she could always use the diagonal, /, between two words to indicate that the meaning of either word pertains; i.e., and/or. In addition, the slash could be used as a dividing line in dates or fractions; i.e., 4/23/94 or 1/6. The virgule, /, is also used as the division symbol in almost all programming languages and in particular mathematical applications." p2 = "You will learn in class that computer software directs the hardware to do its work in the proper way. You may already know about a common type of software, a word processor. Other kinds include database, spreadsheet, desktop publishing, and graphics. Often these are included in one integrated package that is sold at a very reasonable price. Software costs are most likely based on the quality and quantity of work that the software will allow a personal computer to do. It's very important that your hardware have enough memory to run the software that you want to use." class KeyChamp(object): pass def checkActive(self): if win32gui.GetForegroundWindow() == self.npad: return True else: raise Exception('Program has to be active!') def timer(self): current = datetime.datetime.now() elapsed = current - self.start if elapsed > datetime.timedelta(seconds=300): raise Exception('Time is up!') def specialKeys(self, key): if key == '%': wsh.SendKeys("{%}") elif key == '^': wsh.SendKeys("{^}") elif key == '+': wsh.SendKeys("{+}") elif key == '~': wsh.SendKeys("{~}") def typing(self): wsh.AppActivate("Keychamp 2.0") # select the application self.npad = win32gui.GetForegroundWindow() self.start = datetime.datetime.now() while True: wsh.SendKeys("{Tab}") for i in p1: if i == '%' or i == '^' or i == '+' or i == '~': self.specialKeys(i) elif self.checkActive() != True: exit else: wsh.SendKeys(i) # send the keys you want time.sleep(random.uniform(0.200, 0.210)) self.timer() wsh.SendKeys("{Enter}") wsh.SendKeys("{Tab}") for i in p2: if i == '%' or i == '^' or i == '+' or i == '~': self.specialKeys(i) elif self.checkActive() != True: exit else: wsh.SendKeys(i) # send the keys you want time.sleep(random.uniform(0.200, 0.210)) self.timer() wsh.SendKeys("{Enter}") k = KeyChamp() k.typing()