本文整理汇总了Python中window.Window.getScreenShot方法的典型用法代码示例。如果您正苦于以下问题:Python Window.getScreenShot方法的具体用法?Python Window.getScreenShot怎么用?Python Window.getScreenShot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类window.Window
的用法示例。
在下文中一共展示了Window.getScreenShot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import getScreenShot [as 别名]
def main():
w = Window()
start = time.time()
while True:
print "search game area"
w.getScreenShot()
w.current_screen.save("test.png")
gameWin = findGameArea(w)
if gameWin is not None:
print "found area"
break
gameWin.getScreenShot()
gameWin.current_screen.save("whack1.png", "png")
whack = Whack(gameWin)
area = whack.getArea()
area.getScreenShot()
area.current_screen.save("whack2.png", "png")
i=0
while True:
if whack.hasArea():
break
time.sleep(0.3)
ignoreUntilNextClick = (9999,9999)
resetIgnore = 0
while True:
if resetIgnore < time.time():
print "reset",resetIgnore, time.time()
resetIgnore = time.time() + 100
ignoreUntilNextClick = (9999,9999)
i+=1
print i
print "search button"
coords = whack.findClicks(i)
if len(coords) < 1:
continue
if len(coords) > 7:
return
c=0
last = (9999, 9999)
for coord in coords:
c+=1
y,x = coord
print "coord",coord
if y > ignoreUntilNextClick[0] - 90 and y < ignoreUntilNextClick[0] + 90 and x == ignoreUntilNextClick[1]:
print "ignore", ignoreUntilNextClick
continue
#tmp = SubWindow(area, x-10, y-10, 30, 30)
#tmp.getScreenShot()
#tmp.current_screen.save("click"+str(i)+str(c)+".png")
area.mouseMove(x, y)
area.mouseClick()
gameWin.mouseMove(10, 10)
last = coord
if last[0] != 9999:
print "last",last
ignoreUntilNextClick = last
resetIgnore = time.time() + 0.6
print time.time()-start
示例2: main
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import getScreenShot [as 别名]
def main():
w = Window()
while True:
print "search game area"
w.getScreenShot()
gameWin = findGameArea(w)
if gameWin is not None:
print "found area"
break
gameWin.getScreenShot()
gameWin.current_screen.save("game1.png", "png")
healthbar = HealthBar(gameWin, constants)
healthbar.saveScreenshot('health')
healthpot = HealthPot(gameWin, constants)
healthpot.saveScreenshot('healthpotmoney')
manapot = ManaPot(gameWin, constants)
manapot.saveScreenshot('manapotmoney')
inventory = InventoryWindow(gameWin, constants)
inventory.saveScreenshot('inventory')
loot = LootWindow(gameWin, constants)
loot.saveScreenshot('loot')
if not healthpot.hasPot():
print "no health pots"
if not manapot.hasPot():
print "no mana pots"
i=0
checknextHealth = 0
checknextLoot = 9999990
nextSpell = 0
healthHistory = []
while True:
time.sleep(0.05)
i+=1
print i
if i > checknextLoot:
if loot.hasLoot():
coords = loot.getLootPositions()
loot.saveScreenshot('loot%d'%i)
if coords != []:
x, y = autopy.mouse.get_pos()
for coord in coords:
print "foundloot"
loot.window.mouseMove(coord[0], coord[1])
loot.window.mouseClick()
loot.window.mouseClick()
autopy.mouse.move(x, y)
checknextLoot = i+80
if i > checknextHealth:
full = healthbar.getPercentFull()
if full < 50:
#healthbar.saveScreenshot("bartakepot%d"% i)
print "50% health lost"
# can take pot, when has at least one
canTakePot = healthpot.hasPot()
# can take pot, when not in last 40*0.05=2seconds two pots were taken
if len(healthHistory) > 1 and healthHistory[-2] > i-40:
canTakePot = False
# can take pot, when more than 25%
if full>25 and canTakePot:
checknextHealth = i+10
#healthpot.saveScreenshot("takepot%d"% i)
healthbar.saveScreenshot("bartakepot%d"% i)
print "send f"
autopy.key.tap('f')
healthHistory.append(i)
else:
checknextHealth = i+200
# no healthpot left - going home
print "send g"
autopy.key.tap('g')
elif full < 80:
if nextSpell < i:
autopy.key.tap(' ')
print "space"
nextSpell=i+20