zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    [译]GLUT教程
    [译]GLUT教程
    [译]GLUT教程
    [译]GLUT教程
    [译]GLUT教程
    [译]GLUT教程
    [译]GLUT教程
    表单
    列表、表格与媒体元素
    HTML5基础
  • 原文地址:https://www.cnblogs.com/mypath/p/10147349.html
Copyright © 2011-2022 走看看