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)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM