autopy的使用探索

autopy这个包可以直接操作电脑的一些行为,比如点击,移动鼠标啥的,但是可能只使用于windows,用处有限,不过做个简单的游戏辅助还是可以的。

网上资料贼少,很多不能用的,现总结一些可以用的放在这:

import autopy
autopy.alert.alert('hello')
autopy.mouse.move(100,100)
autopy.mouse.smooth_move(400,400)
print(autopy.mouse.location())
width,height = autopy.screen.size()
print(width,height)
a = autopy.bitmap.capture_screen().get_color(1,1)
b = autopy.screen.get_color(1,1)
autopy.bitmap.capture_screen().save('lfsenior.png')
autopy.mouse.click()
autopy.mouse.toggle(None,True)
autopy.mouse.toggle(None,False)
autopy.mouse.toggle(down=True,button=None)

autopy.mouse.toggle(True)
def where_is_the_rubbish():
    '''查找回收站在屏幕中的位置'''
    rubbish=autopy.bitmap.Bitmap.open('rubbish.png')
    screen=autopy.bitmap.capture_screen()
    pos=screen.find_bitmap(rubbish)
    if pos:
        print ('找到了,他的位置在:%s' % str(pos))
    else:
        print ('没有找到')
where_is_the_rubbish()

目前成功的代码,右键不知道怎点击,找了圈没找到。

 补,右键点击

autopy.mouse.click(autopy.mouse.Button.RIGHT)
posted @ 2018-12-20 08:36  猪啊美  阅读(2708)  评论(0编辑  收藏  举报