python+autoit用法

一、自己封装的一些使用到的autoit库

import autoit

class MouseControl(object):
    '''
    AutoIt鼠标相关操作
    '''
    def __init__(self):
        '''
        Constructor
        '''
        
    def click(self, title, text, x, y, button="main", clicks=1):
        '''
        :description 执行鼠标点击操作
        '''
        pos = autoit.win_get_pos(title, text=text)
        autoit.mouse_click(button, x + pos[0], y + pos[1], clicks=clicks)
        
    def move(self, title, text, x, y):
        '''
        :description 移动鼠标指针
        '''
        pos = autoit.win_get_pos(title, text=text)
        autoit.mouse_move(x + pos[0], y + pos[1])
        
    def drag(self, title, text, x1, y1, x2, y2):
        '''
        :description 执行鼠标拖拽操作
        '''
        pos = autoit.win_get_pos(title, text=text)
        autoit.mouse_click_drag(x1 + pos[0], y1 + pos[1], x2 + pos[0], y2 + pos[1])
        
    def wheel(self, direction="up"):
        '''
        :description 产生向上或向下滚动鼠标滚轮事件.仅支持NT/2000/XP及更高.
        '''
        autoit.mouse_wheel(direction)

mouseControl.py
import autoit

class ProcessControl(object):
    '''
    AutoIt进程相关操作
    '''
    
    def __init__(self, processName):
        '''
        Constructor
        '''
        self.processName = processName
        
    def close(self):
        '''
        :description 终止某个进程
        :return 1:成功; 0:失败.
        '''
        return autoit.process_close(self.processName)
        
    def exists(self):
        '''
        :description 检查指定进程是否存在
        :return PID:成功; 0:进程不存在.
        '''
        return autoit.process_exists(self.processName)

processControl
import autoit

class WinControl(object):
    &#
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用Python的Selenium库进行图片上传时,可以通过定位元素属性为type="file"的按钮,然后使用send_keys方法将图片文件的路径传递给该元素。以下是一个示例代码: ``` from selenium import webdriver browser = webdriver.Firefox() browser.get('http://app.xunjietupian.com/crop') # 定位上传按钮元素 upload_button = browser.find_element_by_xpath('//input[@type="file"]') # 上传图片 upload_button.send_keys("/path/to/image.jpg") # 将图片路径替换为实际的图片路径 ``` 这样就可以使用Python的Selenium<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Selenium上传图片(python+Selenium+AutoIT)](https://blog.csdn.net/weixin_42763696/article/details/105781884)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Python SELENIUM上传文件或图片实现过程](https://download.csdn.net/download/weixin_38687904/14012043)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [利用Selenium实现图片文件上传的两种方式(解决Selenium不能上传文件问题)](https://blog.csdn.net/legend818/article/details/105653352)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值