• 按键精灵【找图片,并打开该图或打开且关闭两段代码】


    第一次学习,感觉其他语言来写太复杂,用脚本语言写这些简单功能,其实更好,不牵涉多线程这些的情况下,直接贴代码:

    注意:只写了打开,并没有写关闭图片,弱需要,可以自行使用快捷键加上延时的命令,就可以不用手点,隔一段时间继续找下一张以及打开了,这有点类似与游戏内找东西。

    Function say()
    
    // 找与图片类似的窗口图片或图标,实现双击鼠标左键 FindPic 0,0,
    1024,768,"C:UsersmacbookDesktop腾讯视频.bmp",0.5,intX,intY //以下是条件判断;如果返回的坐标大于0,那么就说明找到了。 If intX > 0 And intY > 0 Then //在这里可以添加找到坐标后,需要做的处理。 TracePrint "找到图片了" MoveTo intX + 10, intY + 10 LeftClick 2 Else A = WaitKey() TracePrint "你按下了" KeyPress A,1 End If End Function //测试函数 say

    以上Function里面的才是重点,如需要加循环,请自行实现。

    -----------------------------------------------------------------------------------------------------------------------------------------------------------

    以下是实现打开和关闭的完整代码,循环自行实现,不再赘述

    Function say()
    //1、找到匹配的图片或图标或与该截图类似的部分
    FindPic 0,0,1024,768,"C:UsersmacbookDesktop腾讯视频.bmp",0.5,intX,intY
    //以下是条件判断;如果返回的坐标大于0,那么就说明找到了。
    If intX > 0 And intY > 0 Then
        //在这里可以添加找到坐标后,需要做的处理。
       TracePrint "找到图片了"
       //这里根据鼠标自行调试 ,鼠标移动到该位置
       MoveTo intX + 10, intY + 10
       //鼠标左键双击点击该相同的位置
       LeftClick 2
       //延时关闭,5秒钟后,关闭图片或程序
       Delay 5000
       //寻找关闭的地方 
       FindPic 0,0,1280,800,"C:UsersmacbookDesktop关闭.bmp",0.9,intX,intY
        If intX > 0 And intY > 0 Then 
        //移动到该位置 
        MoveTo intX + 10, intY + 10
        //点击该位置的叉,进行关闭
        LeftClick 1
        End If
    //这是没有找到图片的判断,实现按下键盘任意键,会自动再按该键一次 Else A
    = WaitKey() TracePrint "你按下了" KeyPress A, 1 End If End Function //测试函数 say
  • 相关阅读:
    js 对象合并
    python3 TypeError: 'str' does not support the buffer interface in python
    django rest framework 再撸体验
    linux shell输入重定向
    httpie 取代 curl
    wget 断点续传 & nginx文件服务器
    select2 demo
    vmare centos 6.8 minimal 无法上网
    protocol http not supported or disabled in libcurl apt-get
    python3 -pip
  • 原文地址:https://www.cnblogs.com/ciscolee/p/11790105.html
Copyright © 2020-2023  润新知