Created
December 13, 2020 13:05
-
-
Save zztalker/5fefe550a6e669dd39c5c71daa844e11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import win32gui as w | |
import win32con as wc | |
import win32process as wp | |
TRACK_MODE, RESTRICT_MODE = "TRACK", "RESTRICT" | |
while True: | |
handle = w.GetForegroundWindow() | |
w_name = w.GetwindowText(handle) | |
t_id, p_id = wp.GetWindowThreadProcessId(handle) | |
print(handle, w_name, t_id, p_id) | |
time.sleep(1) | |
# to kill window | |
mode = get_mode() | |
# if mode == RESTRICT_MODE and | |
# w.PostMessage(handle,win32con.WM_CLOSE,0,0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment