0

I'm looking to create something that interacts with your desktop in some way with pygame.
What I want to do is draw something outside of the pygame window, as in anywhere on the screen.
Is this possible at all?
What would be more helpful, if you can do it at all, is if you can draw without a window even on the screen.

Connor Club
  • 64
  • 1
  • 7

1 Answers1

1

I had an idea that to create a transparent fullscreen window That Can Be Displayed on The Desktop. 

import pygame
from win32api import GetSystemMetrics
import win32api
import win32con
import win32gui

pygame.init()
screen = pygame.display.set_mode((GetSystemMetrics(0),GetSystemMetrics(1)),pygame.FULLSCREEN)
done = False

fuchsia = (255, 0, 128)

hwnd = pygame.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(*fuchsia), 0, win32con.LWA_COLORKEY)

while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
    
    screen.fill(fuchsia)
    pygame.draw.rect(screen, (200,200,0), pygame.Rect(30, 30, 100, 100))
    pygame.display.update()