python---pyautogui

# -*- coding: utf-8 -*-
import pyautogui
import time
print("解除现场引当")
#切换到网页
#pyautogui.moveTo(163,753,duration=0.2)
#pyautogui.click()
a = 344  
b = 1
c = 3
n1 = time.time()
count1 =0
while count1 < c:
    count = 0
    pyautogui.moveTo(163,753,duration=0.2)
    pyautogui.click()
    
    while count < b:
        pyautogui.moveTo(699,a,duration=0.3)
        pyautogui.click()
        
        pyautogui.moveTo(816,79,duration=0.3)
        pyautogui.click()
         
        pyautogui.moveTo(699,328,duration=0.3)
        pyautogui.click()
        pyautogui.press('enter') 
    #    pyautogui.moveTo(915,84,duration=0.2)
    #    pyautogui.click()
        count = count + 1
    else:
        print (count, " 大于或等于 5")
    #点击数据库
    pyautogui.moveTo(220,751,duration=0.1)
    pyautogui.click()
    #运行数据库
    pyautogui.press('f5')
    #复制品目编码
    pyautogui.moveTo(296,468,duration=0.1)
    pyautogui.click()
    pyautogui.hotkey('ctrl', 'c')
    #切换到网页
    pyautogui.moveTo(163,753,duration=0.1)
    pyautogui.click()
    #粘贴品目编码
    pyautogui.moveTo(287,197,duration=0.1)
    pyautogui.doubleClick()
    pyautogui.hotkey('ctrl', 'v')
    
    #点击数据库
    pyautogui.moveTo(220,751,duration=0.1)
    pyautogui.click()
    #复制线别编码
    pyautogui.moveTo(353,464,duration=0.1)
    pyautogui.click()
    pyautogui.hotkey('ctrl', 'c')
    #切换到网页
    pyautogui.moveTo(163,753,duration=0.1)
    pyautogui.click()
    #粘贴品目编码
    pyautogui.moveTo(235,243,duration=0.1)
    pyautogui.doubleClick()
    pyautogui.hotkey('ctrl', 'v')
    #刷新网页
    pyautogui.press('enter') 
    
#    #点击数据库
#    pyautogui.moveTo(220,751,duration=0.2)
#    pyautogui.click()
#    #复制条目次数
#    pyautogui.moveTo(401,468,duration=0.5)
#    pyautogui.click()
#    pyautogui.hotkey('ctrl', 'c')
    #切换到python
    pyautogui.moveTo(414,752,duration=0.2)
    pyautogui.click()
    #粘贴条目次数
#    pyautogui.moveTo(808,261,duration=0.2)
#    pyautogui.doubleClick()
#    pyautogui.hotkey('ctrl', 'v')
#    
    count1 = count1 + 1
else:
    print (count, " 大于或等于 6")

n2 = time.time()
n3 = n2-n1
print(n3)
#运行系统
#pyautogui.press('f5') 



#
#pyautogui.moveTo(415,758,duration=0.2)
#pyautogui.doubleClick()

#print("更新现场库存")    
##a =344   
#b = 1
#count = 0
#while count < b:
#    pyautogui.moveTo(77,282,duration=0.8)
#    pyautogui.click()
#    
#    pyautogui.moveTo(703,72,duration=0.8)
#    pyautogui.click()
#     
#    pyautogui.moveTo(862,75,duration=0.4)
#    pyautogui.click()
#     
##    pyautogui.moveTo(915,84,duration=0.05)
##    pyautogui.click()
#    count = count + 1
#else:
#    print (count, " 大于或等于 5")
#pyautogui.moveTo(1222,76,duration=0.8)
#pyautogui.click()   
#
#pyautogui.moveTo(28,336,duration=0.8)
#pyautogui.click()  
#
#pyautogui.moveTo(163,224,duration=0.8)
##pyautogui.click()  
#
##pyautogui.moveTo(163,224, duration=0.8)
#pyautogui.click(button = 'right')  
#
#pyautogui.moveTo(242, 317,duration=0.2)
#pyautogui.click()  
### 使用 PyAutoGUI 库在指定区域内进行图像匹配和识别 为了实现在特定区域内查找并点击目标图像的功能,可以利用 `pyautogui.locateOnScreen()` 方法来定位图像的位置,并通过传递额外参数限定搜索范围。此方法返回的是一个矩形框坐标 (left, top, width, height),如果未找到则返回 None。 对于更精确的操作需求,比如只在一个较小的子窗口内寻找图标而不是整个屏幕,`region=(x,y,w,h)` 参数允许设定自定义的扫描区域能够显著提高效率与准确性[^1]: ```python import pyautogui # 定义要查找的目标图片路径以及设置置信度阈值 target_image = 'C:/pythoncode/new/target.png' confidence_level = 0.85 try: # 在屏幕上指定区域(左上角起点X=100,Y=200;宽度W=500px,高度H=400px)内查找目标图片 location = pyautogui.locateOnScreen(target_image, region=(100, 200, 500, 400), confidence=confidence_level) if location is not None: center = pyautogui.center(location) print(f'Found target at {center}') # 移动鼠标到中心点并单击 pyautogui.click(center) except Exception as e: print('An error occurred:', str(e)) ``` 需要注意的是,当文件夹或文件名称含有非ASCII字符(如中文)时可能会引发错误,因此建议保持所有涉及路径均为纯英文字符以确保兼容性良好[^4]。 此外,调整系统的显示缩放比例也会影响最终坐标的计算结果,所以在执行上述脚本之前应当先确认当前使用的显示器分辨率及DPI设置是否处于默认状态[^2]。 最后,考虑到实际应用环境中可能存在相似图案干扰的情况,适当调节 `confidence` 参数可帮助过滤掉不完美的匹配项从而提升稳定性[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值