win_gui 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +21 -21
- data/HISTORY +7 -0
- data/LICENSE +20 -20
- data/README.rdoc +77 -114
- data/Rakefile +24 -58
- data/VERSION +1 -1
- data/features/support/env.rb +7 -4
- data/features/win_gui.feature +9 -9
- data/lib/version.rb +8 -0
- data/lib/win_gui/window.rb +78 -69
- data/lib/win_gui.rb +25 -3
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +90 -118
- data/spec/win_gui/window_spec.rb +120 -123
- data/tasks/common.rake +14 -0
- data/tasks/doc.rake +14 -0
- data/tasks/gem.rake +39 -0
- data/tasks/git.rake +34 -0
- data/tasks/spec.rake +19 -0
- data/tasks/version.rake +71 -0
- metadata +68 -188
- data/.document +0 -5
- data/book_code/early_success/bundle.rb +0 -34
- data/book_code/early_success/english.txt +0 -1
- data/book_code/early_success/jruby_basics.rb +0 -47
- data/book_code/early_success/windows_basics.rb +0 -97
- data/book_code/guessing/locknote.rb +0 -379
- data/book_code/guessing/monkeyshines.rb +0 -14
- data/book_code/guessing/note.rb +0 -120
- data/book_code/guessing/note_spec.rb +0 -175
- data/book_code/guessing/replay.rb +0 -21
- data/book_code/guessing/seed.rb +0 -9
- data/book_code/guessing/spec_helper.rb +0 -69
- data/book_code/guessing/windows_gui.rb +0 -247
- data/book_code/home_stretch/junquenote.rb +0 -151
- data/book_code/home_stretch/locknote.rb +0 -180
- data/book_code/home_stretch/note.rb +0 -144
- data/book_code/home_stretch/note_spec.rb +0 -191
- data/book_code/home_stretch/spec_helper.rb +0 -55
- data/book_code/home_stretch/swing_gui.rb +0 -50
- data/book_code/home_stretch/windows_gui.rb +0 -232
- data/book_code/junquenote/exports.sh +0 -10
- data/book_code/junquenote/jruby_mac.sh +0 -10
- data/book_code/junquenote/junquenote_app.rb +0 -262
- data/book_code/novite/Rakefile +0 -10
- data/book_code/novite/app/controllers/application.rb +0 -18
- data/book_code/novite/app/controllers/guests_controller.rb +0 -28
- data/book_code/novite/app/controllers/parties_controller.rb +0 -77
- data/book_code/novite/app/helpers/application_helper.rb +0 -11
- data/book_code/novite/app/helpers/guests_helper.rb +0 -10
- data/book_code/novite/app/helpers/parties_helper.rb +0 -10
- data/book_code/novite/app/models/guest.rb +0 -11
- data/book_code/novite/app/models/party.rb +0 -32
- data/book_code/novite/app/models/party_mailer.rb +0 -19
- data/book_code/novite/app/views/layouts/application.rhtml +0 -44
- data/book_code/novite/app/views/parties/new.html.erb +0 -42
- data/book_code/novite/app/views/parties/show.html.erb +0 -43
- data/book_code/novite/app/views/party_mailer/invite.erb +0 -17
- data/book_code/novite/config/boot.rb +0 -117
- data/book_code/novite/config/database.yml +0 -19
- data/book_code/novite/config/environment.rb +0 -67
- data/book_code/novite/config/environments/development.rb +0 -29
- data/book_code/novite/config/environments/production.rb +0 -27
- data/book_code/novite/config/environments/test.rb +0 -30
- data/book_code/novite/config/initializers/inflections.rb +0 -18
- data/book_code/novite/config/initializers/mime_types.rb +0 -13
- data/book_code/novite/config/routes.rb +0 -47
- data/book_code/novite/db/migrate/001_create_parties.rb +0 -26
- data/book_code/novite/db/migrate/002_create_guests.rb +0 -23
- data/book_code/novite/db/schema.rb +0 -41
- data/book_code/novite/log/empty.txt +0 -0
- data/book_code/novite/public/.htaccess +0 -40
- data/book_code/novite/public/404.html +0 -38
- data/book_code/novite/public/422.html +0 -38
- data/book_code/novite/public/500.html +0 -38
- data/book_code/novite/public/dispatch.cgi +0 -10
- data/book_code/novite/public/dispatch.fcgi +0 -24
- data/book_code/novite/public/dispatch.rb +0 -18
- data/book_code/novite/public/favicon.ico +0 -0
- data/book_code/novite/public/images/rails.png +0 -0
- data/book_code/novite/public/index.html +0 -285
- data/book_code/novite/public/javascripts/application.js +0 -10
- data/book_code/novite/public/javascripts/controls.js +0 -971
- data/book_code/novite/public/javascripts/dragdrop.js +0 -980
- data/book_code/novite/public/javascripts/effects.js +0 -1128
- data/book_code/novite/public/javascripts/prototype.js +0 -4233
- data/book_code/novite/public/robots.txt +0 -5
- data/book_code/novite/script/about +0 -3
- data/book_code/novite/script/console +0 -3
- data/book_code/novite/script/destroy +0 -3
- data/book_code/novite/script/generate +0 -3
- data/book_code/novite/script/performance/benchmarker +0 -3
- data/book_code/novite/script/performance/profiler +0 -3
- data/book_code/novite/script/performance/request +0 -3
- data/book_code/novite/script/plugin +0 -3
- data/book_code/novite/script/process/inspector +0 -3
- data/book_code/novite/script/process/reaper +0 -3
- data/book_code/novite/script/process/spawner +0 -3
- data/book_code/novite/script/runner +0 -3
- data/book_code/novite/script/server +0 -3
- data/book_code/novite/test/test_helper.rb +0 -46
- data/book_code/one_more_thing/applescript.rb +0 -68
- data/book_code/one_more_thing/note_spec.rb +0 -50
- data/book_code/one_more_thing/spec_helper.rb +0 -17
- data/book_code/one_more_thing/textedit-pure.rb +0 -28
- data/book_code/one_more_thing/textedit.applescript +0 -26
- data/book_code/one_more_thing/textedit.rb +0 -32
- data/book_code/one_more_thing/textnote.rb +0 -87
- data/book_code/simplify/junquenote.rb +0 -48
- data/book_code/simplify/locknote.rb +0 -46
- data/book_code/simplify/note.rb +0 -35
- data/book_code/simplify/note_spec.rb +0 -28
- data/book_code/simplify/swing_gui.rb +0 -45
- data/book_code/simplify/windows_gui.rb +0 -232
- data/book_code/simplify/windows_gui_spec.rb +0 -35
- data/book_code/story/invite.story +0 -19
- data/book_code/story/journal.txt +0 -29
- data/book_code/story/novite_stories.rb +0 -156
- data/book_code/story/party.rb +0 -149
- data/book_code/story/password.rb +0 -61
- data/book_code/story/password.story +0 -26
- data/book_code/story/rsvp.story +0 -29
- data/book_code/tables/TestTime.html +0 -93
- data/book_code/tables/TestTimeSample.html +0 -63
- data/book_code/tables/calculate_time.rb +0 -39
- data/book_code/tables/calculator.rb +0 -108
- data/book_code/tables/calculator_actions.rb +0 -27
- data/book_code/tables/calculator_spec.rb +0 -47
- data/book_code/tables/fit.rb +0 -32
- data/book_code/tables/matrix.rb +0 -109
- data/book_code/tables/pseudocode.rb +0 -17
- data/book_code/tubes/book_selenium.rb +0 -67
- data/book_code/tubes/book_watir.rb +0 -60
- data/book_code/tubes/dragdrop.html +0 -81
- data/book_code/tubes/html_capture.rb +0 -33
- data/book_code/tubes/joke_list.rb +0 -67
- data/book_code/tubes/list_spec.rb +0 -41
- data/book_code/tubes/search_spec.rb +0 -32
- data/book_code/tubes/selenium_example.rb +0 -66
- data/book_code/tubes/selenium_link.rb +0 -23
- data/book_code/tubes/web_server.rb +0 -14
- data/book_code/windows/wgui.rb +0 -29
- data/book_code/windows/wobj.rb +0 -25
- data/book_code/windows/wsh.rb +0 -25
- data/book_code/with_rspec/empty_spec.rb +0 -13
- data/book_code/with_rspec/junquenote.rb +0 -60
- data/book_code/with_rspec/locknote.rb +0 -129
- data/book_code/with_rspec/note_spec.rb +0 -32
- data/book_code/with_rspec/should_examples.rb +0 -18
- data/lib/note/java/jemmy.jar +0 -0
- data/lib/note/java/jnote.rb +0 -48
- data/lib/note/java/jruby_basics.rb +0 -37
- data/lib/note/java/junquenote_app.rb +0 -262
- data/lib/note/java/note_spec.rb +0 -20
- data/lib/note/win/locknote.rb +0 -19
- data/lib/note.rb +0 -15
- data/lib/win_gui/constants.rb +0 -82
- data/lib/win_gui/def_api.rb +0 -160
- data/lib/win_gui/string_extensions.rb +0 -36
- data/lib/win_gui/win_gui.rb +0 -437
- data/old/windows_basics.rb +0 -80
- data/old/wnote.rb +0 -80
- data/old/wnote_spec.rb +0 -20
- data/spec/note/win/locknote_spec.rb +0 -7
- data/spec/test_apps/locknote/LockNote.exe +0 -0
- data/spec/win_gui/def_api_spec.rb +0 -339
- data/spec/win_gui/string_extensions_spec.rb +0 -61
- data/spec/win_gui/win_gui_spec.rb +0 -537
- data/win_gui.gemspec +0 -215
data/.gitignore
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
## MAC OS
|
|
2
|
-
.DS_Store
|
|
3
|
-
|
|
4
|
-
## TEXTMATE
|
|
5
|
-
*.tmproj
|
|
6
|
-
tmtags
|
|
7
|
-
|
|
8
|
-
## EMACS
|
|
9
|
-
*~
|
|
10
|
-
\#*
|
|
11
|
-
.\#*
|
|
12
|
-
|
|
13
|
-
## VIM
|
|
14
|
-
*.swp
|
|
15
|
-
|
|
16
|
-
## PROJECT::GENERAL
|
|
17
|
-
coverage
|
|
18
|
-
rdoc
|
|
19
|
-
pkg
|
|
20
|
-
|
|
21
|
-
## PROJECT::SPECIFIC
|
|
1
|
+
## MAC OS
|
|
2
|
+
.DS_Store
|
|
3
|
+
|
|
4
|
+
## TEXTMATE
|
|
5
|
+
*.tmproj
|
|
6
|
+
tmtags
|
|
7
|
+
|
|
8
|
+
## EMACS
|
|
9
|
+
*~
|
|
10
|
+
\#*
|
|
11
|
+
.\#*
|
|
12
|
+
|
|
13
|
+
## VIM
|
|
14
|
+
*.swp
|
|
15
|
+
|
|
16
|
+
## PROJECT::GENERAL
|
|
17
|
+
coverage
|
|
18
|
+
rdoc
|
|
19
|
+
pkg
|
|
20
|
+
|
|
21
|
+
## PROJECT::SPECIFIC
|
data/HISTORY
ADDED
data/LICENSE
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
Copyright (c)
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright (c) 2010 Arvicco
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
|
@@ -1,114 +1,77 @@
|
|
|
1
|
-
= win_gui
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
== DESCRIPTION:
|
|
6
|
-
|
|
7
|
-
WinGui is a module that provides
|
|
8
|
-
functions
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
quite easy to define new one with def_api class method that does a lot of heavy lifting for
|
|
79
|
-
you and can be customized with options and code blocks to give you reusable API wrapper method
|
|
80
|
-
with the exact behavior you need.
|
|
81
|
-
|
|
82
|
-
== DOCUMENTATION:
|
|
83
|
-
|
|
84
|
-
See WinGui and WinGui::Window for documentation
|
|
85
|
-
|
|
86
|
-
== REQUIREMENTS:
|
|
87
|
-
|
|
88
|
-
Only works with Ruby 1.9.1+ since it uses some of the most recent features (block
|
|
89
|
-
arguments given to block, etc...)
|
|
90
|
-
|
|
91
|
-
== FEATURES/PROBLEMS:
|
|
92
|
-
|
|
93
|
-
This project is quite new, so it may be not suitable for production-quality systems yet.
|
|
94
|
-
Contributors always welcome!
|
|
95
|
-
|
|
96
|
-
== INSTALL:
|
|
97
|
-
|
|
98
|
-
$ sudo gem install win_gui
|
|
99
|
-
|
|
100
|
-
== SYNOPSIS:
|
|
101
|
-
|
|
102
|
-
require 'win_gui'
|
|
103
|
-
include WinGui
|
|
104
|
-
|
|
105
|
-
More examples will follow when the code is closer to production quality...
|
|
106
|
-
|
|
107
|
-
== CREDITS:
|
|
108
|
-
|
|
109
|
-
This library started as an extension of ideas and code described in excellent book
|
|
110
|
-
"Scripted GUI Testing with Ruby" by Ian Dees.
|
|
111
|
-
|
|
112
|
-
== LICENSE:
|
|
113
|
-
|
|
114
|
-
Copyright (c) 2009 Arvicco. See LICENSE for details
|
|
1
|
+
= win_gui
|
|
2
|
+
by:: Arvicco
|
|
3
|
+
url:: http://github.com/arvicco/win_gui
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
WinGui is a module that provides higher-level abstractions/wrappers around GUI-related
|
|
8
|
+
Win32 API functions. It uses Win gem as a basis, which in turn uses FFI.
|
|
9
|
+
So (in theory) it should work for any Ruby implementation supporting FFI. In practice,
|
|
10
|
+
it's only been tested under mingw and cygwin flavors of Ruby 1.9.1.
|
|
11
|
+
|
|
12
|
+
== SUMMARY:
|
|
13
|
+
|
|
14
|
+
Win gem provides Rubyesque wrappers around Win32 API functions, but it is not enough to
|
|
15
|
+
to make Win32 API calls feel like more or less natural extension of Ruby code.
|
|
16
|
+
The reason for this, straightforward API wrappers are not object-oriented enough.
|
|
17
|
+
|
|
18
|
+
For example, here is how you deal with typical GUI-related tasks using Win:
|
|
19
|
+
|
|
20
|
+
require 'win/gui'
|
|
21
|
+
include Win::Gui::Window
|
|
22
|
+
|
|
23
|
+
window_handle = find_window('WinClass', nil)
|
|
24
|
+
title = window_text(window_handle )
|
|
25
|
+
thread, process = window_thread_process_id(window_handle)
|
|
26
|
+
puts window_handle, title, thread, process
|
|
27
|
+
|
|
28
|
+
enum_child_windows(window_handle, message) do |child_handle, message|
|
|
29
|
+
title = window_text(child_handle )
|
|
30
|
+
thread, process = window_thread_process_id(child_handle)
|
|
31
|
+
puts child_handle, title, thread, process
|
|
32
|
+
end
|
|
33
|
+
close_window(window_handle)
|
|
34
|
+
|
|
35
|
+
Ideally, there should be a thin wrapper class around window handle, and the code above should be more like this:
|
|
36
|
+
require 'win_gui'
|
|
37
|
+
include WinGui
|
|
38
|
+
|
|
39
|
+
window = Window.find(:first, :class => 'WinClass')
|
|
40
|
+
puts window.handle, window.title, window.thread, window.process
|
|
41
|
+
window.each_child {|child| puts child.handle, child.title, child.thread, child.process }
|
|
42
|
+
window.close
|
|
43
|
+
|
|
44
|
+
This library will try to provide such wrappers and convenience methods that will make working with
|
|
45
|
+
Windows GUI-related code much more fun than it is right now.
|
|
46
|
+
|
|
47
|
+
== REQUIREMENTS:
|
|
48
|
+
|
|
49
|
+
Only works with Ruby 1.9.1+ compatible implementations since Win gem uses some of latest Ruby features.
|
|
50
|
+
|
|
51
|
+
== FEATURES/PROBLEMS:
|
|
52
|
+
|
|
53
|
+
This project is quite new, so it may be not suitable for production-quality systems yet.
|
|
54
|
+
Contributors always welcome!
|
|
55
|
+
|
|
56
|
+
== INSTALL:
|
|
57
|
+
|
|
58
|
+
$ sudo gem install win_gui
|
|
59
|
+
|
|
60
|
+
== SYNOPSIS:
|
|
61
|
+
|
|
62
|
+
require 'win_gui'
|
|
63
|
+
include WinGui
|
|
64
|
+
|
|
65
|
+
More examples will follow when the code is closer to production quality...
|
|
66
|
+
|
|
67
|
+
== CREDITS/PRIOR ART:
|
|
68
|
+
|
|
69
|
+
This library started as an extension of ideas and code described in excellent book
|
|
70
|
+
"Scripted GUI Testing with Ruby" by Ian Dees.
|
|
71
|
+
|
|
72
|
+
Win32::GuiTest by MoonWolf is a port of eponimous Perl library to Ruby
|
|
73
|
+
(http://raa.ruby-lang.org/project/win32-guitest). I do not like its Perlisms though.
|
|
74
|
+
|
|
75
|
+
== LICENSE:
|
|
76
|
+
|
|
77
|
+
Copyright (c) 2010 Arvicco. See LICENSE for details
|
data/Rakefile
CHANGED
|
@@ -1,58 +1,24 @@
|
|
|
1
|
-
require '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
spec.libs << 'lib' << 'spec'
|
|
26
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
|
30
|
-
spec.libs << 'lib' << 'spec'
|
|
31
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
|
32
|
-
spec.rcov = true
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
task :spec => :check_dependencies
|
|
36
|
-
|
|
37
|
-
begin
|
|
38
|
-
require 'cucumber/rake/task'
|
|
39
|
-
Cucumber::Rake::Task.new(:features)
|
|
40
|
-
|
|
41
|
-
task :features => :check_dependencies
|
|
42
|
-
rescue LoadError
|
|
43
|
-
task :features do
|
|
44
|
-
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
task :default => :spec
|
|
49
|
-
|
|
50
|
-
require 'rake/rdoctask'
|
|
51
|
-
Rake::RDocTask.new do |rdoc|
|
|
52
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
53
|
-
|
|
54
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
55
|
-
rdoc.title = "win_gui #{version}"
|
|
56
|
-
rdoc.rdoc_files.include('README*')
|
|
57
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
58
|
-
end
|
|
1
|
+
require 'pathname'
|
|
2
|
+
NAME = 'win_gui'
|
|
3
|
+
BASE_PATH = Pathname.new(__FILE__).dirname
|
|
4
|
+
LIB_PATH = BASE_PATH + 'lib'
|
|
5
|
+
PKG_PATH = BASE_PATH + 'pkg'
|
|
6
|
+
DOC_PATH = BASE_PATH + 'rdoc'
|
|
7
|
+
|
|
8
|
+
$LOAD_PATH.unshift LIB_PATH.to_s
|
|
9
|
+
require 'version'
|
|
10
|
+
|
|
11
|
+
CLASS_NAME = WinGui
|
|
12
|
+
VERSION = CLASS_NAME::VERSION
|
|
13
|
+
|
|
14
|
+
begin
|
|
15
|
+
require 'rake'
|
|
16
|
+
rescue LoadError
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
gem 'rake', '~> 0.8.3.1'
|
|
19
|
+
require 'rake'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Load rakefile tasks
|
|
23
|
+
Dir['tasks/*.rake'].sort.each { |file| load file }
|
|
24
|
+
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/features/support/env.rb
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
|
2
|
-
require 'win_gui'
|
|
3
|
-
|
|
4
|
-
require 'spec/
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
|
2
|
+
require 'win_gui'
|
|
3
|
+
require 'spec/expectations'
|
|
4
|
+
require 'spec/stubs/cucumber'
|
|
5
|
+
|
|
6
|
+
require 'pathname'
|
|
7
|
+
BASE_PATH = Pathname.new(__FILE__).dirname + '../..'
|
data/features/win_gui.feature
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Feature: something something
|
|
2
|
-
In order to something something
|
|
3
|
-
A user something something
|
|
4
|
-
something something something
|
|
5
|
-
|
|
6
|
-
Scenario: something something
|
|
7
|
-
Given inspiration
|
|
8
|
-
When I create a sweet new gem
|
|
9
|
-
Then everyone should see how awesome I am
|
|
1
|
+
Feature: something something
|
|
2
|
+
In order to something something
|
|
3
|
+
A user something something
|
|
4
|
+
something something something
|
|
5
|
+
|
|
6
|
+
Scenario: something something
|
|
7
|
+
Given inspiration
|
|
8
|
+
When I create a sweet new gem
|
|
9
|
+
Then everyone should see how awesome I am
|
data/lib/version.rb
ADDED
data/lib/win_gui/window.rb
CHANGED
|
@@ -1,70 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
require 'win/gui'
|
|
2
|
+
|
|
3
|
+
module WinGui
|
|
4
|
+
# Delay between key commands (events)
|
|
5
|
+
WG_KEY_DELAY = 0.00001
|
|
6
|
+
# Wait delay quant
|
|
7
|
+
WG_SLEEP_DELAY = 0.001
|
|
8
|
+
# Timeout waiting for Window to be closed
|
|
9
|
+
WG_CLOSE_TIMEOUT = 1
|
|
10
|
+
|
|
11
|
+
class Window
|
|
12
|
+
include Win::Gui
|
|
13
|
+
extend Win::Gui
|
|
14
|
+
|
|
15
|
+
def initialize(handle)
|
|
16
|
+
@handle = handle
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attr_reader :handle
|
|
20
|
+
|
|
21
|
+
# find top level window by title, return wrapped Window object
|
|
22
|
+
def self.top_level(title, seconds=3)
|
|
23
|
+
@handle = timeout(seconds) do
|
|
24
|
+
sleep WG_SLEEP_DELAY while (h = find_window nil, title) == nil; h
|
|
25
|
+
end
|
|
26
|
+
Window.new @handle
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# find child window (control) by title, window class, or control ID:
|
|
30
|
+
def child(id)
|
|
31
|
+
result = case id
|
|
32
|
+
when String
|
|
33
|
+
by_title = find_window_ex @handle, 0, nil, id.gsub('_' , '&' )
|
|
34
|
+
by_class = find_window_ex @handle, 0, id, nil
|
|
35
|
+
by_title ? by_title : by_class
|
|
36
|
+
when Fixnum
|
|
37
|
+
get_dlg_item @handle, id
|
|
38
|
+
when nil
|
|
39
|
+
find_window_ex @handle, 0, nil, nil
|
|
40
|
+
else
|
|
41
|
+
nil
|
|
42
|
+
end
|
|
43
|
+
raise "Control '#{id}' not found" unless result
|
|
44
|
+
Window.new result
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def children
|
|
48
|
+
enum_child_windows(@handle).map{|child_handle| Window.new child_handle}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# emulate click of the control identified by id
|
|
52
|
+
def click(id)
|
|
53
|
+
h = child(id).handle
|
|
54
|
+
rectangle = [0, 0, 0, 0].pack 'LLLL'
|
|
55
|
+
get_window_rect h, rectangle
|
|
56
|
+
left, top, right, bottom = rectangle.unpack 'LLLL'
|
|
57
|
+
center = [(left + right) / 2, (top + bottom) / 2]
|
|
58
|
+
set_cursor_pos *center
|
|
59
|
+
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
|
|
60
|
+
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def close
|
|
64
|
+
post_message @handle, WM_SYSCOMMAND, SC_CLOSE, nil
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def wait_for_close
|
|
68
|
+
timeout(WG_CLOSE_TIMEOUT) do
|
|
69
|
+
sleep WG_SLEEP_DELAY while window_visible?(@handle)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def text
|
|
74
|
+
buffer = "\x0" * 2048
|
|
75
|
+
length = send_message @handle, WM_GETTEXT, buffer.length, buffer
|
|
76
|
+
length == 0 ? '' : buffer[0..length - 1]
|
|
77
|
+
end
|
|
78
|
+
end
|
|
70
79
|
end
|
data/lib/win_gui.rb
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require 'version'
|
|
2
|
+
|
|
3
|
+
module WinGui
|
|
4
|
+
|
|
5
|
+
# require "bundler"
|
|
6
|
+
# Bundler.setup
|
|
7
|
+
|
|
8
|
+
# Requires ruby source file(s). Accepts either single filename/glob or Array of filenames/globs.
|
|
9
|
+
# Accepts following options:
|
|
10
|
+
# :*file*:: Lib(s) required relative to this file - defaults to __FILE__
|
|
11
|
+
# :*dir*:: Required lib(s) located under this dir name - defaults to gem name
|
|
12
|
+
#
|
|
13
|
+
def self.require_libs( libs, opts={} )
|
|
14
|
+
file = Pathname.new(opts[:file] || __FILE__)
|
|
15
|
+
[libs].flatten.each do |lib|
|
|
16
|
+
name = file.dirname + (opts[:dir] || file.basename('.*')) + lib.gsub(/(?<!.rb)$/, '.rb')
|
|
17
|
+
Pathname.glob(name.to_s).sort.each {|rb| require rb}
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end # module WinGui
|
|
21
|
+
|
|
22
|
+
# Require all ruby source files located under directory lib/win_gui
|
|
23
|
+
# If you need files in specific order, you should specify it here before the glob
|
|
24
|
+
WinGui.require_libs %W[**/*]
|
|
25
|
+
|
data/spec/spec.opts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
--color
|
|
1
|
+
--color
|
|
2
2
|
--format nested
|