python3.7 特定时间间隔一直循环鼠标双击“我的电脑”图标

python3.7 特定时间间隔一直循环鼠标双击“我的电脑”图标

# -*- coding: utf-8 -*-
"""
Created on Wed Apr  3 11:31:54 2019

@author: fern.xu
"""

import win32api
import win32gui
import win32con
import time
import ctypes
import sched
import os
import datetime

def click(x,y): #第二种
    ctypes.windll.user32.SetCursorPos(x,y)
    ctypes.windll.user32.mouse_event(2,0,0,0,0)
    ctypes.windll.user32.mouse_event(4,0,0,0,0)
    ctypes.windll.user32.mouse_event(2,0,0,0,0)
    ctypes.windll.user32.mouse_event(4,0,0,0,0)

'''
def timer(n):  
    ''''' 
    每n秒执行一次 
    '''  
    while True:    
        print(time.strftime('%Y-%m-%d %X',time.localtime()))    
        click(40,23)  # 此处为要执行的任务    
        time.sleep(n)

#timer(2)
'''

# 第一个参数确定任务的时间,返回从某个特定的时间到现在经历的秒数 
# 第二个参数以某种人为的方式衡量时间 
schedule = sched.scheduler(time.time, time.sleep) 
  
def perform_command(cmd, inc): 
    # 安排inc秒后再次运行自己,即周期运行 
    schedule.enter(inc, 0, perform_command, (cmd, inc)) 
    #os.system(cmd)
    click(40,23)
    quit()
 
   
def timming_exe(cmd, inc = 60): 
    # enter用来安排某事件的发生时间,从现在起第n秒开始启动 
    schedule.enter(inc, 0, perform_command, (cmd, inc)) 
    # 持续运行,直到计划时间队列变成空为止 
    schedule.run() 
   

print("show time after 10 seconds:") 
timming_exe("echo %time%", 20)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐为波

看着给就好了,学习写作有点累!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值