I'm using Tkinter to create an overlay on top of every other windows. For now, if I click on my overlay, like an image or a button, it changes the active windows to Tkinter, obviously. What i want is to use my overlay but keeping my active windows. I looked around click-through type of things but for now it's either i can't click my buttons and the window remain active, either I can but Tkinter switch to active window. I'm new to python and I'm not sure if my code worth sharing, as it is quite simple, but it might to avoid any misunderstanding :
root = Tk()
root.geometry("1920x1080")
root.config(bg='#add123')
root.wm_attributes('-transparentcolor', '#add123')
root.attributes("-fullscreen", True)
root.attributes('-topmost',True)
EDIT: I'm going to try to be as clear as possible. If I use a GUI made with Tkinter, like any others widows, it will become the "Active window". So if I'm using my overlay with another app let's say Firefox. Thanks to topmost attribute, my overlay will stay on top while using Firefox as "active window" which is what i want. But if click a button on my overlay, the "active window" will become Tkinter. To give an example, if I star typing in the URL bar then click a button on my overlay, I won't be able to continue to type in the URL bar since Firefox is no more the "Active window". This is an issue to me as I'm using this overlay over a full screen app that pause when it's inactive. Thanks again ;)
EDIT2: So I might be doing something wrong i'll share the code with you:
from tkinter import *
from PIL import Image, ImageTk
import win32gui
import win32con
def setClickthrough(hwnd):
print("setting window properties")
try:
styles = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
styles = win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT
win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, styles)
win32gui.SetLayeredWindowAttributes(hwnd, 0, 255, win32con.LWA_ALPHA)
except Exception as e:
print(e)
width = 1920 #self.winfo_screenwidth()
height = 1080 #self.winfo_screenheight()
root = Tk()
root.geometry("1920x1080")
root.config(bg='#add123')
root.wm_attributes('-transparentcolor', '#add123')
root.attributes("-fullscreen", True)
root.wm_attributes("-topmost", 1)
bg = Canvas(root, width=width, height=height)
setClickthrough(bg.winfo_id())
frame = ImageTk.PhotoImage(file="sample.png")
bg.create_image(1920/2, 1080/2, image=frame)
bg.button_1 = Button(root,text='Click')
bg.button_1.pack()
bg.pack()
root.mainloop()
At this point, the image "sample.png" is clickable trough but not the Button. If that make sense