直接上代码,copy过去就能用
思路:
后台300ms检测一次窗口的位置
窗口Y方向坐标移到屏幕上界限附近,且鼠标移出窗口时。将窗口移出屏幕。
反过来检测窗口是否在屏幕外+鼠标是否在窗口坐标范围内,再将窗口移回。
同时获取电脑屏幕的长宽,将移出左右两侧的窗口拉回
#!/bin/env python
# -*- coding:utf-8 -*-
'''
Class: my_hide_or_show.py
Programmer: tangzhiying
Date: 2021-12-12
Purpose: demo for hide window
'''
import numpy as np
import sys
import os
import re
import PyWinMouse as mouse #捕捉鼠标坐标
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtWidgets import qApp
from PyQt5.QtWidgets import QApplication, QMainWindow
import time
class Demo(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setFixedSize(self.width(), self.height())
self._init_timer() #定时器
self.mouse = mouse.Mouse() #捕捉
self._get_screen_rect()
def _get_screen_rect(self):
sel