rdp-win32screenshot 0.0.7.3 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/RDP_BRANCH_HAS_MASTER_WITH_CORRECT_VERSION_NUMBER +0 -0
- data/RDP_VERSION_IS_IN_RDP_BRANCH +0 -0
- data/VERSION +1 -2
- data/lib/win32/screenshot/bitmap_maker.rb +3 -1
- data/lib/win32/util.rb +45 -2
- data/spec/win32_screenshot_util_spec.rb +31 -3
- data/win32screenshot.gemspec +69 -69
- metadata +16 -13
- data/.gitignore +0 -5
File without changes
|
File without changes
|
data/VERSION
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
0.0.
|
2
|
-
|
1
|
+
0.0.9
|
@@ -28,6 +28,8 @@ module Win32
|
|
28
28
|
[:long], :long
|
29
29
|
attach_function :client_rect, :GetClientRect,
|
30
30
|
[:long, :pointer], :bool
|
31
|
+
attach_function :window_rect, :GetWindowRect,
|
32
|
+
[:long, :pointer], :bool
|
31
33
|
attach_function :minimized, :IsIconic,
|
32
34
|
[:long], :bool
|
33
35
|
attach_function :show_window, :ShowWindow,
|
@@ -100,7 +102,7 @@ module Win32
|
|
100
102
|
:search_class, :char # boolean
|
101
103
|
end
|
102
104
|
|
103
|
-
def hwnd(window_title, search_class =
|
105
|
+
def hwnd(window_title, search_class = false)
|
104
106
|
window = WindowStruct.new
|
105
107
|
unless window_title.is_a?(Regexp)
|
106
108
|
window_title = Regexp.escape(window_title.to_s)
|
data/lib/win32/util.rb
CHANGED
@@ -3,7 +3,7 @@ module Win32
|
|
3
3
|
class Util
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def
|
6
|
+
def all_desktop_windows
|
7
7
|
titles = []
|
8
8
|
window_callback = FFI::Function.new(:bool, [ :long, :pointer ], { :convention => :stdcall }) do |hwnd, param|
|
9
9
|
titles << [window_title(hwnd), hwnd]
|
@@ -13,7 +13,43 @@ module Win32
|
|
13
13
|
BitmapMaker.enum_windows(window_callback, nil)
|
14
14
|
titles
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
|
+
# just returns a long list of hwnd's...
|
18
|
+
# unless with_info is true
|
19
|
+
# then it will return all hwnds with full info about each window
|
20
|
+
def windows_hierarchy with_info = false
|
21
|
+
all = {}
|
22
|
+
desktop_hwnd = BitmapMaker.desktop_window
|
23
|
+
root = {:hwnd => desktop_hwnd, :children => []}
|
24
|
+
root.merge!(get_info(desktop_hwnd)) if with_info
|
25
|
+
parents = []
|
26
|
+
parents << root
|
27
|
+
window_callback = FFI::Function.new(:bool, [ :long, :pointer ], { :convention => :stdcall }) do |hwnd, param|
|
28
|
+
# this is a child of the most recent parent
|
29
|
+
myself = {:hwnd => hwnd, :children => []}
|
30
|
+
myself.merge!(get_info(hwnd)) if with_info
|
31
|
+
parents[-1][:children] << myself
|
32
|
+
parents << myself
|
33
|
+
if !all[hwnd]
|
34
|
+
all[hwnd] = true
|
35
|
+
BitmapMaker.enum_child_windows(hwnd, window_callback, nil)
|
36
|
+
end
|
37
|
+
|
38
|
+
parents.pop
|
39
|
+
true
|
40
|
+
end
|
41
|
+
BitmapMaker.enum_child_windows(desktop_hwnd, window_callback, nil)
|
42
|
+
root
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_info hwnd
|
46
|
+
{:title => window_title(hwnd),
|
47
|
+
:class => window_class(hwnd),
|
48
|
+
:dimensions => dimensions_for(hwnd),
|
49
|
+
:starting_coordinates => location_of(hwnd)
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
17
53
|
def window_title hwnd
|
18
54
|
title_length = BitmapMaker.window_text_length(hwnd) + 1
|
19
55
|
title = FFI::MemoryPointer.new :char, title_length
|
@@ -32,6 +68,13 @@ module Win32
|
|
32
68
|
raise "window with title '#{title_query}' was not found!" unless hwnd
|
33
69
|
hwnd
|
34
70
|
end
|
71
|
+
|
72
|
+
def location_of(hwnd)
|
73
|
+
rect = [0, 0, 0, 0].pack('L4')
|
74
|
+
BitmapMaker.window_rect(hwnd, rect)
|
75
|
+
x, y, width, height = rect.unpack('L4')
|
76
|
+
return x, y
|
77
|
+
end
|
35
78
|
|
36
79
|
def dimensions_for(hwnd)
|
37
80
|
rect = [0, 0, 0, 0].pack('L4')
|
@@ -11,8 +11,8 @@ describe Win32::Screenshot::Util do
|
|
11
11
|
@calc_hwnd = Win32::Screenshot::Util.window_hwnd("Calculator")
|
12
12
|
end
|
13
13
|
|
14
|
-
it ".
|
15
|
-
all_windows = Win32::Screenshot::Util.
|
14
|
+
it ".all_desktop_windows enumerates all available windows" do
|
15
|
+
all_windows = Win32::Screenshot::Util.all_desktop_windows
|
16
16
|
all_windows.should_not be_empty
|
17
17
|
all_windows[0].should be_an(Array)
|
18
18
|
all_windows[0][0].should be_a(String)
|
@@ -38,8 +38,36 @@ describe Win32::Screenshot::Util do
|
|
38
38
|
Win32::Screenshot::Util.window_class(@calc_hwnd).should == "CalcFrame"
|
39
39
|
end
|
40
40
|
|
41
|
+
it ".get_info returns lots of info about an hwnd" do
|
42
|
+
desktop_hwnd = Win32::Screenshot::BitmapMaker.desktop_window
|
43
|
+
info = Win32::Screenshot::Util.get_info desktop_hwnd
|
44
|
+
info.should be_a Hash
|
45
|
+
info.keys.sort.should == [:title, :class, :dimensions, :starting_coordinates].sort
|
46
|
+
end
|
47
|
+
|
48
|
+
it ".windows_hierarchy returns hwnds" do
|
49
|
+
a = Win32::Screenshot::Util.windows_hierarchy
|
50
|
+
# should have root as "desktop"
|
51
|
+
# though in reality some windows might not be descendants of the desktop
|
52
|
+
# (see the WinCheat source which discusses this further)
|
53
|
+
# but we don't worry about that edge case yet
|
54
|
+
a.should be_a Hash
|
55
|
+
a[:children].should be_an Array
|
56
|
+
a[:children].length.should be > 0
|
57
|
+
a[:children][0].should be_a Hash
|
58
|
+
a[:hwnd].should == Win32::Screenshot::BitmapMaker.desktop_window
|
59
|
+
end
|
60
|
+
|
61
|
+
it ".windows_hierarchy can return info" do
|
62
|
+
a = Win32::Screenshot::Util.windows_hierarchy true
|
63
|
+
# check for right structure
|
64
|
+
for hash_example in [a, a[:children][0]] do
|
65
|
+
hash_example.keys.sort.should == [:title, :hwnd, :class, :dimensions, :starting_coordinates, :children].sort
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
41
69
|
after :all do
|
42
|
-
#
|
70
|
+
# tests our hwnd -> pid method, and conveniently, shuts down the calculator process
|
43
71
|
calc_pid = Win32::Screenshot::Util.window_process_id(@calc_hwnd)
|
44
72
|
system("taskkill /PID #{calc_pid}")
|
45
73
|
proc {Win32::Screenshot::Util.window_hwnd("Calculator") }.should raise_exception("window with title 'Calculator' was not found!")
|
data/win32screenshot.gemspec
CHANGED
@@ -1,69 +1,69 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{win32screenshot}
|
8
|
-
s.version = "0.0.7"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jarmo Pertman", "Aslak Helles\
|
12
|
-
s.date = %q{2010-08-
|
13
|
-
s.description = %q{Capture Screenshots on Windows with Ruby}
|
14
|
-
s.email = ["jarmo.p@gmail.com", "aslak.hellesoy@gmail.com"]
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"History.rdoc",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/win32/screenshot.rb",
|
28
|
-
"lib/win32/screenshot/bitmap_maker.rb",
|
29
|
-
"lib/win32/util.rb",
|
30
|
-
"spec/spec.opts",
|
31
|
-
"spec/spec_helper.rb",
|
32
|
-
"spec/win32_screenshot_spec.rb",
|
33
|
-
"spec/win32_screenshot_util_spec.rb",
|
34
|
-
"win32screenshot.gemspec"
|
35
|
-
]
|
36
|
-
s.homepage = %q{http://github.com/jarmo/win32screenshot}
|
37
|
-
s.rdoc_options = ["--main", "README.rdoc"]
|
38
|
-
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = %q{1.3.7}
|
40
|
-
s.summary = %q{Capture Screenshots on Windows with Ruby}
|
41
|
-
s.test_files = [
|
42
|
-
"spec/spec_helper.rb",
|
43
|
-
"spec/win32_screenshot_spec.rb",
|
44
|
-
"spec/win32_screenshot_util_spec.rb"
|
45
|
-
]
|
46
|
-
|
47
|
-
if s.respond_to? :specification_version then
|
48
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
-
s.specification_version = 3
|
50
|
-
|
51
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_runtime_dependency(%q<ffi>, [">= 0"])
|
53
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
54
|
-
s.add_development_dependency(%q<os>, [">= 0"])
|
55
|
-
s.add_development_dependency(%q<rmagick>, [">= 0"])
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<ffi>, [">= 0"])
|
58
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
59
|
-
s.add_dependency(%q<os>, [">= 0"])
|
60
|
-
s.add_dependency(%q<rmagick>, [">= 0"])
|
61
|
-
end
|
62
|
-
else
|
63
|
-
s.add_dependency(%q<ffi>, [">= 0"])
|
64
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
-
s.add_dependency(%q<os>, [">= 0"])
|
66
|
-
s.add_dependency(%q<rmagick>, [">= 0"])
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{win32screenshot}
|
8
|
+
s.version = "0.0.7"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jarmo Pertman", "Aslak Helles\303\270y"]
|
12
|
+
s.date = %q{2010-08-18}
|
13
|
+
s.description = %q{Capture Screenshots on Windows with Ruby}
|
14
|
+
s.email = ["jarmo.p@gmail.com", "aslak.hellesoy@gmail.com"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"History.rdoc",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/win32/screenshot.rb",
|
28
|
+
"lib/win32/screenshot/bitmap_maker.rb",
|
29
|
+
"lib/win32/util.rb",
|
30
|
+
"spec/spec.opts",
|
31
|
+
"spec/spec_helper.rb",
|
32
|
+
"spec/win32_screenshot_spec.rb",
|
33
|
+
"spec/win32_screenshot_util_spec.rb",
|
34
|
+
"win32screenshot.gemspec"
|
35
|
+
]
|
36
|
+
s.homepage = %q{http://github.com/jarmo/win32screenshot}
|
37
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.3.7}
|
40
|
+
s.summary = %q{Capture Screenshots on Windows with Ruby}
|
41
|
+
s.test_files = [
|
42
|
+
"spec/spec_helper.rb",
|
43
|
+
"spec/win32_screenshot_spec.rb",
|
44
|
+
"spec/win32_screenshot_util_spec.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<ffi>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
54
|
+
s.add_development_dependency(%q<os>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<rmagick>, [">= 0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<ffi>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
59
|
+
s.add_dependency(%q<os>, [">= 0"])
|
60
|
+
s.add_dependency(%q<rmagick>, [">= 0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<ffi>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
+
s.add_dependency(%q<os>, [">= 0"])
|
66
|
+
s.add_dependency(%q<rmagick>, [">= 0"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdp-win32screenshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 13
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.0.7.3
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jarmo Pertman
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
20
|
-
default_executable:
|
19
|
+
date: 2011-08-12 00:00:00 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: ffi
|
@@ -27,6 +26,7 @@ dependencies:
|
|
27
26
|
requirements:
|
28
27
|
- - ">="
|
29
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
version: "0"
|
@@ -40,6 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 13
|
43
44
|
segments:
|
44
45
|
- 1
|
45
46
|
- 2
|
@@ -55,6 +56,7 @@ dependencies:
|
|
55
56
|
requirements:
|
56
57
|
- - ">="
|
57
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
58
60
|
segments:
|
59
61
|
- 0
|
60
62
|
version: "0"
|
@@ -68,6 +70,7 @@ dependencies:
|
|
68
70
|
requirements:
|
69
71
|
- - ">="
|
70
72
|
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
71
74
|
segments:
|
72
75
|
- 0
|
73
76
|
version: "0"
|
@@ -86,9 +89,10 @@ extra_rdoc_files:
|
|
86
89
|
- README.rdoc
|
87
90
|
files:
|
88
91
|
- .document
|
89
|
-
- .gitignore
|
90
92
|
- History.rdoc
|
91
93
|
- LICENSE
|
94
|
+
- RDP_BRANCH_HAS_MASTER_WITH_CORRECT_VERSION_NUMBER
|
95
|
+
- RDP_VERSION_IS_IN_RDP_BRANCH
|
92
96
|
- README.rdoc
|
93
97
|
- Rakefile
|
94
98
|
- VERSION
|
@@ -100,7 +104,6 @@ files:
|
|
100
104
|
- spec/win32_screenshot_spec.rb
|
101
105
|
- spec/win32_screenshot_util_spec.rb
|
102
106
|
- win32screenshot.gemspec
|
103
|
-
has_rdoc: true
|
104
107
|
homepage: http://github.com/jarmo/win32screenshot
|
105
108
|
licenses: []
|
106
109
|
|
@@ -115,6 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
118
|
requirements:
|
116
119
|
- - ">="
|
117
120
|
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
118
122
|
segments:
|
119
123
|
- 0
|
120
124
|
version: "0"
|
@@ -123,17 +127,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
127
|
requirements:
|
124
128
|
- - ">="
|
125
129
|
- !ruby/object:Gem::Version
|
130
|
+
hash: 3
|
126
131
|
segments:
|
127
132
|
- 0
|
128
133
|
version: "0"
|
129
134
|
requirements: []
|
130
135
|
|
131
136
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.
|
137
|
+
rubygems_version: 1.7.2
|
133
138
|
signing_key:
|
134
139
|
specification_version: 3
|
135
140
|
summary: Capture Screenshots on Windows with Ruby
|
136
|
-
test_files:
|
137
|
-
|
138
|
-
- spec/win32_screenshot_spec.rb
|
139
|
-
- spec/win32_screenshot_util_spec.rb
|
141
|
+
test_files: []
|
142
|
+
|