python实现快捷键的方法

python实现快捷键的方法

import pyautogui
import time
import keyboard
import pyautogui as pag
iscanzhixing=1;
def test_a():
    global iscanzhixing
    # 只能执行一次
    if iscanzhixing==0:
        return 1;
    iscanzhixing=0;
    px,py = pag.position() #返回鼠标的坐标

    time_stamp = time.time() 
    img = pyautogui.screenshot(region=[px,py,600,600]) # x,y,w,h
    img.save("xx/jietu"+str( round(time_stamp * 1000) )+".jpg")
    iscanzhixing=1;
    print(iscanzhixing);

keyboard.add_hotkey('z', test_a)
keyboard.wait()


如果遇到什么不懂的地方直接关注公众号留言(本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。)
作者:newmiracle
出处:https://www.cnblogs.com/newmiracle/

 
原文地址:https://www.cnblogs.com/newmiracle/p/15309092.html