I am very new to python but do have experience in other languages. I recently bought the PC version of Final Fantasy III on steam and I wanted to test my week-old python skills to see if I could automatically send keystrokes to the game to essentially play for me and grind my job levels while I'm away.
A quick search on the internet and I found this http://win32com.goermezer.de/content/view/136/254/ which I hoped would enable me to do just that.
Here's my code:
import win32com.client
import time
shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate("Final Fantasy III")
def actionSelect():
time.sleep(1) #time between switching characters
shell.SendKeys("s", 0) #'s' is my down key
time.sleep(0.2)
shell.SendKeys("s", 0)
# so it goes down two options for each character for the 'Guard' option
time.sleep(0.2) #slight delay between each key to compensate for processing
shell.SendKeys("e", 0) #then it uses the 'e' key to select that option
return
def battle():
time.sleep(5)
for rounds in range(0, 10): #loops 10 times (due to xp gain per action)
for action in range(0, 4): #loops 4 times = 4 charcaters
actionSelect()
time.sleep(9) #time for all to Guard and enemy to attack
battle()
I have no idea what the third and fourth lines of code do and no small amount of Google-ing and scanning could tell me in layman's terms. I am also unsure as to what the 0 in SendKeys("s", 0) does. The code itself works... but only in any text box I click. It does not switch into the game window as I had planned (how can I do this?) and if I switch into the game manually it keeps running in the background but wont actually control anything in the game.
Any help on my "fun" weekend project would be much obliged. Thanks.