Created
July 25, 2020 18:50
-
-
Save vicwomg/d50e7aa9f76d8870c43aee30da4fb87b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python | |
import os | |
import sys | |
def moveWindowToZero(windowName): | |
print "Moving window '%s' to (0,0)" % windowName | |
cmd=""" | |
osascript<<END | |
tell application "System Events" | |
set position of window 1 of application process "%s" to {0, 0} | |
end tell | |
""" % windowName | |
os.system(cmd) | |
def usageExit(): | |
print "%s: Recovers a rogue OSX window whose title bar may have been pushed off screen. Moves window to top right corner." % sys.argv[0] | |
print "Usage: " | |
print " %s <window_name>" % sys.argv[0] | |
print "Example: " | |
print " %s Terminal" % sys.argv[0] | |
print " (recovers the Terminal window)" | |
print "Notes: " | |
print " The <window_name> can be found by clicking on the runaway app in the dock and reading it off the OSX title bar" | |
print " Enclose the <window_name> in double quotes if it has a space or special chars (ex: \"iOS Simulator\")" | |
sys.exit(1) | |
def main(): | |
if (len(sys.argv) < 2): | |
usageExit() | |
moveWindowToZero(sys.argv[1]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment