win32ole 1.8.8

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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +7 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +56 -0
  7. data/Rakefile +10 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/ext/win32ole/depend +12 -0
  11. data/ext/win32ole/extconf.rb +45 -0
  12. data/ext/win32ole/sample/excel1.rb +37 -0
  13. data/ext/win32ole/sample/excel2.rb +31 -0
  14. data/ext/win32ole/sample/excel3.rb +21 -0
  15. data/ext/win32ole/sample/ie.rb +12 -0
  16. data/ext/win32ole/sample/ieconst.rb +33 -0
  17. data/ext/win32ole/sample/ienavi.rb +41 -0
  18. data/ext/win32ole/sample/ienavi2.rb +41 -0
  19. data/ext/win32ole/sample/oledirs.rb +24 -0
  20. data/ext/win32ole/sample/olegen.rb +348 -0
  21. data/ext/win32ole/sample/xml.rb +7307 -0
  22. data/ext/win32ole/win32ole.c +4140 -0
  23. data/ext/win32ole/win32ole.h +155 -0
  24. data/ext/win32ole/win32ole_error.c +84 -0
  25. data/ext/win32ole/win32ole_error.h +9 -0
  26. data/ext/win32ole/win32ole_event.c +1277 -0
  27. data/ext/win32ole/win32ole_event.h +6 -0
  28. data/ext/win32ole/win32ole_method.c +950 -0
  29. data/ext/win32ole/win32ole_method.h +16 -0
  30. data/ext/win32ole/win32ole_param.c +438 -0
  31. data/ext/win32ole/win32ole_param.h +8 -0
  32. data/ext/win32ole/win32ole_record.c +604 -0
  33. data/ext/win32ole/win32ole_record.h +10 -0
  34. data/ext/win32ole/win32ole_type.c +915 -0
  35. data/ext/win32ole/win32ole_type.h +8 -0
  36. data/ext/win32ole/win32ole_typelib.c +844 -0
  37. data/ext/win32ole/win32ole_typelib.h +11 -0
  38. data/ext/win32ole/win32ole_variable.c +380 -0
  39. data/ext/win32ole/win32ole_variable.h +8 -0
  40. data/ext/win32ole/win32ole_variant.c +733 -0
  41. data/ext/win32ole/win32ole_variant.h +9 -0
  42. data/ext/win32ole/win32ole_variant_m.c +149 -0
  43. data/ext/win32ole/win32ole_variant_m.h +7 -0
  44. data/lib/win32ole.rb +33 -0
  45. data/lib/win32ole/property.rb +17 -0
  46. data/win32ole.gemspec +22 -0
  47. metadata +91 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dfff5b9994fea1fd3249f3d80aa265a21cd27f7ddd8d74bc34438f987342f97b
