Python 模拟鼠键

让python 自动操作桌面或应用窗口,点击,滑动鼠标,输入文字等

# coding=utf-8
from pymouse import PyMouse
from pykeyboard import PyKeyboard
import time, random
import pyautogui as pag

m = PyMouse()
k = PyKeyboard()
x_dim, y_dim = m.screen_size()
# 打开浏览器,点击百度搜索框
m.click(282, 183)
time.sleep(0.3)
# 输入关键字
k.type_string('cnblog')
# 回车
k.tap_key(k.enter_key)
# 在页面内瞎点
while True:
    i = random.uniform(-10, 10)
    m.scroll(2 * i, None, None)
    time.sleep(2)
    m.click(500 + 50 * i, 400 + 20 * i)


# 获取鼠标坐标
def getM_xy():
    try:
        while True:
            print "Press Ctrl-C to end"
            x, y = pag.position()  # 返回鼠标的坐标
            posStr = "Position:" + str(x).rjust(4) + ',' + str(y).rjust(4)
            print posStr  # 打印坐标
            time.sleep(1)
            # os.system('cls')  # 清楚屏幕
    except  KeyboardInterrupt:
        print 'end....'

 写出来也不觉得有什么用,纯粹是闲的蛋疼吧。

转载于:https://www.cnblogs.com/lanqie/p/8400578.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值