win32screenshot 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +7 -0
- data/Gemfile.lock +2 -2
- data/README.md +29 -23
- data/lib/win32/screenshot/image.rb +48 -48
- data/lib/win32/screenshot/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20fb85f0a8a6db55a03ef208225cb7a0f081b704f41abf405b39e63283c2c7ea
|
4
|
+
data.tar.gz: bfeb14a87af3452d3bd39b37edfd13733a940657e671e4e038a1ec06775aa858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b4b936b11909e01426ee6ae23a8885106c594a8585372e9e8d7cef59c739d0ce5b7369173b1ae28484559637466f2d22774b0d29a487df13dca8011ed1464d
|
7
|
+
data.tar.gz: e428a2fdcaa46dd961f351000af951d4c4ffa8f556e1b8b9befb7e09dd99eb7c3412d950f9e4122301d6ebc99009cda805eb7343c0772bb14ac0b152fcd4163c
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 4.1.0 2023-02-05
|
2
|
+
* Add support for Ruby 3.2 (by @kaiwaredaikon009 via PR #36)
|
3
|
+
|
4
|
+
|
1
5
|
# 4.0.0 2022-06-18
|
2
6
|
* Add support for taking screenchots of non-native Windows (e.g. Google Chrome).
|
3
7
|
* When taking screenshot of `:desktop` then all monitors will be included if they exist.
|
@@ -6,14 +10,17 @@
|
|
6
10
|
|
7
11
|
Changes done by @bensandland via PR #34.
|
8
12
|
|
13
|
+
|
9
14
|
# 3.1.0 2022-02-05
|
10
15
|
* Update dependencies
|
11
16
|
|
17
|
+
|
12
18
|
# 3.0.0 2019-12-11
|
13
19
|
* Use RAutomation 1.0.0 as its dependency to be able to use newer ffi.
|
14
20
|
* Update bundled ImageMagick to 7.0.9-8.
|
15
21
|
* Update MiniMagick dependency.
|
16
22
|
|
23
|
+
|
17
24
|
# 2.1.0 2016-01-09
|
18
25
|
* Add Image#write! for overwriting images.
|
19
26
|
* Update MiniMagick dependency.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Win32::Screenshot
|
2
2
|
|
3
|
-
*
|
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
|
-
|
12
|
+
```
|
13
|
+
gem install win32screenshot
|
14
|
+
```
|
13
15
|
|
14
16
|
## SYNOPSIS
|
15
17
|
|
16
|
-
|
18
|
+
```ruby
|
19
|
+
require 'win32/screenshot'
|
17
20
|
|
18
|
-
|
19
|
-
|
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
|
-
|
22
|
-
|
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
|
-
|
25
|
-
|
27
|
+
# Take a screenshot of the foreground window
|
28
|
+
Win32::Screenshot::Take.of(:foreground).write("image.png")
|
26
29
|
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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.
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -20,7 +20,7 @@ module SpecHelper
|
|
20
20
|
[:long, :long, :int, :int, :int, :int, :int], :bool
|
21
21
|
|
22
22
|
def save_and_verify_image(img, file=nil)
|
23
|
-
FileUtils.mkdir @temp_dir unless File.
|
23
|
+
FileUtils.mkdir @temp_dir unless File.exist?(@temp_dir)
|
24
24
|
file_name = File.join @temp_dir, "#{file}.bmp"
|
25
25
|
img.write file_name
|
26
26
|
expect(img.bitmap[0..1]).to eq('BM')
|
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.
|
4
|
+
version: 4.1.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:
|
12
|
+
date: 2023-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -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.
|
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.
|