win32screenshot 1.0.5 → 1.0.6
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 +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +34 -0
- data/History.rdoc +5 -0
- data/README.rdoc +3 -0
- data/Rakefile +4 -30
- data/lib/win32/screenshot/bitmap_maker.rb +19 -12
- data/lib/win32/screenshot/take.rb +16 -12
- data/lib/win32/screenshot/version.rb +5 -0
- data/lib/win32/screenshot.rb +1 -0
- data/spec/win32/screenshot/take_spec.rb +40 -26
- data/win32screenshot.gemspec +18 -83
- metadata +42 -26
- data/.document +0 -5
- data/VERSION +0 -1
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
win32screenshot (1.0.6)
|
5
|
+
ffi (~> 1.0)
|
6
|
+
mini_magick (~> 3.2.1)
|
7
|
+
rake (= 0.8.7)
|
8
|
+
rautomation (~> 0.6.3)
|
9
|
+
rspec (~> 2.5)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: http://rubygems.org/
|
13
|
+
specs:
|
14
|
+
diff-lcs (1.1.3)
|
15
|
+
ffi (1.0.9-x86-mingw32)
|
16
|
+
mini_magick (3.2.1)
|
17
|
+
subexec (~> 0.0.4)
|
18
|
+
rake (0.8.7)
|
19
|
+
rautomation (0.6.3)
|
20
|
+
rspec (2.6.0)
|
21
|
+
rspec-core (~> 2.6.0)
|
22
|
+
rspec-expectations (~> 2.6.0)
|
23
|
+
rspec-mocks (~> 2.6.0)
|
24
|
+
rspec-core (2.6.4)
|
25
|
+
rspec-expectations (2.6.0)
|
26
|
+
diff-lcs (~> 1.1.2)
|
27
|
+
rspec-mocks (2.6.0)
|
28
|
+
subexec (0.0.4)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
x86-mingw32
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
win32screenshot!
|
data/History.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 1.0.6 2011-10-16
|
2
|
+
* Screenshot will be taken of the whole window instead of client area - e.g. with title bar and such.
|
3
|
+
* Added :context option to specify which area to take screenshot of - possible values are :window or :client
|
4
|
+
Win32::Screenshot::Take.of(:window, :hwnd => 1234, :context => :client)
|
5
|
+
|
1
6
|
= 1.0.5 2011-08-18
|
2
7
|
* Minor output message change
|
3
8
|
|
data/README.rdoc
CHANGED
@@ -26,6 +26,9 @@ Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats!
|
|
26
26
|
# Take a screenshot of the window with the specified handle
|
27
27
|
Win32::Screenshot::Take.of(:window, :hwnd => 123456).write("image.gif")
|
28
28
|
|
29
|
+
# Take a screenshot of the window's client area (e.g. without title bar) with the specified handle
|
30
|
+
Win32::Screenshot::Take.of(:window, :hwnd => 123456, :context => :client)
|
31
|
+
|
29
32
|
# Take a screenshot of the child window with the specified internal class name
|
30
33
|
Win32::Screenshot::Take.of(:rautomation, RAutomation::Window.new(:hwnd => 123456).
|
31
34
|
child(:class => "Internet Explorer_Server")).write("image.png")
|
data/Rakefile
CHANGED
@@ -1,30 +1,6 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
require 'rubygems'
|
4
|
-
require '
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'jeweler'
|
8
|
-
Jeweler::Tasks.new do |gem|
|
9
|
-
gem.name = "win32screenshot"
|
10
|
-
gem.summary = %Q{Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats!}
|
11
|
-
gem.description = %Q{Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats!}
|
12
|
-
gem.email = ["jarmo.p@gmail.com", "aslak.hellesoy@gmail.com"]
|
13
|
-
gem.homepage = "http://github.com/jarmo/win32screenshot"
|
14
|
-
gem.authors = ["Jarmo Pertman", "Aslak Hellesøy"]
|
15
|
-
|
16
|
-
gem.rdoc_options = ["--main", "README.rdoc"]
|
17
|
-
|
18
|
-
gem.add_dependency "ffi", "~>1.0"
|
19
|
-
gem.add_dependency "mini_magick", "~>3.2.0"
|
20
|
-
gem.add_dependency "rautomation", "~>0.6.3"
|
21
|
-
|
22
|
-
gem.add_development_dependency "rspec", "~>2.5"
|
23
|
-
end
|
24
|
-
Jeweler::GemcutterTasks.new
|
25
|
-
rescue LoadError
|
26
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
27
|
-
end
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
28
4
|
|
29
5
|
require 'rspec/core/rake_task'
|
30
6
|
RSpec::Core::RakeTask.new(:spec)
|
@@ -33,14 +9,12 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
33
9
|
spec.rcov = true
|
34
10
|
end
|
35
11
|
|
36
|
-
task :spec => :check_dependencies
|
37
|
-
|
38
12
|
task :default => :spec
|
39
13
|
|
40
14
|
require 'yard'
|
41
15
|
YARD::Rake::YardocTask.new
|
42
16
|
|
43
17
|
desc "Remove all temporary files"
|
44
|
-
task :clobber
|
45
|
-
rm_r "spec/tmp"
|
18
|
+
task :clobber do
|
19
|
+
rm_r ["spec/tmp", "doc", ".yardoc", "coverage"]
|
46
20
|
end
|
@@ -10,7 +10,9 @@ module Win32
|
|
10
10
|
ffi_convention :stdcall
|
11
11
|
|
12
12
|
# user32.dll
|
13
|
-
attach_function :
|
13
|
+
attach_function :window_dc, :GetWindowDC,
|
14
|
+
[:long], :long
|
15
|
+
attach_function :client_dc, :GetDC,
|
14
16
|
[:long], :long
|
15
17
|
attach_function :client_rect, :GetClientRect,
|
16
18
|
[:long, :pointer], :bool
|
@@ -39,16 +41,16 @@ module Win32
|
|
39
41
|
attach_function :release_dc, :ReleaseDC,
|
40
42
|
[:long, :long], :int
|
41
43
|
|
42
|
-
def capture_all(hwnd)
|
43
|
-
width, height = dimensions_for(hwnd)
|
44
|
-
capture_area(hwnd, 0, 0, width, height)
|
44
|
+
def capture_all(hwnd, context)
|
45
|
+
width, height = dimensions_for(hwnd, context)
|
46
|
+
capture_area(hwnd, context, 0, 0, width, height)
|
45
47
|
end
|
46
48
|
|
47
49
|
SRCCOPY = 0x00CC0020
|
48
50
|
DIB_RGB_COLORS = 0
|
49
51
|
|
50
|
-
def capture_area(hwnd, x1, y1, x2, y2)
|
51
|
-
hScreenDC =
|
52
|
+
def capture_area(hwnd, context, x1, y1, x2, y2)
|
53
|
+
hScreenDC = send("#{context}_dc", hwnd)
|
52
54
|
w = x2-x1
|
53
55
|
h = y2-y1
|
54
56
|
|
@@ -80,14 +82,19 @@ module Win32
|
|
80
82
|
release_dc(0, hScreenDC)
|
81
83
|
end
|
82
84
|
|
83
|
-
def dimensions_for(hwnd)
|
84
|
-
rect = [0, 0, 0, 0].pack('
|
85
|
-
BitmapMaker.
|
86
|
-
|
87
|
-
|
85
|
+
def dimensions_for(hwnd, context)
|
86
|
+
rect = [0, 0, 0, 0].pack('l4')
|
87
|
+
BitmapMaker.send("#{context}_rect", hwnd.to_i, rect)
|
88
|
+
left, top, width, height = rect.unpack('l4')
|
89
|
+
|
90
|
+
if context == :window
|
91
|
+
[width + 1 - left, height + 1 - top]
|
92
|
+
else
|
93
|
+
[width, height]
|
94
|
+
end
|
88
95
|
end
|
89
96
|
|
90
97
|
end
|
91
98
|
end
|
92
99
|
end
|
93
|
-
end
|
100
|
+
end
|
@@ -18,17 +18,20 @@ module Win32
|
|
18
18
|
# @example Take a screenshot of the window with the specified handle
|
19
19
|
# Win32::Screenshot::Take.of(:window, :hwnd => 123456)
|
20
20
|
#
|
21
|
+
# @example Take a screenshot of the window's client area (e.g. without title bar) with the specified handle
|
22
|
+
# Win32::Screenshot::Take.of(:window, :hwnd => 123456, :context => :client)
|
23
|
+
#
|
21
24
|
# @example Take a screenshot of the child window with the specified internal class name
|
22
25
|
# Win32::Screenshot::Take.of(:rautomation, RAutomation::Window.new(:hwnd => 123456).child(:class => "Internet Explorer_Server"))
|
23
26
|
#
|
24
27
|
# @param [Symbol] what the type of the object to take a screenshot of,
|
25
28
|
# possible values are _:foreground_, _:desktop_ and _:window_.
|
26
|
-
# @param [Hash] opts options
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# to other options a 0-based _:index_ option to search for other windows if multiple
|
29
|
+
# @param [Hash] opts options are optional for specifying an _:area_ and/or _:context_ to take a screenshot.
|
30
|
+
# It is possible to specify as many options as are needed for searching for the unique window.
|
31
|
+
# By default the first window with matching identifiers will be taken screenshot of.
|
32
|
+
# It is possible to use in addition to other options a 0-based _:index_ option to search for other windows if multiple
|
31
33
|
# windows match the specified criteria.
|
34
|
+
# @option opts [String, Symbol] :context Context to take a screenshot of. Can be _:window_ or _:client_. Defaults to _:window_
|
32
35
|
# @option opts [String, Regexp] :title Title of the window
|
33
36
|
# @option opts [String, Regexp] :text Visible text of the window
|
34
37
|
# @option opts [String, Regexp] :class Internal class name of the window
|
@@ -43,7 +46,7 @@ module Win32
|
|
43
46
|
valid_whats = [:foreground, :desktop, :window]
|
44
47
|
raise "It is not possible to take a screenshot of '#{what}', possible values are #{valid_whats.join(", ")}" unless valid_whats.include?(what)
|
45
48
|
|
46
|
-
self.send(what, opts)
|
49
|
+
self.send(what, {:context => :window}.merge(opts))
|
47
50
|
end
|
48
51
|
|
49
52
|
alias_method :new, :of
|
@@ -62,6 +65,7 @@ module Win32
|
|
62
65
|
|
63
66
|
def window(opts)
|
64
67
|
area = {:area => opts.delete(:area)}
|
68
|
+
context = {:context => opts.delete(:context)}
|
65
69
|
win = opts[:rautomation] || RAutomation::Window.new(opts)
|
66
70
|
timeout = Time.now + 10
|
67
71
|
until win.active?
|
@@ -71,19 +75,19 @@ module Win32
|
|
71
75
|
end
|
72
76
|
win.activate
|
73
77
|
end
|
74
|
-
take_screenshot(win.hwnd, opts.merge(area || {}))
|
78
|
+
take_screenshot(win.hwnd, opts.merge(context).merge(area || {}))
|
75
79
|
end
|
76
80
|
|
77
81
|
def take_screenshot(hwnd, opts)
|
78
82
|
if opts[:area]
|
79
|
-
validate_coordinates(hwnd, *opts[:area])
|
80
|
-
BitmapMaker.capture_area(hwnd, *opts[:area])
|
83
|
+
validate_coordinates(hwnd, opts[:context], *opts[:area])
|
84
|
+
BitmapMaker.capture_area(hwnd, opts[:context], *opts[:area])
|
81
85
|
else
|
82
|
-
BitmapMaker.capture_all(hwnd)
|
86
|
+
BitmapMaker.capture_all(hwnd, opts[:context])
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
86
|
-
def validate_coordinates(hwnd, x1, y1, x2, y2)
|
90
|
+
def validate_coordinates(hwnd, context, x1, y1, x2, y2)
|
87
91
|
specified_coordinates = "x1: #{x1}, y1: #{y1}, x2: #{x2}, y2: #{y2}"
|
88
92
|
if [x1, y1, x2, y2].any? {|c| c < 0}
|
89
93
|
raise "specified coordinates (#{specified_coordinates}) are invalid - cannot be negative!"
|
@@ -93,7 +97,7 @@ module Win32
|
|
93
97
|
raise "specified coordinates (#{specified_coordinates}) are invalid - cannot be x1 >= x2 or y1 >= y2!"
|
94
98
|
end
|
95
99
|
|
96
|
-
max_width, max_height = BitmapMaker.dimensions_for(hwnd)
|
100
|
+
max_width, max_height = BitmapMaker.dimensions_for(hwnd, context)
|
97
101
|
if x2 > max_width || y2 > max_height
|
98
102
|
raise "specified coordinates (#{specified_coordinates}) are invalid - maximum x2: #{max_width} and y2: #{max_height}!"
|
99
103
|
end
|
data/lib/win32/screenshot.rb
CHANGED
@@ -3,6 +3,7 @@ require 'mini_magick'
|
|
3
3
|
ENV["RAUTOMATION_ADAPTER"] = "win_ffi" # make sure that WinFfi adapter is always used for RAutomation
|
4
4
|
require 'rautomation'
|
5
5
|
|
6
|
+
require File.dirname(__FILE__) + '/screenshot/version'
|
6
7
|
require File.dirname(__FILE__) + '/screenshot/take'
|
7
8
|
require File.dirname(__FILE__) + '/screenshot/image'
|
8
9
|
require File.dirname(__FILE__) + '/screenshot/bitmap_maker'
|
@@ -9,61 +9,61 @@ describe Win32::Screenshot::Take do
|
|
9
9
|
@calc = RAutomation::Window.new(:title => /calculator/i).pid
|
10
10
|
end
|
11
11
|
|
12
|
-
it "captures foreground" do
|
12
|
+
it "captures the foreground" do
|
13
13
|
image = Win32::Screenshot::Take.of(:foreground)
|
14
14
|
save_and_verify_image(image, 'foreground')
|
15
15
|
hwnd = Win32::Screenshot::BitmapMaker.foreground_window
|
16
|
-
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(hwnd)
|
16
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(hwnd, :window)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "captures area of the foreground" do
|
19
|
+
it "captures an area of the foreground" do
|
20
20
|
image = Win32::Screenshot::Take.of(:foreground, :area => [30, 30, 100, 150])
|
21
21
|
save_and_verify_image(image, 'foreground_area')
|
22
22
|
image.width.should == 70
|
23
23
|
image.height.should == 120
|
24
24
|
end
|
25
25
|
|
26
|
-
it "doesn't allow to capture area of the foreground with invalid coordinates" do
|
26
|
+
it "doesn't allow to capture an area of the foreground with invalid coordinates" do
|
27
27
|
expect {Win32::Screenshot::Take.of(:foreground, :area => [0, 0, -1, 100])}.
|
28
28
|
to raise_exception("specified coordinates (x1: 0, y1: 0, x2: -1, y2: 100) are invalid - cannot be negative!")
|
29
29
|
end
|
30
30
|
|
31
|
-
it "captures desktop" do
|
31
|
+
it "captures the desktop" do
|
32
32
|
image = Win32::Screenshot::Take.of(:desktop)
|
33
33
|
save_and_verify_image(image, 'desktop')
|
34
34
|
hwnd = Win32::Screenshot::BitmapMaker.desktop_window
|
35
|
-
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(hwnd)
|
35
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(hwnd, :window)
|
36
36
|
end
|
37
37
|
|
38
|
-
it "captures area of the desktop" do
|
38
|
+
it "captures an area of the desktop" do
|
39
39
|
image = Win32::Screenshot::Take.of(:desktop, :area => [30, 30, 100, 150])
|
40
40
|
save_and_verify_image(image, 'desktop_area')
|
41
41
|
image.width.should == 70
|
42
42
|
image.height.should == 120
|
43
43
|
end
|
44
44
|
|
45
|
-
it "doesn't allow to capture area of the desktop with invalid coordinates" do
|
45
|
+
it "doesn't allow to capture an area of the desktop with invalid coordinates" do
|
46
46
|
expect {Win32::Screenshot::Take.of(:desktop, :area => [0, 0, -1, 100])}.
|
47
47
|
to raise_exception("specified coordinates (x1: 0, y1: 0, x2: -1, y2: 100) are invalid - cannot be negative!")
|
48
48
|
end
|
49
49
|
|
50
|
-
it "captures maximized window" do
|
50
|
+
it "captures a maximized window" do
|
51
51
|
window = RAutomation::Window.new(:pid => @iexplore)
|
52
52
|
window.maximize
|
53
53
|
image = Win32::Screenshot::Take.of(:window, :pid => @iexplore)
|
54
54
|
save_and_verify_image(image, 'iexplore_max')
|
55
|
-
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd)
|
55
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
56
56
|
end
|
57
57
|
|
58
|
-
it "captures minimized window" do
|
58
|
+
it "captures a minimized window" do
|
59
59
|
window = RAutomation::Window.new(:pid => @calc)
|
60
60
|
window.minimize
|
61
61
|
image = Win32::Screenshot::Take.of(:window, :pid => @calc)
|
62
62
|
save_and_verify_image(image, 'calc_min')
|
63
|
-
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd)
|
63
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
64
64
|
end
|
65
65
|
|
66
|
-
it "captures small window" do
|
66
|
+
it "captures a small window" do
|
67
67
|
title = /Internet Explorer/
|
68
68
|
resize(title)
|
69
69
|
image = Win32::Screenshot::Take.of(:window, :pid => @iexplore)
|
@@ -73,57 +73,71 @@ describe Win32::Screenshot::Take do
|
|
73
73
|
# screenshot doesn't include titlebar and the size
|
74
74
|
# varies between different themes and Windows versions
|
75
75
|
window = RAutomation::Window.new(:pid => @iexplore)
|
76
|
-
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd)
|
76
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
77
77
|
end
|
78
78
|
|
79
|
-
it "captures
|
79
|
+
it "captures a window context of the window" do
|
80
|
+
image = Win32::Screenshot::Take.of(:window, :pid => @calc, :context => :window)
|
81
|
+
save_and_verify_image(image, 'calc_context_window')
|
82
|
+
window = RAutomation::Window.new(:pid => @calc)
|
83
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "captures a client context of the window" do
|
87
|
+
image = Win32::Screenshot::Take.of(:window, :pid => @calc, :context => :client)
|
88
|
+
save_and_verify_image(image, 'calc_context_client')
|
89
|
+
window = RAutomation::Window.new(:pid => @calc)
|
90
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :client)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "captures an area of the window" do
|
80
94
|
image = Win32::Screenshot::Take.of(:window, :pid => @calc, :area => [30, 30, 100, 150])
|
81
95
|
save_and_verify_image(image, 'calc_area')
|
82
96
|
image.width.should == 70
|
83
97
|
image.height.should == 120
|
84
98
|
end
|
85
99
|
|
86
|
-
it "captures by RAutomation::Window" do
|
100
|
+
it "captures by the RAutomation::Window" do
|
87
101
|
window = RAutomation::Window.new(:pid => @calc)
|
88
102
|
image = Win32::Screenshot::Take.of(:window, :rautomation => window)
|
89
103
|
save_and_verify_image(image, 'calc_rautomation')
|
90
|
-
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd)
|
104
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
91
105
|
end
|
92
106
|
|
93
|
-
it "captures child windows" do
|
107
|
+
it "captures a child windows" do
|
94
108
|
window = RAutomation::Window.new(:pid => @iexplore).child(:class => "Internet Explorer_Server")
|
95
109
|
image = Win32::Screenshot::Take.of(:window, :rautomation => window)
|
96
110
|
save_and_verify_image(image, 'iexplore_child')
|
97
|
-
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd)
|
111
|
+
[image.width, image.height].should == Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
98
112
|
end
|
99
113
|
|
100
|
-
it "captures whole window if window size is specified as coordinates" do
|
114
|
+
it "captures a whole window if window size is specified as coordinates" do
|
101
115
|
window = RAutomation::Window.new(:pid => @calc)
|
102
|
-
expected_width, expected_height = Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd)
|
116
|
+
expected_width, expected_height = Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
103
117
|
image = Win32::Screenshot::Take.of(:window, :rautomation => window, :area => [0, 0, expected_width, expected_height])
|
104
118
|
save_and_verify_image(image, 'calc_area_full_window')
|
105
119
|
image.width.should == expected_width
|
106
120
|
image.height.should == expected_height
|
107
121
|
end
|
108
122
|
|
109
|
-
it "doesn't allow to capture area of the window with negative coordinates" do
|
123
|
+
it "doesn't allow to capture an area of the window with negative coordinates" do
|
110
124
|
expect {Win32::Screenshot::Take.of(:window, :pid => @calc, :area => [0, 0, -1, 100])}.
|
111
125
|
to raise_exception("specified coordinates (x1: 0, y1: 0, x2: -1, y2: 100) are invalid - cannot be negative!")
|
112
126
|
end
|
113
127
|
|
114
|
-
it "doesn't allow to capture area of the window if coordinates are the same" do
|
128
|
+
it "doesn't allow to capture an area of the window if coordinates are the same" do
|
115
129
|
expect {Win32::Screenshot::Take.of(:window, :pid => @calc, :area => [10, 0, 10, 20])}.
|
116
130
|
to raise_exception("specified coordinates (x1: 10, y1: 0, x2: 10, y2: 20) are invalid - cannot be x1 >= x2 or y1 >= y2!")
|
117
131
|
end
|
118
132
|
|
119
|
-
it "doesn't allow to capture area of the window if second coordinate is smaller than first one" do
|
133
|
+
it "doesn't allow to capture an area of the window if second coordinate is smaller than first one" do
|
120
134
|
expect {Win32::Screenshot::Take.of(:window, :pid => @calc, :area => [0, 10, 10, 9])}.
|
121
135
|
to raise_exception("specified coordinates (x1: 0, y1: 10, x2: 10, y2: 9) are invalid - cannot be x1 >= x2 or y1 >= y2!")
|
122
136
|
end
|
123
137
|
|
124
|
-
it "doesn't allow to capture area of the window with too big coordinates" do
|
138
|
+
it "doesn't allow to capture an area of the window with too big coordinates" do
|
125
139
|
window = RAutomation::Window.new(:pid => @calc)
|
126
|
-
expected_width, expected_height = Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd)
|
140
|
+
expected_width, expected_height = Win32::Screenshot::BitmapMaker.dimensions_for(window.hwnd, :window)
|
127
141
|
expect {Win32::Screenshot::Take.of(:window, :pid => @calc, :area => [0, 0, 10, 1000])}.
|
128
142
|
to raise_exception("specified coordinates (x1: 0, y1: 0, x2: 10, y2: 1000) are invalid - maximum x2: #{expected_width} and y2: #{expected_height}!")
|
129
143
|
end
|
data/win32screenshot.gemspec
CHANGED
@@ -1,87 +1,22 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "win32/screenshot/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version =
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
s.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
"History.rdoc",
|
24
|
-
"LICENSE",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"ext/CORE_RL_bzlib_.dll",
|
29
|
-
"ext/CORE_RL_jpeg_.dll",
|
30
|
-
"ext/CORE_RL_lcms_.dll",
|
31
|
-
"ext/CORE_RL_magick_.dll",
|
32
|
-
"ext/CORE_RL_png_.dll",
|
33
|
-
"ext/CORE_RL_ttf_.dll",
|
34
|
-
"ext/CORE_RL_wand_.dll",
|
35
|
-
"ext/CORE_RL_zlib_.dll",
|
36
|
-
"ext/ImageMagick-License.txt",
|
37
|
-
"ext/X11.dll",
|
38
|
-
"ext/identify.exe",
|
39
|
-
"ext/modules/coders/IM_MOD_RL_bmp_.dll",
|
40
|
-
"ext/modules/coders/IM_MOD_RL_gif_.dll",
|
41
|
-
"ext/modules/coders/IM_MOD_RL_jpeg_.dll",
|
42
|
-
"ext/modules/coders/IM_MOD_RL_png_.dll",
|
43
|
-
"ext/mogrify.exe",
|
44
|
-
"ext/msvcr100.dll",
|
45
|
-
"ext/vcomp100.dll",
|
46
|
-
"lib/win32/screenshot.rb",
|
47
|
-
"lib/win32/screenshot/bitmap_maker.rb",
|
48
|
-
"lib/win32/screenshot/image.rb",
|
49
|
-
"lib/win32/screenshot/take.rb",
|
50
|
-
"spec/spec_helper.rb",
|
51
|
-
"spec/win32/screenshot/image_spec.rb",
|
52
|
-
"spec/win32/screenshot/take_spec.rb",
|
53
|
-
"win32screenshot.gemspec"
|
54
|
-
]
|
55
|
-
s.homepage = %q{http://github.com/jarmo/win32screenshot}
|
56
|
-
s.rdoc_options = [%q{--main}, %q{README.rdoc}]
|
57
|
-
s.require_paths = [%q{lib}]
|
58
|
-
s.rubygems_version = %q{1.8.4}
|
59
|
-
s.summary = %q{Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats!}
|
60
|
-
s.test_files = [
|
61
|
-
"spec/spec_helper.rb",
|
62
|
-
"spec/win32/screenshot/image_spec.rb",
|
63
|
-
"spec/win32/screenshot/take_spec.rb"
|
64
|
-
]
|
65
|
-
|
66
|
-
if s.respond_to? :specification_version then
|
67
|
-
s.specification_version = 3
|
68
|
-
|
69
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
70
|
-
s.add_runtime_dependency(%q<ffi>, ["~> 1.0"])
|
71
|
-
s.add_runtime_dependency(%q<mini_magick>, ["~> 3.2.0"])
|
72
|
-
s.add_runtime_dependency(%q<rautomation>, ["~> 0.6.3"])
|
73
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.5"])
|
74
|
-
else
|
75
|
-
s.add_dependency(%q<ffi>, ["~> 1.0"])
|
76
|
-
s.add_dependency(%q<mini_magick>, ["~> 3.2.0"])
|
77
|
-
s.add_dependency(%q<rautomation>, ["~> 0.6.3"])
|
78
|
-
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
79
|
-
end
|
80
|
-
else
|
81
|
-
s.add_dependency(%q<ffi>, ["~> 1.0"])
|
82
|
-
s.add_dependency(%q<mini_magick>, ["~> 3.2.0"])
|
83
|
-
s.add_dependency(%q<rautomation>, ["~> 0.6.3"])
|
84
|
-
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
85
|
-
end
|
6
|
+
s.name = "win32screenshot"
|
7
|
+
s.version = Win32::Screenshot::VERSION
|
8
|
+
s.authors = ["Jarmo Pertman", "Aslak Hellesøy"]
|
9
|
+
s.email = ["jarmo.p@gmail.com", "aslak.hellesoy@gmail.com"]
|
10
|
+
s.description = "Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats."
|
11
|
+
s.homepage = "http://github.com/jarmo/win32screenshot"
|
12
|
+
s.summary = "Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats."
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
|
17
|
+
s.add_dependency("rake", "0.8.7")
|
18
|
+
s.add_dependency("ffi", "~> 1.0")
|
19
|
+
s.add_dependency("mini_magick", "~> 3.2.1")
|
20
|
+
s.add_dependency("rautomation", "~> 0.6.3")
|
21
|
+
s.add_dependency("rspec", "~> 2.5")
|
86
22
|
end
|
87
|
-
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32screenshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jarmo Pertman
|
@@ -16,12 +16,28 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-10-18 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: rake
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - "="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 49
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 8
|
33
|
+
- 7
|
34
|
+
version: 0.8.7
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: ffi
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
26
42
|
requirements:
|
27
43
|
- - ~>
|
@@ -32,27 +48,27 @@ dependencies:
|
|
32
48
|
- 0
|
33
49
|
version: "1.0"
|
34
50
|
type: :runtime
|
35
|
-
version_requirements: *
|
51
|
+
version_requirements: *id002
|
36
52
|
- !ruby/object:Gem::Dependency
|
37
53
|
name: mini_magick
|
38
54
|
prerelease: false
|
39
|
-
requirement: &
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
56
|
none: false
|
41
57
|
requirements:
|
42
58
|
- - ~>
|
43
59
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
60
|
+
hash: 13
|
45
61
|
segments:
|
46
62
|
- 3
|
47
63
|
- 2
|
48
|
-
-
|
49
|
-
version: 3.2.
|
64
|
+
- 1
|
65
|
+
version: 3.2.1
|
50
66
|
type: :runtime
|
51
|
-
version_requirements: *
|
67
|
+
version_requirements: *id003
|
52
68
|
- !ruby/object:Gem::Dependency
|
53
69
|
name: rautomation
|
54
70
|
prerelease: false
|
55
|
-
requirement: &
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
56
72
|
none: false
|
57
73
|
requirements:
|
58
74
|
- - ~>
|
@@ -64,11 +80,11 @@ dependencies:
|
|
64
80
|
- 3
|
65
81
|
version: 0.6.3
|
66
82
|
type: :runtime
|
67
|
-
version_requirements: *
|
83
|
+
version_requirements: *id004
|
68
84
|
- !ruby/object:Gem::Dependency
|
69
85
|
name: rspec
|
70
86
|
prerelease: false
|
71
|
-
requirement: &
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
72
88
|
none: false
|
73
89
|
requirements:
|
74
90
|
- - ~>
|
@@ -78,9 +94,9 @@ dependencies:
|
|
78
94
|
- 2
|
79
95
|
- 5
|
80
96
|
version: "2.5"
|
81
|
-
type: :
|
82
|
-
version_requirements: *
|
83
|
-
description: Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats
|
97
|
+
type: :runtime
|
98
|
+
version_requirements: *id005
|
99
|
+
description: Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats.
|
84
100
|
email:
|
85
101
|
- jarmo.p@gmail.com
|
86
102
|
- aslak.hellesoy@gmail.com
|
@@ -88,18 +104,18 @@ executables: []
|
|
88
104
|
|
89
105
|
extensions: []
|
90
106
|
|
91
|
-
extra_rdoc_files:
|
92
|
-
|
93
|
-
- README.rdoc
|
107
|
+
extra_rdoc_files: []
|
108
|
+
|
94
109
|
files:
|
95
|
-
- .
|
110
|
+
- .gitignore
|
96
111
|
- .rspec
|
97
112
|
- .yardopts
|
113
|
+
- Gemfile
|
114
|
+
- Gemfile.lock
|
98
115
|
- History.rdoc
|
99
116
|
- LICENSE
|
100
117
|
- README.rdoc
|
101
118
|
- Rakefile
|
102
|
-
- VERSION
|
103
119
|
- ext/CORE_RL_bzlib_.dll
|
104
120
|
- ext/CORE_RL_jpeg_.dll
|
105
121
|
- ext/CORE_RL_lcms_.dll
|
@@ -122,6 +138,7 @@ files:
|
|
122
138
|
- lib/win32/screenshot/bitmap_maker.rb
|
123
139
|
- lib/win32/screenshot/image.rb
|
124
140
|
- lib/win32/screenshot/take.rb
|
141
|
+
- lib/win32/screenshot/version.rb
|
125
142
|
- spec/spec_helper.rb
|
126
143
|
- spec/win32/screenshot/image_spec.rb
|
127
144
|
- spec/win32/screenshot/take_spec.rb
|
@@ -130,9 +147,8 @@ homepage: http://github.com/jarmo/win32screenshot
|
|
130
147
|
licenses: []
|
131
148
|
|
132
149
|
post_install_message:
|
133
|
-
rdoc_options:
|
134
|
-
|
135
|
-
- README.rdoc
|
150
|
+
rdoc_options: []
|
151
|
+
|
136
152
|
require_paths:
|
137
153
|
- lib
|
138
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -159,7 +175,7 @@ rubyforge_project:
|
|
159
175
|
rubygems_version: 1.8.4
|
160
176
|
signing_key:
|
161
177
|
specification_version: 3
|
162
|
-
summary: Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats
|
178
|
+
summary: Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats.
|
163
179
|
test_files:
|
164
180
|
- spec/spec_helper.rb
|
165
181
|
- spec/win32/screenshot/image_spec.rb
|
data/.document
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.5
|