Skip to content

Instantly share code, notes, and snippets.

@iwalton3
Created January 16, 2020 04:17
Show Gist options
  • Save iwalton3/52ac640bb2249ad6f0f6343eb6194ca8 to your computer and use it in GitHub Desktop.
Save iwalton3/52ac640bb2249ad6f0f6343eb6194ca8 to your computer and use it in GitHub Desktop.
Raise MPV
# Depends on Python 3 and pywin32.
# https://www.python.org/downloads/
# pip install pywin32
import win32gui
# Mode 5 = Raise to top
# Mode 9 = Unminimize and raise to top
WINDOW_MODE = 5
def windowEnumerationHandler(hwnd, top_windows):
top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
results = []
top_windows = []
win32gui.EnumWindows(windowEnumerationHandler, top_windows)
for i in top_windows:
if "mpv" in i[1].lower():
win32gui.ShowWindow(i[0],WINDOW_MODE)
win32gui.SetForegroundWindow(i[0])
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment