Created
November 29, 2017 21:07
-
-
Save AimForNaN/c3b11530494f3454ce52d66c07c7537e to your computer and use it in GitHub Desktop.
Will position a window onto the main screen to x(0) y(0) with size width(800) height(800)
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
""" | |
Usage: python bring-back-window.py [--title WindowTitle] | |
Example: python bring-back-window.py --title "Create a new Gist - Google Chrome" | |
Depends on Python 3 and pywin32. | |
""" | |
import argparse, win32gui; | |
def enum(hwnd, extra): | |
name = win32gui.GetWindowText(hwnd); | |
# Minor black list! | |
if name and name not in ('Default IME', 'MSCTFIME UI'): | |
try: | |
print(name); | |
pass; | |
except Exception as e: | |
pass; | |
if name == enum.window: | |
win32gui.MoveWindow(hwnd, 0, 0, 800, 800, True); | |
enum.window = None; | |
def main(): | |
parser = argparse.ArgumentParser(description='Bring back my window!'); | |
parser.add_argument('--title', type=str, help='Title of window', dest='window', required=False); | |
args = parser.parse_args(); | |
enum.window = args.window; | |
win32gui.EnumWindows(enum, None); | |
if __name__ == '__main__': | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment