首页 > 其他 > 详细

模拟键盘和复制文件

时间:2021-06-18 14:34:42      阅读:9      评论:0      收藏:0      [点我收藏+]

模拟键盘和复制文件

from pykeyboard import PyKeyboard
import time
import glob
import os
import shutil
import threading

def key_click_f1(t=1):
    k = PyKeyboard()
    while True:
        print(‘点击F1‘)
        k.tap_key(k.function_keys[1]) # 点击功能键F5
        time.sleep(1)

def copy_file(files_map_list,t=30):
    while True:
        for file_map in files_map_list:
            source_dir, aim_dir, file_type = file_map
            glob_source_path = os.path.join(source_dir,‘*.{}‘.format(file_type))
            glob_aim_path = os.path.join(aim_dir,‘*.{}‘.format(file_type))
            source_file_paths = glob.glob(glob_source_path)
            aim_file_paths = glob.glob(glob_aim_path)

            if not aim_file_paths:
                print(files_map_list)
                for source_path in source_file_paths:
                    file_name = os.path.basename(source_path)
                    aim_path = os.path.join(aim_dir,file_name)
                    shutil.copyfile(source_path,aim_path)
        time.sleep(1)

f1_t = threading.Thread(target=key_click_f1,args=(2,),daemon=True)

args_map = [
    [r‘C:\Users\WangLin\Downloads‘,r‘D:\ccc‘, ‘png‘],
    ]
copy_t = threading.Thread(target=copy_file,args=(args_map,),daemon=True)

t_list = []
# t_list.append(f1_t)
t_list.append(copy_t)

for t in t_list:
    t.start()
for t in t_list:
    t.join()

模拟键盘和复制文件

原文:https://www.cnblogs.com/pythonwl/p/14898916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!