rdp-win32screenshot 0.0.7.2 → 0.0.7.3

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/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 0.0.7.2
1
+ 0.0.7.3
2
2
 
@@ -13,7 +13,9 @@ module Win32
13
13
 
14
14
  # user32.dll
15
15
  attach_function :enum_windows, :EnumWindows,
16
- [:enum_callback, :pointer], :long
16
+ [:enum_callback, :pointer], :int
17
+ attach_function :enum_child_windows, :EnumChildWindows,
18
+ [:long, :enum_callback, :pointer], :int
17
19
  attach_function :window_text, :GetWindowTextA,
18
20
  [:long, :pointer, :int], :int
19
21
  attach_function :window_text_length, :GetWindowTextLengthA,
@@ -65,26 +67,40 @@ module Win32
65
67
  attach_function :release_dc, :ReleaseDC,
66
68
  [:long, :long], :int
67
69
 
68
-
69
-
70
70
 
71
71
  EnumWindowCallback = FFI::Function.new(:bool, [ :long, :pointer ], { :convention => :stdcall }) do |hwnd, param|
72
72
  searched_window = WindowStruct.new param
73
- title = Util.window_title(hwnd)
73
+ if(searched_window[:search_class] != 0)
74
+ title = Util.window_class(hwnd)
75
+ else
76
+ title = Util.window_title(hwnd)
77
+ end
74
78
  if title =~ Regexp.new(searched_window[:title].read_string) && window_visible(hwnd)
75
79
  searched_window[:hwnd] = hwnd
76
80
  false
77
81
  else
78
- true
82
+ if(searched_window[:search_class] != 0)
83
+ # if they're searching for a classname, enumerate children, too
84
+ enum_child_windows(hwnd, EnumWindowCallback, param)
85
+ if searched_window[:hwnd] != 0
86
+ # return early if already discovered
87
+ false
88
+ else
89
+ true
90
+ end
91
+ else
92
+ true
93
+ end
79
94
  end
80
95
  end
81
96
 
82
97
  class WindowStruct < FFI::Struct
83
98
  layout :title, :pointer,
84
- :hwnd, :long
99
+ :hwnd, :long,
100
+ :search_class, :char # boolean
85
101
  end
86
102
 
87
- def hwnd(window_title)
103
+ def hwnd(window_title, search_class = nil)
88
104
  window = WindowStruct.new
89
105
  unless window_title.is_a?(Regexp)
90
106
  window_title = Regexp.escape(window_title.to_s)
@@ -93,10 +109,11 @@ module Win32
93
109
  end
94
110
  window_title = FFI::MemoryPointer.from_string(window_title)
95
111
  window[:title] = window_title
112
+ window[:search_class] = search_class ? 1 : 0
96
113
  enum_windows(EnumWindowCallback, window.to_ptr)
97
114
  window[:hwnd] == 0 ? nil : window[:hwnd]
98
115
  end
99
-
116
+
100
117
  def prepare_window(hwnd, pause)
101
118
  restore(hwnd) if minimized(hwnd)
102
119
  set_foreground(hwnd)
data/lib/win32/util.rb CHANGED
@@ -23,7 +23,7 @@ module Win32
23
23
 
24
24
  def window_class hwnd
25
25
  title = FFI::MemoryPointer.new :char, 100
26
- BitmapMaker.class_name(hwnd, title, 100)
26
+ BitmapMaker.class_name(hwnd, title, 99)
27
27
  title.read_string
28
28
  end
29
29
 
@@ -72,6 +72,17 @@ describe Win32::Screenshot do
72
72
  [width, height].should == Win32::Screenshot::Util.dimensions_for(hwnd)
73
73
  end
74
74
  end
75
+
76
+ it "can also search by window class name" do
77
+ good_pid = Win32::Screenshot::BitmapMaker.hwnd(/calculator/i)
78
+ good_pid.should_not be_nil
79
+ good_pid.should == Win32::Screenshot::BitmapMaker.hwnd(/calcframe/i, true)
80
+ end
81
+
82
+ it "can find sub windows as well" do
83
+ # search for an IE sub-window by class (doesn't have text)
84
+ Win32::Screenshot::BitmapMaker.hwnd(/CommandBarClass/i, true).should_not be_nil
85
+ end
75
86
 
76
87
  it "captures small windows" do
77
88
  title = /Notepad/
@@ -140,7 +151,7 @@ describe Win32::Screenshot do
140
151
  [width, height].should == Win32::Screenshot::Util.dimensions_for(hwnd)
141
152
  end
142
153
  end
143
-
154
+
144
155
  it "captures area of the window with handle" do
145
156
  hwnd = Win32::Screenshot::BitmapMaker.hwnd(/calculator/i)
146
157
  Win32::Screenshot.hwnd_area(hwnd, 30, 30, 100, 150) do |width, height, bmp|
@@ -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\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
-
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\u00F8y"]
12
+ s.date = %q{2010-08-19}
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
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 0
8
8
  - 7
9
- - 2
10
- version: 0.0.7.2
9
+ - 3
10
+ version: 0.0.7.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jarmo Pertman