4
+ data.tar.gz: cd3953182a81a6bb9bbc5d561bdc800aee603cccda736113cd37785685564bb2
5
+ SHA512:
6
+ metadata.gz: 984fbc6c59a16d9855982896c1fa1230ec6a68ee90083afe7564fce2e07a8e8c05131dfbc322175858be520da1b109ddc642a262bee7c4bcbad809aaaca01b30
7
+ data.tar.gz: a88c069fe37638ffa0749fc113506b96d23c0882e0953c4d4d55583111fc3012c18941b9989500c2645e564cb238f7dd85b35363fbdbf85e8296f94b9c813738
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.8.0
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in win32ole.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
@@ -0,0 +1,56 @@
1
+ # WIN32OLE
2
+
3
+ WIN32OLE objects represent OLE Automation object in Ruby.
4
+
5
+ By using WIN32OLE, you can access OLE server like VBScript.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'win32ole'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install win32ole
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ require 'win32ole'
27
+
28
+ excel = WIN32OLE.new('Excel.Application')
29
+ excel.visible = true
30
+ workbook = excel.Workbooks.Add();
31
+ worksheet = workbook.Worksheets(1);
32
+ worksheet.Range("A1:D1").value = ["North","South","East","West"];
33
+ worksheet.Range("A2:B2").value = [5.2, 10];
34
+ worksheet.Range("C2").value = 8;
35
+ worksheet.Range("D2").value = 20;
36
+
37
+ range = worksheet.Range("A1:D2");
38
+ range.select
39
+ chart = workbook.Charts.Add;
40
+
41
+ workbook.saved = true;
42
+
43
+ excel.ActiveWorkbook.Close(0);
44
+ excel.Quit();
45
+ ```
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/win32ole.
56
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/test_*.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "win32ole"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ WIN32OLE_HEADERS = $(HDRS) $(ruby_headers)
2
+ win32ole.o : win32ole.c $(WIN32OLE_HEADERS)
3
+ win32ole_variant_m.o : win32ole_variant_m.c $(WIN32OLE_HEADERS)
4
+ win32ole_typelib.o : win32ole_typelib.c $(WIN32OLE_HEADERS)
5
+ win32ole_type.o : win32ole_type.c $(WIN32OLE_HEADERS)
6
+ win32ole_variable.o : win32ole_variable.c $(WIN32OLE_HEADERS)
7
+ win32ole_method.o : win32ole_method.c $(WIN32OLE_HEADERS)
8
+ win32ole_param.o : win32ole_param.c $(WIN32OLE_HEADERS)
9
+ win32ole_variant.o : win32ole_variant.c $(WIN32OLE_HEADERS)
10
+ win32ole_event.o : win32ole_event.c $(WIN32OLE_HEADERS)
11
+ win32ole_record.o : win32ole_record.c $(WIN32OLE_HEADERS)
12
+ win32ole_error.o : win32ole_error.c $(WIN32OLE_HEADERS)
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: false
2
+ #----------------------------------
3
+ # extconf.rb
4
+ # $Revision$
5
+ #----------------------------------
6
+ require 'mkmf'
7
+
8
+ case RUBY_PLATFORM
9
+ when /cygwin/
10
+ inc = nil
11
+ lib = '/usr/lib/w32api'
12
+ end
13
+
14
+ dir_config("win32", inc, lib)
15
+
16
+ def create_win32ole_makefile
17
+ if have_library("ole32") and
18
+ have_library("oleaut32") and
19
+ have_library("uuid", "&CLSID_CMultiLanguage", "mlang.h") and
20
+ have_library("user32") and
21
+ have_library("kernel32") and
22
+ have_library("advapi32") and
23
+ have_header("windows.h")
24
+ unless have_type("IMultiLanguage2", "mlang.h")
25
+ have_type("IMultiLanguage", "mlang.h")
26
+ end
27
+ spec = nil
28
+ checking_for('thread_specific', '%s') do
29
+ spec = %w[__declspec(thread) __thread].find {|th|
30
+ try_compile("#{th} int foo;", "", :werror => true)
31
+ }
32
+ spec or 'no'
33
+ end
34
+ $defs << "-DRB_THREAD_SPECIFIC=#{spec}" if spec
35
+ create_makefile("win32ole")
36
+ end
37
+ end
38
+
39
+
40
+ case RUBY_PLATFORM
41
+ when /mswin/
42
+ $CFLAGS.sub!(/((?:\A|\s)[-\/])W\d(?=\z|\s)/, '\1W3') or
43
+ $CFLAGS += ' -W3'
44
+ end
45
+ create_win32ole_makefile
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: false
2
+ require 'win32ole'
3
+
4
+ application = WIN32OLE.new('Excel.Application')
5
+
6
+ application.visible = true
7
+ workbook = application.Workbooks.Add();
8
+ worksheet = workbook.Worksheets(1);
9
+
10
+ =begin
11
+ worksheet.Range("A1:D1").value = ["North","South","East","West"];
12
+ worksheet.Range("A2:B2").value = [5.2, 10];
13
+
14
+ worksheet.Range("C2").value = 8;
15
+ worksheet.Range("D2").value = 20;
16
+ =end
17
+
18
+ worksheet.Range("A1:B2").value = [["North","South"],
19
+ [5.2, 10]];
20
+
21
+ vals = WIN32OLE_VARIANT.new([["East","West"],
22
+ [8, 20]],
23
+ WIN32OLE::VARIANT::VT_ARRAY)
24
+ worksheet.Range("C1:D2").value = vals
25
+
26
+ range = worksheet.Range("A1:D2");
27
+ range.Select
28
+ chart = workbook.Charts.Add;
29
+
30
+ workbook.saved = true;
31
+
32
+ print "Now quit Excel... Please enter."
33
+ gets
34
+
35
+ application.ActiveWorkbook.Close(0);
36
+ application.Quit();
37
+
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: false
2
+ require 'win32ole'
3
+
4
+ # -4100 is the value for the Excel constant xl3DColumn.
5
+ ChartTypeVal = -4100;
6
+
7
+ # Creates OLE object to Excel
8
+ excel = WIN32OLE.new("excel.application")
9
+
10
+ # Create and rotate the chart
11
+ excel.visible = true;
12
+ excel.Workbooks.Add();
13
+ excel.Range("a1").value = 3;
14
+ excel.Range("a2").value = 2;
15
+ excel.Range("a3").value = 1;
16
+ excel.Range("a1:a3").Select();
17
+ excelchart = excel.Charts.Add();
18
+ excelchart.type = ChartTypeVal;
19
+
20
+ i = 0
21
+ i.step(180, 10) do |rot|
22
+ excelchart.rotation=rot;
23
+ sleep 0.1
24
+ end
25
+ # Done, bye
26
+
27
+ print "Now quit Excel... Please enter."
28
+ gets
29
+
30
+ excel.ActiveWorkbook.Close(0);
31
+ excel.Quit();
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: false
2
+ require 'win32ole'
3
+
4
+ #application = WIN32OLE.new('Excel.Application.5')
5
+ application = WIN32OLE.new('Excel.Application')
6
+
7
+ application.visible = true
8
+ workbook = application.Workbooks.Add();
9
+ sheet = workbook.Worksheets(1);
10
+ sheetS = workbook.Worksheets
11
+ puts "The number of sheets is #{sheetS.count}"
12
+ puts "Now add 2 sheets after of `#{sheet.name}`"
13
+ sheetS.add({'count'=>2, 'after'=>sheet})
14
+ puts "The number of sheets is #{sheetS.count}"
15
+
16
+ print "Now quit Excel... Please enter."
17
+ gets
18
+
19
+ application.ActiveWorkbook.Close(0);
20
+ application.Quit();
21
+
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: false
2
+ require 'win32ole'
3
+ url = 'http://www.ruby-lang.org/'
4
+ ie = WIN32OLE.new('InternetExplorer.Application')
5
+ ie.visible = true
6
+ ie.gohome
7
+ print "Now navigate Ruby home page... Please enter."
8
+ gets
9
+ ie.navigate(url)
10
+ print "Now quit Internet Explorer... Please enter."
11
+ gets
12
+ ie.Quit()
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: false
2
+ require 'win32ole'
3
+
4
+ ie = WIN32OLE.new('InternetExplorer.Application')
5
+ =begin
6
+ WIN32OLE.const_load(ie)
7
+ WIN32OLE.constants.sort.each do |c|
8
+ puts "#{c} = #{WIN32OLE.const_get(c)}"
9
+ end
10
+ =end
11
+
12
+ module IE_CONST
13
+ end
14
+
15
+ WIN32OLE.const_load(ie, IE_CONST)
16
+ IE_CONST.constants.sort.each do |c|
17
+ puts "#{c} = #{IE_CONST.const_get(c)}"
18
+ end
19
+
20
+ #------------------------------------------------------------
21
+ # Remark!!! CONSTANTS has not tested enoughly!!!
22
+ # CONSTANTS is alpha release.
23
+ # If there are constants which first letter is not [a-zA-Z],
24
+ # like a '_Foo', then maybe you can access the value by
25
+ # using CONSTANTS['_Foo']
26
+ #------------------------------------------------------------
27
+ IE_CONST::CONSTANTS.each do |k, v|
28
+ puts "#{k} = #{v}"
29
+ end
30
+
31
+ puts WIN32OLE::VERSION
32
+ ie.quit
33
+
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: false
2
+ require 'win32ole'
3
+
4
+ $urls = []
5
+
6
+ def navigate(url)
7
+ $urls << url
8
+ end
9
+
10
+ def stop_msg_loop
11
+ puts "Now Stop IE..."
12
+ $LOOP = false;
13
+ end
14
+
15
+ def default_handler(event, *args)
16
+ case event
17
+ when "BeforeNavigate"
18
+ puts "Now Navigate #{args[0]}..."
19
+ end
20
+ end
21
+
22
+ ie = WIN32OLE.new('InternetExplorer.Application')
23
+ ie.visible = true
24
+ ie.gohome
25
+
26
+ ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
27
+
28
+ ev.on_event {|*args| default_handler(*args)}
29
+ ev.on_event("NavigateComplete") {|url| navigate(url)}
30
+ ev.on_event("Quit") {|*args| stop_msg_loop}
31
+
32
+ $LOOP = true
33
+ while ($LOOP)
34
+ WIN32OLE_EVENT.message_loop
35
+ end
36
+
37
+ puts "You Navigated the URLs ..."
38
+ $urls.each_with_index do |url, i|
39
+ puts "(#{i+1}) #{url}"
40
+ end
41
+
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: false
2
+ require 'win32ole'
3
+
4
+ class IEHandler
5
+ attr_reader :loop
6
+ def initialize
7
+ @urls = []
8
+ @loop = true
9
+ end
10
+ def method_missing(event, *args)
11
+ case event
12
+ when "BeforeNavigate2"
13
+ puts "Now Navigate #{args[1]}..."
14
+ end
15
+ end
16
+ def onNavigateComplete2(pdisp, url)
17
+ @urls << url
18
+ end
19
+ def onOnQuit
20
+ puts "Now Stop IE..."
21
+ @loop = false
22
+ end
23
+ def put_urls
24
+ puts "You Navigated the URLs ..."
25
+ @urls.each_with_index do |url, i|
26
+ puts "(#{i+1}) #{url}"
27
+ end
28
+ end
29
+ end
30
+
31
+ ie = WIN32OLE.new('InternetExplorer.Application')
32
+ ie.visible = true
33
+ ie.gohome
34
+
35
+ ev = WIN32OLE_EVENT.new(ie)
36
+ ev.handler = IEHandler.new
37
+
38
+ while (ev.handler.loop)
39
+ WIN32OLE_EVENT.message_loop
40
+ end
41
+ ev.handler.put_urls
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: false
2
+ #
3
+ # You need WSH(Windows Scripting Host) to run this script.
4
+ #
5
+
6
+ require "win32ole"
7
+
8
+ def listup(items)
9
+ # items.each do |i|
10
+ for i in items
11
+ puts i.name
12
+ end
13
+ end
14
+
15
+ fs = WIN32OLE.new("Scripting.FileSystemObject")
16
+
17
+ folder = fs.GetFolder(".")
18
+
19
+ puts "--- folder of #{folder.path} ---"
20
+ listup(folder.SubFolders)
21
+
22
+ puts "--- files of #{folder.path} ---"
23
+ listup(folder.Files)
24
+