Specifically, the issue is that my Tkinter application, which I have set as "TopMost", is obscured by the "touch keyboard".
My application is inactive, TopMost and sits at the bottom of the display. It's like a mascot. The simplified code is shown below.
import tkinter as tk
import win32api
import win32con
import pywintypes
myapp = tk.Tk()
# Place it at the bottom of the display
myapp.geometry("300x300+200+700")
myapp.wm_attributes("-topmost", True)
myapp.wm_attributes("-disabled", True)
hwnd = pywintypes.HANDLE(int(myapp.wm_frame(), 16))
exStyle = \
win32con.WS_EX_LAYERED | \
win32con.WS_EX_NOACTIVATE | \
win32con.WS_EX_TOPMOST | \
win32con.WS_EX_TRANSPARENT
win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exStyle)
myapp.mainloop()
If you leave this running and display the Windows "touch keyboard", it will be hidden behind it.
When the "touch keyboard" hides my application, I release the TopMost of it, but there is no change.
hwnd_of_touchkey = win32gui.FindWindow(
None, "Microsoft Text Input Application")
win32gui.SetWindowPos(
hwnd_of_touchkey,
win32con.HWND_NOTOPMOST,
0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE
)
Is there any way to lift it up somehow?
Specifically, the issue is that my Tkinter application, which I have set as "TopMost", is obscured by the "touch keyboard".
My application is inactive, TopMost and sits at the bottom of the display. It's like a mascot. The simplified code is shown below.
import tkinter as tk
import win32api
import win32con
import pywintypes
myapp = tk.Tk()
# Place it at the bottom of the display
myapp.geometry("300x300+200+700")
myapp.wm_attributes("-topmost", True)
myapp.wm_attributes("-disabled", True)
hwnd = pywintypes.HANDLE(int(myapp.wm_frame(), 16))
exStyle = \
win32con.WS_EX_LAYERED | \
win32con.WS_EX_NOACTIVATE | \
win32con.WS_EX_TOPMOST | \
win32con.WS_EX_TRANSPARENT
win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exStyle)
myapp.mainloop()
If you leave this running and display the Windows "touch keyboard", it will be hidden behind it.
When the "touch keyboard" hides my application, I release the TopMost of it, but there is no change.
hwnd_of_touchkey = win32gui.FindWindow(
None, "Microsoft Text Input Application")
win32gui.SetWindowPos(
hwnd_of_touchkey,
win32con.HWND_NOTOPMOST,
0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE
)
Is there any way to lift it up somehow?
Share Improve this question edited Mar 17 at 14:41 JRiggles 6,8622 gold badges15 silver badges36 bronze badges asked Mar 17 at 14:20 Kenta KobayashiKenta Kobayashi 11 1 |1 Answer
Reset to default 0No, this is not possible with any supported API's. Also, please don't. Topmost and similar things are reviled by users and run afoul of the "What if two programs did this?" principle.
Historical windows were ordered based on their Z-Index, and the Z-Index could be held above other windows with the Topmost style. Windows 8 added a new layering system called bands, which are not exposed to developers and require the caller of the API's to be cryptographically signed by Microsoft. These layers exist on-top of the desktop windows (which is where Z-Index lies). The topmost band is ZBID_UIACCESS
since it represents soft-input panels that are meant to be the user's means of controlling other applications.
ADeltaX has a great summary on his blog of what has been reverse engineered about the bands system.
(Yes, ZBID_UIACCESS
is accessible with signing and uiAccess="true"
manifest, but that's still not supported for non-assistive technologies)
Related: Is it possible through the Windows API to place a window on top of jump list windows?
WS_EX_TOPMOST
. "Window bands" higher up are reserved for system use to keep the system usable. You wouldn't want some random app to obscure jump lists, the start menu, the on-screen keyboard, or any number of other crucial system UI. – IInspectable Commented Mar 17 at 14:37