python之auto鼠标/键盘事件

##test.py

import os,sys
from mouse_key import *

def move_click(x,y,t=0.01):
    mouse_move(x,y)
    time.sleep(t)
    mouse_click(x,y)
def readFile(fname):
    with open(fname, 'r') as f:
        return f.readlines()


#load url list
urlList = readFile(sys.argv[1])
for url in urlList:
    #open chrome
    os.system("start chrome %s" % (url))
    time.sleep(10)
    #move to input tag
    move_click(383,288)
    time.sleep(1)
    #input sexy
    key_input("sexy")
    sendKey(0x0D)
    time.sleep(1)
    #input enter key
    sendKey(0x0D)
    time.sleep(1)


## mouse_key.py

import os
import time
import win32gui
import win32api
import win32con
from ctypes import *


###################################################################################################
#   Define the KeyValue
###################################################################################################
VK_CODE = {
    'backspace':0x08,'  ':0x08,' ':0x08,
    'tab':0x09,
    'clear':0x0C,
    'enter':0x0D,
    'shift':0x10,
    'ctrl':0x11,
    'alt':0x12,
    'pause':0x13,
    'caps_lock':0x14,
    'esc':0x1B,
    'spacebar':0x20,
    'page_up':0x21,
    'page_down':0x22,
    'end':0x23,
    'home':0x24,
    'left_arrow':0x25,
    &
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值