无背景,透明,无边框,止步于此,其余自己发挥,我是学不懂python了太难搞了
import math import pyautogui import pygame import pygame as py import win32api import win32con import win32gui import time import threading import base64 import requests py.init() # 初始化 window_width = 700 window_height = 450 window_x = -1 window_y = -1 window_screen = py.display.set_mode((window_width, window_height), pygame.RESIZABLE | pygame.SWSURFACE) hwnd = py.display.get_wm_info()["window"] win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong( hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED) win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(255, 0, 128), 0, win32con.LWA_COLORKEY) win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE) font = py.font.SysFont("Times New Roman", 54) # 要展示的文本 text = [] # 设置文本位置 text.append((font.render("transparent window", 0, (255, 100, 0)), (20, 10))) text.append((font.render("ESC to exit", 0, (255, 100, 100)), (20, 100))) text.append((font.render("(Click window title to focus)", 0, (255, 100, 100)), (20, 250))) done = 0 pygame_focus = False # def do_something_in_the_background: # pass # thread = threading.Thread(target=do_something_in_background) # thread.start() # 展示文本 def show_text(): for t in text: window_screen.blit(t[0], t[1]) if __name__ == "__main__": pygame_focus = True while not done: for event in py.event.get(): print(event) if event.type == py.WINDOWFOCUSGAINED: pygame_focus = True elif event.type == py.WINDOWFOCUSLOST: pygame_focus = False elif event.type == py.QUIT: done = 1 elif event.type == py.KEYDOWN: if event.key == py.K_ESCAPE: done = 1 elif event.type == py.WINDOWMOVED: window_x = event.x window_y = event.y if window_x < 0: window_x = 0 if window_y < 0: window_y = 0 elif event.type == py.VIDEORESIZE: window_width, window_height = event.size # 设置透明 window_screen.fill((255, 0, 128)) # 将文字写上去 show_text() py.display.update() # thread.join()