win32-autogui 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemfiles +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +5 -10
- data/HISTORY.markdown +9 -1
- data/LICENSE +1 -1
- data/README.markdown +84 -48
- data/Rakefile +3 -3
- data/TODO.markdown +1 -1
- data/VERSION +1 -1
- data/examples/quicknote/FormMainU.pas +1 -1
- data/examples/quicknote/README.markdown +1 -1
- data/examples/quicknote/lib/quicknote.rb +29 -30
- data/examples/quicknote/spec/aruba_helper.rb +25 -0
- data/examples/quicknote/spec/quicknote/form_about_spec.rb +2 -2
- data/examples/quicknote/spec/quicknote/form_main_spec.rb +29 -28
- data/examples/quicknote/spec/quicknote/form_splash_spec.rb +1 -1
- data/examples/quicknote/spec/spec_helper.rb +1 -21
- data/examples/skeleton/README.markdown +4 -4
- data/examples/skeleton/features/step_definitions/application_steps.rb +20 -9
- data/examples/skeleton/features/support/env.rb +11 -1
- data/examples/skeleton/lib/myapp.rb +53 -26
- data/examples/skeleton/spec/aruba_helper.rb +25 -0
- data/examples/skeleton/spec/myapp/form_about_spec.rb +3 -2
- data/examples/skeleton/spec/myapp/form_main_spec.rb +10 -17
- data/examples/skeleton/spec/spec_helper.rb +1 -21
- data/examples/skeleton/spec/watchr.rb +43 -24
- data/features/step_definitions/calculator_steps.rb +1 -1
- data/features/support/env.rb +3 -1
- data/lib/win32/autogui.rb +6 -4
- data/lib/win32/autogui/application.rb +35 -35
- data/lib/win32/autogui/input.rb +61 -20
- data/lib/win32/autogui/logging.rb +8 -8
- data/lib/win32/autogui/window.rb +19 -16
- data/lib/win32/autogui/windows/window.rb +1 -1
- data/spec/applications/calculator.rb +4 -4
- data/spec/aruba_helper.rb +25 -0
- data/spec/auto_gui/application_spec.rb +7 -7
- data/spec/auto_gui/logging_spec.rb +1 -2
- data/spec/auto_gui/window_spec.rb +36 -6
- data/spec/basic_gem/aruba_helper_spec.rb +2 -2
- data/spec/basic_gem/basic_gem_spec.rb +67 -1
- data/spec/basic_gem/gemspec_spec.rb +36 -36
- data/spec/spec_helper.rb +1 -21
- data/spec/watchr.rb +2 -3
- data/win32-autogui.gemspec +11 -11
- metadata +11 -8
data/.gemfiles
CHANGED
@@ -30,6 +30,7 @@ examples/quicknote/quicknote.cfg
|
|
30
30
|
examples/quicknote/quicknote.dof
|
31
31
|
examples/quicknote/quicknote.dpr
|
32
32
|
examples/quicknote/quicknote.res
|
33
|
+
examples/quicknote/spec/aruba_helper.rb
|
33
34
|
examples/quicknote/spec/quicknote/form_about_spec.rb
|
34
35
|
examples/quicknote/spec/quicknote/form_main_spec.rb
|
35
36
|
examples/quicknote/spec/quicknote/form_splash_spec.rb
|
@@ -50,6 +51,7 @@ examples/skeleton/features/step_definitions/.gitignore
|
|
50
51
|
examples/skeleton/features/step_definitions/application_steps.rb
|
51
52
|
examples/skeleton/features/support/env.rb
|
52
53
|
examples/skeleton/lib/myapp.rb
|
54
|
+
examples/skeleton/spec/aruba_helper.rb
|
53
55
|
examples/skeleton/spec/myapp/form_about_spec.rb
|
54
56
|
examples/skeleton/spec/myapp/form_main_spec.rb
|
55
57
|
examples/skeleton/spec/spec.opts
|
@@ -66,6 +68,7 @@ lib/win32/autogui/logging.rb
|
|
66
68
|
lib/win32/autogui/window.rb
|
67
69
|
lib/win32/autogui/windows/window.rb
|
68
70
|
spec/applications/calculator.rb
|
71
|
+
spec/aruba_helper.rb
|
69
72
|
spec/auto_gui/application_spec.rb
|
70
73
|
spec/auto_gui/logging_spec.rb
|
71
74
|
spec/auto_gui/window_spec.rb
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
win32-autogui (0.4.
|
4
|
+
win32-autogui (0.4.1)
|
5
5
|
log4r (>= 1.1.9)
|
6
|
-
win32-clipboard (
|
7
|
-
win32-process (
|
8
|
-
windows-api (
|
9
|
-
windows-pr (
|
6
|
+
win32-clipboard (= 0.5.2)
|
7
|
+
win32-process (= 0.6.4)
|
8
|
+
windows-api (= 0.4.0)
|
9
|
+
windows-pr (= 1.1.2)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: http://rubygems.org/
|
@@ -49,12 +49,7 @@ DEPENDENCIES
|
|
49
49
|
bundler (>= 1.0.7)
|
50
50
|
cucumber (>= 0.9.4)
|
51
51
|
kramdown (>= 0.12.0)
|
52
|
-
log4r (>= 1.1.9)
|
53
52
|
rake (>= 0.8.7)
|
54
53
|
rspec (= 1.3.1)
|
55
54
|
win32-autogui!
|
56
|
-
win32-clipboard (>= 0.5.2)
|
57
|
-
win32-process (>= 0.6.4)
|
58
|
-
windows-api (>= 0.4.0)
|
59
|
-
windows-pr (>= 1.1.2)
|
60
55
|
yard (>= 0.6.2)
|
data/HISTORY.markdown
CHANGED
@@ -6,12 +6,20 @@ Most recent changes are at the top
|
|
6
6
|
Changes
|
7
7
|
-------
|
8
8
|
|
9
|
+
### 0.4.1 - 02/03/2011 ###
|
10
|
+
|
11
|
+
* Window.wait_for_close yields if a block is given allowing callbacks during
|
12
|
+
long running waits in order to check for error message dialogs, etc.
|
13
|
+
* Lock down win32 gem dependencies to known working versions
|
14
|
+
* Add input support for shift numeric row
|
15
|
+
* Add input support for VK_OEM_1 through VK_OEM_7
|
16
|
+
|
9
17
|
### 0.4.0 - 11/22/2010 ###
|
10
18
|
|
11
19
|
* Internal specs, features and all examples should run out-of-the-box on both Cygwin and MingW installs
|
12
20
|
* EnumerateDesktopWindows now accepts an optional timeout allowing the "find"
|
13
21
|
method to continue enumerating windows until the timeout is reached
|
14
|
-
* Added static logging constants to Autogui::
|
22
|
+
* Added static logging constants to Autogui::Logging
|
15
23
|
|
16
24
|
### 0.3.0 - 11/08/2010 ###
|
17
25
|
|
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -6,10 +6,10 @@ A Win32 GUI testing framework packaged as a [RubyGem](http://rubygems.org/).
|
|
6
6
|
|
7
7
|
Overview
|
8
8
|
--------
|
9
|
-
Win32-autogui provides a framework to enable GUI application testing
|
10
|
-
with Ruby. This facilitates integration testing of Windows binaries using
|
11
|
-
Ruby based tools like [RSpec](http://github.com/dchelimsky/rspec)
|
12
|
-
and [Cucumber](http://github.com/aslakhellesoy/cucumber). Examples of
|
9
|
+
Win32-autogui provides a framework to enable GUI application testing
|
10
|
+
with Ruby. This facilitates integration testing of Windows binaries using
|
11
|
+
Ruby based tools like [RSpec](http://github.com/dchelimsky/rspec)
|
12
|
+
and [Cucumber](http://github.com/aslakhellesoy/cucumber). Examples of
|
13
13
|
using both these tools are provided with this gem.
|
14
14
|
|
15
15
|
|
@@ -24,7 +24,7 @@ Read our introduction blog posting here: <http://www.gearheadforhire.com/article
|
|
24
24
|
Run Win32-autogui's internal specs and example programs.
|
25
25
|
|
26
26
|
gem install win32-autogui
|
27
|
-
gem install rake bundler win32console cucumber
|
27
|
+
gem install rake bundler win32console cucumber
|
28
28
|
gem install rspec -v 1.3.1
|
29
29
|
|
30
30
|
cd C:\Ruby187\lib\ruby\gems\1.8\gems\win32-autogui-0.4.0
|
@@ -41,59 +41,63 @@ Run Win32-autogui's internal specs and example programs.
|
|
41
41
|
Example Usage: Driving Calc.exe
|
42
42
|
-------------------------------
|
43
43
|
|
44
|
-
Using [RSpec](http://github.com/dchelimsky/rspec) to test drive the stock
|
45
|
-
Window's calculator application. This example is used as Win32-autogui's
|
46
|
-
internal spec. See [spec/auto_gui/application_spec.rb](spec/auto_gui/application_spec.rb).
|
44
|
+
Using [RSpec](http://github.com/dchelimsky/rspec) to test drive the stock
|
45
|
+
Window's calculator application. This example is used as Win32-autogui's
|
46
|
+
internal spec. See [spec/auto_gui/application_spec.rb](spec/auto_gui/application_spec.rb).
|
47
47
|
|
48
|
-
A more complete example of testing a Window's Delphi program is presented with
|
48
|
+
A more complete example of testing a Window's Delphi program is presented with
|
49
49
|
source and binaries in [examples/quicknote/](examples/quicknote/).
|
50
50
|
|
51
51
|
### Wrap the application to be tested ###
|
52
52
|
The first step is to subclass Win32-autogui's application class.
|
53
53
|
|
54
|
-
require '
|
54
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
55
55
|
|
56
56
|
class Calculator < Autogui::Application
|
57
57
|
|
58
58
|
# initialize with the binary name 'calc' and the window title
|
59
|
-
# 'Calculator' used along with the application pid to find the
|
59
|
+
# 'Calculator' used along with the application pid to find the
|
60
60
|
# main application window
|
61
61
|
def initialize(options = {})
|
62
62
|
defaults = {
|
63
63
|
:name => "calc",
|
64
64
|
:title => "Calculator",
|
65
|
-
:
|
65
|
+
:logger_level => Autogui::Logging::DEBUG
|
66
66
|
}
|
67
67
|
super defaults.merge(options)
|
68
68
|
end
|
69
69
|
|
70
|
-
# the calculator's results window
|
70
|
+
# the calculator's results window
|
71
71
|
def edit_window
|
72
72
|
main_window.children.find {|w| w.window_class == 'Edit'}
|
73
73
|
end
|
74
74
|
|
75
75
|
# About dialog, hotkey (VK_MENU, VK_H, VK_A)
|
76
|
-
def dialog_about
|
77
|
-
Autogui::EnumerateDesktopWindows.new.find do |w|
|
76
|
+
def dialog_about(options = {})
|
77
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
78
78
|
w.title.match(/About Calculator/) && (w.pid == pid)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
# the 'CE' button
|
83
83
|
def clear_entry
|
84
|
+
set_focus
|
84
85
|
keystroke(VK_DELETE)
|
85
86
|
end
|
86
87
|
|
87
88
|
end
|
88
89
|
|
90
|
+
|
89
91
|
### Write specs ###
|
90
|
-
The following RSpec code describes driving the Windows calculator for testing.
|
92
|
+
The following RSpec code describes driving the Windows calculator for testing.
|
91
93
|
Multiple instances running simultaneously are supported. See "should control
|
92
94
|
focus with set_focus."
|
93
95
|
|
96
|
+
|
94
97
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
95
98
|
|
96
99
|
include Autogui::Input
|
100
|
+
include Autogui::Logging
|
97
101
|
|
98
102
|
describe Autogui::Application do
|
99
103
|
|
@@ -101,6 +105,7 @@ focus with set_focus."
|
|
101
105
|
|
102
106
|
before(:all) do
|
103
107
|
@calculator = Calculator.new
|
108
|
+
@calculator.set_focus
|
104
109
|
end
|
105
110
|
|
106
111
|
after(:all) do
|
@@ -112,6 +117,13 @@ focus with set_focus."
|
|
112
117
|
@calculator.should be_running
|
113
118
|
end
|
114
119
|
|
120
|
+
it "should die when sending the kill signal" do
|
121
|
+
killme = Calculator.new
|
122
|
+
killme.should be_running
|
123
|
+
killme.kill
|
124
|
+
killme.should_not be_running
|
125
|
+
end
|
126
|
+
|
115
127
|
it "should have the title 'Calculator' that matches the main_window title" do
|
116
128
|
@calculator.main_window.title.should == 'Calculator'
|
117
129
|
@calculator.main_window.title.should == @calculator.title
|
@@ -121,27 +133,30 @@ focus with set_focus."
|
|
121
133
|
@calculator.inspect.should match(/children=</)
|
122
134
|
end
|
123
135
|
|
124
|
-
it "should
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
136
|
+
it "should raise an error if setting focus and the application title is incorrect" do
|
137
|
+
goodcalc = Calculator.new :title => "Calculator"
|
138
|
+
lambda { goodcalc.set_focus }.should_not raise_error
|
139
|
+
goodcalc.close
|
140
|
+
|
141
|
+
badcalc = Calculator.new :title => "BaDTitle"
|
142
|
+
lambda {
|
143
|
+
begin
|
144
|
+
badcalc.setfocus
|
145
|
+
ensure
|
146
|
+
badcalc.kill
|
147
|
+
end
|
148
|
+
}.should raise_error
|
134
149
|
end
|
135
150
|
|
136
151
|
it "should control the focus with 'set_focus'" do
|
137
152
|
@calculator.set_focus
|
138
153
|
keystroke(VK_9)
|
139
154
|
@calculator.edit_window.text.strip.should == "9."
|
140
|
-
|
155
|
+
|
141
156
|
calculator2 = Calculator.new
|
142
157
|
calculator2.pid.should_not == @calculator.pid
|
143
158
|
calculator2.set_focus
|
144
|
-
keystroke(VK_1, VK_0)
|
159
|
+
keystroke(VK_1, VK_0)
|
145
160
|
calculator2.edit_window.text.strip.should == "10."
|
146
161
|
|
147
162
|
@calculator.set_focus
|
@@ -154,7 +169,7 @@ focus with set_focus."
|
|
154
169
|
@calculator.set_focus
|
155
170
|
dialog_about = @calculator.dialog_about
|
156
171
|
dialog_about.should be_nil
|
157
|
-
keystroke(VK_MENU, VK_H, VK_A)
|
172
|
+
keystroke(VK_MENU, VK_H, VK_A)
|
158
173
|
dialog_about = @calculator.dialog_about
|
159
174
|
dialog_about.title.should == "About Calculator"
|
160
175
|
dialog_about.combined_text.should match(/Microsoft . Calculator/)
|
@@ -162,20 +177,38 @@ focus with set_focus."
|
|
162
177
|
@calculator.dialog_about.should be_nil
|
163
178
|
end
|
164
179
|
|
180
|
+
describe "calculations" do
|
181
|
+
before(:each) do
|
182
|
+
@calculator.clear_entry
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should calculate '2+2=4' using the keystroke method" do
|
186
|
+
@calculator.set_focus
|
187
|
+
keystroke(VK_2, VK_ADD, VK_2, VK_RETURN)
|
188
|
+
@calculator.edit_window.text.strip.should == "4."
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should calculate '2+12=14' using the type_in method" do
|
192
|
+
@calculator.set_focus
|
193
|
+
type_in("2+12=")
|
194
|
+
@calculator.edit_window.text.strip.should == "14."
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
165
198
|
describe "clipboard" do
|
166
199
|
before(:each) do
|
167
200
|
@calculator.clear_entry
|
168
201
|
@calculator.clipboard.text = ""
|
169
202
|
@calculator.clipboard.text.should == ""
|
170
203
|
end
|
171
|
-
|
204
|
+
|
172
205
|
describe "copy (VK_CONTROL, VK_C)" do
|
173
206
|
it "should copy the edit window" do
|
174
207
|
@calculator.set_focus
|
175
208
|
type_in("3002")
|
176
|
-
@calculator.edit_window.text.strip.should
|
209
|
+
@calculator.edit_window.text.strip.should match(/3,?002\./)
|
177
210
|
@calculator.edit_window.set_focus
|
178
|
-
keystroke(VK_CONTROL, VK_C)
|
211
|
+
keystroke(VK_CONTROL, VK_C)
|
179
212
|
@calculator.clipboard.text.should == "3002"
|
180
213
|
end
|
181
214
|
end
|
@@ -185,8 +218,8 @@ focus with set_focus."
|
|
185
218
|
@calculator.edit_window.set_focus
|
186
219
|
@calculator.clipboard.text = "12345"
|
187
220
|
@calculator.edit_window.text.strip.should == "0."
|
188
|
-
keystroke(VK_CONTROL, VK_V)
|
189
|
-
@calculator.edit_window.text.strip.should
|
221
|
+
keystroke(VK_CONTROL, VK_V)
|
222
|
+
@calculator.edit_window.text.strip.should match(/12,?345\./)
|
190
223
|
end
|
191
224
|
end
|
192
225
|
|
@@ -199,7 +232,7 @@ focus with set_focus."
|
|
199
232
|
System Requirements
|
200
233
|
-------------------
|
201
234
|
|
202
|
-
Windows OS, version 2000 or higher
|
235
|
+
Windows OS, version 2000 or higher
|
203
236
|
|
204
237
|
Testing was done on the following Ruby platforms:
|
205
238
|
|
@@ -262,27 +295,30 @@ rake -T
|
|
262
295
|
|
263
296
|
### Autotesting with Watchr ###
|
264
297
|
|
265
|
-
[Watchr](http://github.com/mynyml/watchr) provides a flexible alternative to Autotest.
|
266
|
-
jump start script is provided in spec/watchr.rb.
|
298
|
+
[Watchr](http://github.com/mynyml/watchr) provides a flexible alternative to Autotest.
|
267
299
|
|
268
|
-
|
300
|
+
**NOTE:** _The following assumes a global setting of 'git config core.autocrlf
|
301
|
+
input' and that you want to modify the Delphi 7 source to Quicknote which
|
302
|
+
requires CRLF line endings._
|
269
303
|
|
270
|
-
|
304
|
+
Grab the source
|
271
305
|
|
272
|
-
|
306
|
+
cd ~/workspace
|
307
|
+
git clone http://github.com/robertwahler/win32-autogui -n
|
308
|
+
cd win32-autogui
|
309
|
+
git config core.autocrlf true
|
310
|
+
git checkout
|
273
311
|
|
274
|
-
|
312
|
+
#### Install Watchr ####
|
275
313
|
|
276
|
-
|
314
|
+
gem install watchr
|
277
315
|
|
278
|
-
|
316
|
+
#### Run Watchr on Quicknote ####
|
279
317
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
Ctrl-\
|
318
|
+
cd examples/quicknote
|
319
|
+
watchr spec/watchr.rb
|
284
320
|
|
285
|
-
|
321
|
+
Watchr will now watch the files defined in 'spec/watchr.rb' and run RSpec or Cucumber, as appropriate.
|
286
322
|
|
287
323
|
|
288
324
|
Copyright
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# bundler/setup is managing $LOAD_PATH, any gem needed by this Rakefile must
|
3
|
+
# bundler/setup is managing $LOAD_PATH, any gem needed by this Rakefile must
|
4
4
|
# be listed as a development dependency in the gemspec
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
|
-
require 'bundler/setup'
|
7
|
+
require 'bundler/setup'
|
8
8
|
|
9
9
|
# TODO: remove this once issue corrected
|
10
10
|
# Bundler broken up to 1.0.7 on Windows
|
@@ -60,7 +60,7 @@ namespace :doc do
|
|
60
60
|
task :clean do
|
61
61
|
rm_r doc_destination if File.exists?(doc_destination)
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
desc "List undocumented objects"
|
65
65
|
task :undocumented do
|
66
66
|
system('yard stats --list-undoc')
|
data/TODO.markdown
CHANGED
@@ -6,7 +6,7 @@ general
|
|
6
6
|
|
7
7
|
* (1.0) stop changing $LOAD_PATH in specs and features, modify ENV[] in before and afters
|
8
8
|
* (1.0) implement Application.find and add option to not start application automatically, allows driving already running applications
|
9
|
-
* (1.0) application class should be a mixin, not classical inheritance
|
9
|
+
* (1.0) application class should be a mixin, not classical inheritance
|
10
10
|
* (1.0) "rake release" broken on Windows, create patch to fix Bundler. For now, 'git tag v0.3.0 && rake build && gem push pkg/win32-autogui-0.3.0.gem'
|
11
11
|
* (1.0) add an exception dialog watcher that accepts a block and scans for exception dialogs in a separate thread
|
12
12
|
* unicode support for window text
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
@@ -1,7 +1,7 @@
|
|
1
1
|
QuickNote README
|
2
2
|
================
|
3
3
|
|
4
|
-
QuickNote is a stripped down Notepad clone written in Delphi. It is an example GUI executable with
|
4
|
+
QuickNote is a stripped down Notepad clone written in Delphi. It is an example GUI executable with
|
5
5
|
source code for the Win32-autogui gem. It is not fit for any other purpose.
|
6
6
|
|
7
7
|
|
@@ -2,15 +2,14 @@
|
|
2
2
|
# Production code should simply require 'win32/autogui'
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/win32/autogui')
|
4
4
|
|
5
|
-
|
6
5
|
class Quicknote < Autogui::Application
|
7
6
|
|
8
7
|
def initialize(options = {})
|
9
8
|
# relative path to app using Windows style path
|
10
|
-
@name ="exe\\quicknote.exe"
|
9
|
+
@name ="exe\\quicknote.exe"
|
11
10
|
defaults = {
|
12
|
-
:title=> "QuickNote -",
|
13
|
-
:parameters => '--nosplash',
|
11
|
+
:title=> "QuickNote -",
|
12
|
+
:parameters => '--nosplash',
|
14
13
|
:main_window_timeout => 20
|
15
14
|
}
|
16
15
|
super defaults.merge(options)
|
@@ -25,19 +24,19 @@ def status_bar
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def dialog_about(options={})
|
28
|
-
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
27
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
29
28
|
w.title.match(/^About QuickNote/) && (w.pid == pid)
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
32
|
def splash(options={})
|
34
|
-
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
33
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
35
34
|
w.title.match(/^FormSplash/) && (w.pid == pid)
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
38
|
def message_dialog_confirm(options={})
|
40
|
-
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
39
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
41
40
|
w.title.match(/^Confirm/) && (w.pid == pid)
|
42
41
|
end
|
43
42
|
end
|
@@ -45,9 +44,9 @@ def message_dialog_confirm(options={})
|
|
45
44
|
# Title and class are the same as dialog_overwrite_confirm
|
46
45
|
# Use child windows to differentiate
|
47
46
|
def dialog_overwrite_confirm(options={})
|
48
|
-
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
49
|
-
w.title.match(/^Text File Save$/) &&
|
50
|
-
(w.pid == pid) &&
|
47
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
48
|
+
w.title.match(/^Text File Save$/) &&
|
49
|
+
(w.pid == pid) &&
|
51
50
|
(w.window_class == "#32770") &&
|
52
51
|
(w.combined_text.match(/already exists/))
|
53
52
|
end
|
@@ -55,8 +54,8 @@ def dialog_overwrite_confirm(options={})
|
|
55
54
|
|
56
55
|
# Title and class are the same as dialog_overwrite_confirm
|
57
56
|
def file_save_as_dialog(options={})
|
58
|
-
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
59
|
-
w.title.match(/^Text File Save/) &&
|
57
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
58
|
+
w.title.match(/^Text File Save/) &&
|
60
59
|
(w.pid == pid) &&
|
61
60
|
(w.window_class == "#32770") &&
|
62
61
|
(w.combined_text.match(/Save \&in:/))
|
@@ -64,13 +63,13 @@ def file_save_as_dialog(options={})
|
|
64
63
|
end
|
65
64
|
|
66
65
|
def file_open_dialog(options={})
|
67
|
-
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
66
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
68
67
|
w.title.match(/^Text File Open/) && (w.pid == pid)
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
71
|
def error_dialog(options={})
|
73
|
-
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
72
|
+
Autogui::EnumerateDesktopWindows.new(options).find do |w|
|
74
73
|
w.title.match(/^QuickNote$/) && (w.pid == pid) && (w.window_class == "#32770")
|
75
74
|
end
|
76
75
|
end
|
@@ -78,23 +77,23 @@ def error_dialog(options={})
|
|
78
77
|
# menu action File, New
|
79
78
|
def file_new(options={})
|
80
79
|
set_focus
|
81
|
-
keystroke(VK_MENU, VK_F, VK_N)
|
82
|
-
if message_dialog_confirm
|
80
|
+
keystroke(VK_MENU, VK_F, VK_N)
|
81
|
+
if message_dialog_confirm
|
83
82
|
options[:save] == true ? keystroke(VK_Y) : keystroke(VK_N)
|
84
83
|
end
|
85
84
|
# sanity check
|
86
|
-
raise "confirm dialog is still here" if message_dialog_confirm
|
85
|
+
raise "confirm dialog is still here" if message_dialog_confirm
|
87
86
|
end
|
88
|
-
|
87
|
+
|
89
88
|
# menu action File, New
|
90
89
|
def file_open(filename, options={})
|
91
90
|
set_focus
|
92
|
-
keystroke(VK_MENU, VK_F, VK_O)
|
93
|
-
if message_dialog_confirm
|
91
|
+
keystroke(VK_MENU, VK_F, VK_O)
|
92
|
+
if message_dialog_confirm
|
94
93
|
options[:save] == true ? keystroke(VK_Y) : keystroke(VK_N)
|
95
94
|
end
|
96
95
|
|
97
|
-
raise "sanity check, confirm dialog is still here" if message_dialog_confirm
|
96
|
+
raise "sanity check, confirm dialog is still here" if message_dialog_confirm
|
98
97
|
raise "sanity check, file_open_dialog not found" unless file_open_dialog
|
99
98
|
|
100
99
|
# Paste in filename for speed, much faster than 'type_in(filename)'
|
@@ -107,22 +106,22 @@ def file_open(filename, options={})
|
|
107
106
|
# menu action File, Exit
|
108
107
|
def file_exit
|
109
108
|
set_focus
|
110
|
-
keystroke(VK_N) if message_dialog_confirm
|
109
|
+
keystroke(VK_N) if message_dialog_confirm
|
111
110
|
keystroke(VK_ESCAPE) if file_open_dialog
|
112
|
-
keystroke(VK_MENU, VK_F, VK_X)
|
113
|
-
keystroke(VK_N) if message_dialog_confirm
|
111
|
+
keystroke(VK_MENU, VK_F, VK_X)
|
112
|
+
keystroke(VK_N) if message_dialog_confirm
|
114
113
|
end
|
115
|
-
|
114
|
+
|
116
115
|
# menu action File, Save
|
117
116
|
def file_save
|
118
117
|
set_focus
|
119
|
-
keystroke(VK_MENU, VK_F, VK_S)
|
118
|
+
keystroke(VK_MENU, VK_F, VK_S)
|
120
119
|
end
|
121
|
-
|
120
|
+
|
122
121
|
# menu action File, Save As
|
123
122
|
def file_save_as(filename, options={})
|
124
123
|
set_focus
|
125
|
-
keystroke(VK_MENU, VK_F, VK_A)
|
124
|
+
keystroke(VK_MENU, VK_F, VK_A)
|
126
125
|
raise "sanity check, file_save_as_dialog not found" unless file_save_as_dialog
|
127
126
|
|
128
127
|
# Paste in filename for speed, much faster than 'type_in(filename)'
|
@@ -130,10 +129,10 @@ def file_save_as(filename, options={})
|
|
130
129
|
keystroke(VK_CONTROL, VK_V)
|
131
130
|
keystroke(VK_RETURN)
|
132
131
|
|
133
|
-
if dialog_overwrite_confirm
|
132
|
+
if dialog_overwrite_confirm
|
134
133
|
options[:overwrite] == true ? keystroke(VK_Y) : keystroke(VK_N)
|
135
134
|
end
|
136
|
-
raise "sanity check, overwrite confirm dialog is still here" if dialog_overwrite_confirm
|
135
|
+
raise "sanity check, overwrite confirm dialog is still here" if dialog_overwrite_confirm
|
137
136
|
|
138
137
|
end
|
139
138
|
|