4

I want to be able to have the Python program itself transparent, but all I could find was running other programs and making them transparent, which is not what I want to do. I just want to make the Python program itself transparent using the win32 module.

karel
  • 5,489
  • 46
  • 45
  • 50
Dextron
  • 598
  • 7
  • 24

1 Answers1

3

So after playing around with a test i did in pygame and reading the answer from here: https://stackoverflow.com/questions/4549213/make-a-window-transparent-using-win32

I managed to get it to work and I also can change colour with colorama so that's good. Here's my code:

import win32gui,win32api,win32con

hwnd = win32gui.FindWindow(None, title)
        win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED)
        win32gui.SetLayeredWindowAttributes(hwnd, win32api.RGB(0,0,0), 180, win32con.LWA_ALPHA)

So for some strange reason whenever i try to make the program transparent before my loop starts in my program I get a error about "invalid window handle". I do change the program title but I change it before i try the transparency and i update the title with the trancparancy.

Dextron
  • 598
  • 7
  • 24