Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
win32-autogui/spec/applications/calculator.rb
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (34 sloc)
1.08 KB
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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
class Calculator < Autogui::Application | |
# initialize with the binary name 'calc' and the window title | |
# 'Calculator' used along with the application pid to find the | |
# main application window | |
def initialize(options = {}) | |
defaults = { | |
:name => "calc", | |
:title => "Calculator", | |
:logger_level => Autogui::Logging::DEBUG | |
} | |
super defaults.merge(options) | |
end | |
# the calculator's results window | |
def edit_window | |
main_window.children.find {|w| w.window_class == 'Edit'} | |
end | |
# timeout in seconds to wait for desktop windows to appear | |
def default_window_timeout | |
1 | |
end | |
# About dialog, hotkey (VK_MENU, VK_H, VK_A) | |
def dialog_about(options = {}) | |
options[:timeout] = default_window_timeout unless options[:timeout] | |
Autogui::EnumerateDesktopWindows.new(options).find do |w| | |
w.title.match(/About Calculator/) && (w.pid == pid) | |
end | |
end | |
# the 'CE' button | |
def clear_entry | |
set_focus | |
keystroke(VK_DELETE) | |
end | |
end |