Skip to content

Instantly share code, notes, and snippets.

@tspangler
Created October 22, 2018 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tspangler/bc59dab8b1e0a95f9a349761a93bca00 to your computer and use it in GitHub Desktop.
Save tspangler/bc59dab8b1e0a95f9a349761a93bca00 to your computer and use it in GitHub Desktop.
Look for a window and maximize it when found
# `gem install win32-window` first
require 'win32/window'
puts "Searching for Notepad window..."
window = nil
loop do
window = Window.find(title: /Notepad/)
break unless window.empty?
end
window = window.first
puts "Found Notepad window with hwnd #{window.handle}. Maximizing..."
window.maximize
puts "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment