I just got into Python (Jython) coding a few hours ago and I'm trying to automate Kik messenger (using an Android emulator) using Sikuli IDE.
I am trying to make a region observer that scans for changes, if a change is made, it will check if any commands are found. I am not really sure what I'm doing, but this is the code I got with some help all around the web and documentations:
cmdScanLoc = Region(Region(65,762,167,59))
def cmdHelp():
type("Help")
type(Key.ENTER)
cmdScanLoc.stopObserver()
def cmdPing():
type("Pong.")
type(Key.ENTER)
cmdScanLoc.stopObserver()
def changeDetected(event):
print("Change")
if cmdScanLoc.exists("1440090739688.png"):
cmdHelp()
elif cmdScanLoc.exists("1440090725124.png"):
cmdPing()
else:
print("No Command Found")
def startObserver():
cmdScanLoc.onChange(50,changeDetected)
cmdScanLoc.observe(10,background=False)
Settings.ObserveScanRate = 10
startObserver()
Here is the log, after typing !ping:
Change
!help
[log] TYPE "Help"
[log] TYPE "#ENTER."
It seems to go to cmdHelp(), even though I typed !ping. How is that possible? It just completely ignores the if-statement.
And here is an image of the region I'm scanning: http://ift.tt/1gZPB3R And an image of the images I'm scanning for: http://ift.tt/1MBYQmR (code in this image is no longer accurate as you can see)
I would greatly appreciate it if someone could guide me in the right direction with this "command scanner" where if a certain command is detected, the appropiate function is called.
Thanks a lot in advance and sorry if this is a really nooby question, I've just been trying for hours and hours, looking up documentation of Sikuli and Python and I just can't get it to work...
Aucun commentaire:
Enregistrer un commentaire