win32screenshot 4.0.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c6e29c2c5baea6ccc52e0a3988c6f9abb76b83054b38072918d097e21471d67
4
- data.tar.gz: 93ee67cb6debdcf6128b2ebc6ffed4165cd54b119417f625bca2431db0996971
3
+ metadata.gz: cfaefd42ed419ebf47ddbc1f191f68466dc30685c3cfd812474bec028e1bab0c
4
+ data.tar.gz: e4c3fbedae082e998a8df7991eeecd54915123f0dff4006605c57c5c31b6af28
5
5
  SHA512:
6
- metadata.gz: 3ea409fdeeba7caf2dc68858eb378983641003b9167112b58ae8138cd48789f705c2efa77002295614d75f07a0b75a8e783b8bcb47ccb02e1368e030dbb344b1
7
- data.tar.gz: 313e9d5d815495afe4bd59e04b2603e778494500ce19649812335df18f71fdc966635af43074e6ce71e9f0b5da54436839dad4a02e04cf38556d4320756562a6
6
+ metadata.gz: 74f3b311f74ab58d0aa481f2d7212fa8d258e124b53acaa1f4b6adb3dbd3ef2e0e16c83aa0434aacf35bb74ebce853755e95a0e366a72fb319cc5c2cb924122d
7
+ data.tar.gz: 417262ff0d00e1c6223fe42259a6139d0bbc0f794ccbb2670aef16ce38b4bfddff934a906cb340f3e7df08407cba0bd816e8600532b0ed5a49e0b5de8cb6b309
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 5.0.0 2023-07-20
2
+ * Add support for 64-bit Ruby (by @bensandland via PR #37)
3
+
4
+ # 4.1.0 2023-02-05
5
+ * Add support for Ruby 3.2 (by @kaiwaredaikon009 via PR #36)
6
+
7
+
1
8
  # 4.0.0 2022-06-18
2
9
  * Add support for taking screenchots of non-native Windows (e.g. Google Chrome).
3
10
  * When taking screenshot of `:desktop` then all monitors will be included if they exist.
@@ -6,14 +13,17 @@
6
13
 
7
14
  Changes done by @bensandland via PR #34.
8
15
 
16
+
9
17
  # 3.1.0 2022-02-05
10
18
  * Update dependencies
11
19
 
20
+
12
21
  # 3.0.0 2019-12-11
13
22
  * Use RAutomation 1.0.0 as its dependency to be able to use newer ffi.
14
23
  * Update bundled ImageMagick to 7.0.9-8.
15
24
  * Update MiniMagick dependency.
16
25
 
26
+
17
27
  # 2.1.0 2016-01-09
18
28
  * Add Image#write! for overwriting images.
19
29
  * Update MiniMagick dependency.
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- win32screenshot (4.0.0)
4
+ win32screenshot (5.0.0)
5
5
  ffi (~> 1.15.0)
6
6
  mini_magick (~> 4.9)
7
- rautomation (~> 1.1.0)
7
+ rautomation (~> 2.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  diff-lcs (1.5.0)
13
- ffi (1.15.5-x86-mingw32)
13
+ ffi (1.15.5-x64-mingw32)
14
14
  mini_magick (4.11.0)
15
15
  rake (13.0.6)
16
- rautomation (1.1.0)
16
+ rautomation (2.0.1-x64-mingw32)
17
17
  ffi (~> 1.15.0)
18
18
  rspec (3.10.0)
19
19
  rspec-core (~> 3.10.0)
@@ -33,6 +33,7 @@ GEM
33
33
  webrick (~> 1.7.0)
34
34
 
35
35
  PLATFORMS
36
+ x64-mingw32
36
37
  x86-mingw32
37
38
 
38
39
  DEPENDENCIES
@@ -42,4 +43,4 @@ DEPENDENCIES
42
43
  yard
43
44
 
44
45
  BUNDLED WITH
45
- 2.3.3
46
+ 2.3.24
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Win32::Screenshot
2
2
 
3
- * http://github.com/jarmo/win32screenshot
3
+ * http://github.com/jarmo/win32screenshot
4
4
 
5
5
 
6
6
  ## DESCRIPTION
@@ -9,39 +9,45 @@ Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats!
9
9
 
10
10
  ## INSTALL
11
11
 
12
- gem install win32screenshot
12
+ ```
13
+ gem install win32screenshot
14
+ ```
13
15
 
14
16
  ## SYNOPSIS
15
17
 
16
- require 'win32/screenshot'
18
+ ```ruby
19
+ require 'win32/screenshot'
17
20
 
18
- # Take a screenshot of the window with the specified title
19
- Win32::Screenshot::Take.of(:window, title: "Windows Internet Explorer").write("image.bmp")
21
+ # Take a screenshot of the window with the specified title
22
+ Win32::Screenshot::Take.of(:window, title: "Windows Internet Explorer").write("image.bmp")
20
23
 
21
- # Take a screenshot of the whole desktop area, including all monitors if multiple are connected
22
- Win32::Screenshot::Take.of(:desktop).write("image.png")
24
+ # Take a screenshot of the whole desktop area, including all monitors if multiple are connected
25
+ Win32::Screenshot::Take.of(:desktop).write("image.png")
23
26
 
24
- # Take a screenshot of the foreground window
25
- Win32::Screenshot::Take.of(:foreground).write("image.png")
27
+ # Take a screenshot of the foreground window
28
+ Win32::Screenshot::Take.of(:foreground).write("image.png")
26
29
 
27
- # Take a screenshot of the foreground window, and writing over previous image if it exists
28
- Win32::Screenshot::Take.of(:foreground).write!("image.png")
30
+ # Take a screenshot of the foreground window, and writing over previous image if it exists
31
+ Win32::Screenshot::Take.of(:foreground).write!("image.png")
29
32
 
30
- # Take a screenshot of the specified window with title matching the regular expression
31
- Win32::Screenshot::Take.of(:window, title: /internet/i).write("image.jpg")
33
+ # Take a screenshot of the specified window with title matching the regular expression
34
+ Win32::Screenshot::Take.of(:window, title: /internet/i).write("image.jpg")
32
35
 
33
- # Take a screenshot of the window with the specified handle
34
- Win32::Screenshot::Take.of(:window, hwnd: 123456).write("image.gif")
36
+ # Take a screenshot of the window with the specified handle
37
+ Win32::Screenshot::Take.of(:window, hwnd: 123456).write("image.gif")
35
38
 
36
- # Take a screenshot of the child window with the specified internal class name
37
- Win32::Screenshot::Take.of(:rautomation, RAutomation::Window.new(hwnd: 123456).
38
- child(class: "Internet Explorer_Server")).write("image.png")
39
+ # Take a screenshot of the child window with the specified internal class name
40
+ Win32::Screenshot::Take.of(
41
+ :rautomation,
42
+ RAutomation::Window.new(hwnd: 123456).child(class: "Internet Explorer_Server")
43
+ ).write("image.png")
39
44
 
40
- # Use the bitmap blob for something else
41
- image = Win32::Screenshot::Take.of(:window, hwnd: 123456)
42
- image.height # => height of the image
43
- image.width # => width of the image
44
- image.bitmap # => bitmap blob
45
+ # Use the bitmap blob for something else
46
+ image = Win32::Screenshot::Take.of(:window, hwnd: 123456)
47
+ image.height # => height of the image
48
+ image.width # => width of the image
49
+ image.bitmap # => bitmap blob
50
+ ```
45
51
 
46
52
  ## Copyright
47
53
 
@@ -1,48 +1,48 @@
1
- module Win32
2
- module Screenshot
3
- # Holds the bitmap data and writes it to the disk
4
- class Image
5
- # [String] raw bitmap blob
6
- attr_reader :bitmap
7
-
8
- # [String] bitmap width
9
- attr_reader :width
10
-
11
- # [String] bitmap height
12
- attr_reader :height
13
-
14
- # Supported output formats
15
- FORMATS = %w{bmp gif jpg png}
16
-
17
- # @private
18
- def initialize(blob, width, height)
19
- @bitmap = blob
20
- @width = width
21
- @height = height
22
- end
23
-
24
- # Writes image to the disk.
25
- # @param [String] file_path writes image to the specified path.
26
- # @raise [RuntimeError] when _file_path_ already exists.
27
- # @raise [RuntimeError] when _file_path_ is not with the supported output {FORMATS} extension.
28
- def write(file_path)
29
- raise "File already exists: #{file_path}!" if File.exists? file_path
30
- write! file_path
31
- end
32
-
33
- #Writes image to disk, writing over existing copy if it exists.
34
- def write!(file_path)
35
- ext = File.extname(file_path)[1..-1]
36
- raise "File '#{file_path}' has to have one of the following extensions: #{FORMATS.join(", ")}" unless ext && FORMATS.include?(ext.downcase)
37
-
38
- if ext.downcase == "bmp"
39
- File.open(file_path, "wb") {|io| io.write @bitmap}
40
- else
41
- image = ::MiniMagick::Image.read @bitmap
42
- image.format ext
43
- image.write file_path
44
- end
45
- end
46
- end
47
- end
48
- end
1
+ module Win32
2
+ module Screenshot
3
+ # Holds the bitmap data and writes it to the disk
4
+ class Image
5
+ # [String] raw bitmap blob
6
+ attr_reader :bitmap
7
+
8
+ # [String] bitmap width
9
+ attr_reader :width
10
+
11
+ # [String] bitmap height
12
+ attr_reader :height
13
+
14
+ # Supported output formats
15
+ FORMATS = %w{bmp gif jpg png}
16
+
17
+ # @private
18
+ def initialize(blob, width, height)
19
+ @bitmap = blob
20
+ @width = width
21
+ @height = height
22
+ end
23
+
24
+ # Writes image to the disk.
25
+ # @param [String] file_path writes image to the specified path.
26
+ # @raise [RuntimeError] when _file_path_ already exists.
27
+ # @raise [RuntimeError] when _file_path_ is not with the supported output {FORMATS} extension.
28
+ def write(file_path)
29
+ raise "File already exists: #{file_path}!" if File.exist? file_path
30
+ write! file_path
31
+ end
32
+
33
+ #Writes image to disk, writing over existing copy if it exists.
34
+ def write!(file_path)
35
+ ext = File.extname(file_path)[1..-1]
36
+ raise "File '#{file_path}' has to have one of the following extensions: #{FORMATS.join(", ")}" unless ext && FORMATS.include?(ext.downcase)
37
+
38
+ if ext.downcase == "bmp"
39
+ File.open(file_path, "wb") {|io| io.write @bitmap}
40
+ else
41
+ image = ::MiniMagick::Image.read @bitmap
42
+ image.format ext
43
+ image.write file_path
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,5 +1,5 @@
1
1
  module Win32
2
2
  module Screenshot
3
- VERSION = "4.0.0"
3
+ VERSION = "5.0.0"
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -5,38 +5,16 @@ require 'rspec'
5
5
  require 'fileutils'
6
6
 
7
7
  module SpecHelper
8
- HWND_TOPMOST = -1
9
- HWND_NOTOPMOST = -2
10
- SWP_NOSIZE = 1
11
- SWP_NOMOVE = 2
12
- SWP_SHOWWINDOW = 40
13
-
14
- extend FFI::Library
15
- ffi_lib 'user32'
16
- ffi_convention :stdcall
17
-
18
- # user32.dll
19
- attach_function :set_window_pos, :SetWindowPos,
20
- [:long, :long, :int, :int, :int, :int, :int], :bool
21
-
22
8
  def save_and_verify_image(img, file=nil)
23
- FileUtils.mkdir @temp_dir unless File.exists?(@temp_dir)
9
+ FileUtils.mkdir @temp_dir unless File.exist?(@temp_dir)
24
10
  file_name = File.join @temp_dir, "#{file}.bmp"
25
11
  img.write file_name
26
12
  expect(img.bitmap[0..1]).to eq('BM')
27
13
  end
28
14
 
29
15
  def resize title
30
- hwnd = RAutomation::Window.new(:title => title).hwnd
31
- set_window_pos(hwnd,
32
- HWND_TOPMOST,
33
- 0, 0, 150, 238,
34
- SWP_NOMOVE)
35
- set_window_pos(hwnd,
36
- HWND_NOTOPMOST,
37
- 0, 0, 0, 0,
38
- SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE)
39
- sleep 1
16
+ window = RAutomation::Window.new(title: title)
17
+ window.move(left: 0, top: 0, width: 150, height: 238)
40
18
  end
41
19
  end
42
20
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_dependency("ffi", "~> 1.15.0")
19
19
  s.add_dependency("mini_magick", "~> 4.9")
20
- s.add_dependency("rautomation", "~> 1.1.0")
20
+ s.add_dependency("rautomation", "~> 2.0")
21
21
 
22
22
  s.add_development_dependency("rspec", "~> 3.10")
23
23
  s.add_development_dependency("yard")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32screenshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarmo Pertman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-18 00:00:00.000000000 Z
12
+ date: 2023-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 1.1.0
48
+ version: '2.0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 1.1.0
55
+ version: '2.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.0.3
148
+ rubygems_version: 3.3.24
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats.