I am using this code to obtain current window
from typing import Optional
from ctypes import wintypes, windll, create_unicode_buffer
def getForegroundWindowTitle() -> Optional[str]:
hWnd = windll.user32.GetForegroundWindow()
length = windll.user32.GetWindowTextLengthW(hWnd)
buf = create_unicode_buffer(length + 1)
windll.user32.GetWindowTextW(hWnd, buf, length + 1)
return buf.value if buf.value else None
print(getForegroundWindowTitle())
output:
Videos
git
Downloads
Python check if current window is file explorer - Stack Overflow - Google Chrome
While google chrome tabs can be easily identified using this, problem is there's no way to know whether Videos, git, Downloads are windows folder (opened using file explorer).
So, is there a way to get the output in this format Videos - File Explorer
?
/ check whether the current window is a windows folder/file explorer window ?