Last active
December 20, 2015 11:29
-
-
Save ryancastro/6123727 to your computer and use it in GitHub Desktop.
Window-switcher: A co-worker of mine asked me to help him alternate windows on their display. Stats for x seconds, mission statement for x seconds. Here's the 5 minute result.
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
#'compiled' with Ocra | |
require 'win32ole' | |
@wsh = WIN32OLE.new('Wscript.Shell') | |
@title1, @title1_seconds, @title2, @title2_seconds = ARGV | |
if !@title2_seconds | |
puts "usage: window1_title seconds window2_title seconds" | |
puts "ex: Skype 10 Untitled 5" | |
puts "note: you only need to match the first letters in the window title." | |
puts "'Untitled' will find the 'Untitled - Notepad' window" | |
exit | |
end | |
puts "\n\nControl+C to exit\n\n" | |
def alternate_window | |
@wsh.AppActivate @title1 | |
sleep @title1_seconds.to_i | |
@wsh.AppActivate @title2 | |
sleep @title2_seconds.to_i | |
end | |
begin | |
loop {alternate_window} | |
rescue Interrupt | |
puts "\n\nThanks for playin'!\n\n" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment