jruby-win32ole 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +4 -0
  3. data/README +0 -0
  4. data/Rakefile +8 -0
  5. data/VERSION +1 -0
  6. data/bin/make_data.rb +12 -0
  7. data/bin/sample +11 -0
  8. data/build.xml +74 -0
  9. data/jruby-win32ole.gemspec +21 -0
  10. data/lib/jruby-win32ole.rb +39 -0
  11. data/lib/jruby-win32ole/version.rb +5 -0
  12. data/lib/racob-x64.dll +0 -0
  13. data/lib/racob-x86.dll +0 -0
  14. data/lib/racob.jar +0 -0
  15. data/lib/win32ole/utils.rb +230 -0
  16. data/lib/win32ole/win32ole.jar +0 -0
  17. data/lib/win32ole/win32ole_error.rb +13 -0
  18. data/lib/win32ole/win32ole_event.rb +38 -0
  19. data/lib/win32ole/win32ole_method.rb +135 -0
  20. data/lib/win32ole/win32ole_param.rb +45 -0
  21. data/lib/win32ole/win32ole_ruby.rb +115 -0
  22. data/lib/win32ole/win32ole_type.rb +148 -0
  23. data/lib/win32ole/win32ole_typelib.rb +76 -0
  24. data/lib/win32ole/win32ole_variable.rb +41 -0
  25. data/lib/win32ole/win32ole_variant.rb +52 -0
  26. data/nbproject/build-impl.xml +800 -0
  27. data/nbproject/genfiles.properties +8 -0
  28. data/nbproject/private/config.properties +0 -0
  29. data/nbproject/private/private.properties +8 -0
  30. data/nbproject/private/private.xml +4 -0
  31. data/nbproject/project.properties +71 -0
  32. data/nbproject/project.xml +14 -0
  33. data/samples/browser_connect.rb +10 -0
  34. data/samples/const_load.rb +10 -0
  35. data/samples/dir_enum_bench.rb +24 -0
  36. data/samples/dispatch_bench.rb +44 -0
  37. data/samples/file_system_object.rb +7 -0
  38. data/samples/fs.rb +50 -0
  39. data/samples/ie_plus_events.rb +45 -0
  40. data/samples/ie_simple.rb +20 -0
  41. data/samples/ie_simple_clsid.rb +13 -0
  42. data/samples/sbem.rb +11 -0
  43. data/samples/small_enum_bench.rb +126 -0
  44. data/src/org/jruby/ext/win32ole/RubyInvocationProxy.java +34 -0
  45. data/src/org/jruby/ext/win32ole/RubyWIN32OLE.java +278 -0
  46. data/src/win32ole/Win32oleService.java +29 -0
  47. metadata +113 -0
@@ -0,0 +1,8 @@
1
+ build.xml.data.CRC32=62bdc89d
2
+ build.xml.script.CRC32=a38de9f7
3
+ build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45
4
+ # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5
+ # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6
+ nbproject/build-impl.xml.data.CRC32=62bdc89d
7
+ nbproject/build-impl.xml.script.CRC32=ebc43312
8
+ nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45
File without changes
@@ -0,0 +1,8 @@
1
+ compile.on.save=true
2
+ do.depend=false
3
+ do.jar=true
4
+ file.reference.jrwin32ole-lib=C:\\opt\\jruby-win32ole\\lib
5
+ file.reference.jrwin32ole-src=C:\\opt\\jruby-win32ole\\src
6
+ javac.debug=true
7
+ javadoc.preview=true
8
+ user.properties.file=C:\\Documents and Settings\\Fuebo\\.netbeans\\6.8\\build.properties
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project-private xmlns="http://www.netbeans.org/ns/project-private/1">
3
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
4
+ </project-private>
@@ -0,0 +1,71 @@
1
+ application.title=win32ole
2
+ application.vendor=Fuebo
3
+ build.classes.dir=${build.dir}/classes
4
+ build.classes.excludes=**/*.java,**/*.form
5
+ # This directory is removed when the project is cleaned:
6
+ build.dir=build
7
+ build.generated.dir=${build.dir}/generated
8
+ build.generated.sources.dir=${build.dir}/generated-sources
9
+ # Only compile against the classpath explicitly listed here:
10
+ build.sysclasspath=ignore
11
+ build.test.classes.dir=${build.dir}/test/classes
12
+ build.test.results.dir=${build.dir}/test/results
13
+ # Uncomment to specify the preferred debugger connection transport:
14
+ #debug.transport=dt_socket
15
+ debug.classpath=\
16
+ ${run.classpath}
17
+ debug.test.classpath=\
18
+ ${run.test.classpath}
19
+ # This directory is removed when the project is cleaned:
20
+ dist.dir=dist
21
+ dist.jar=${dist.dir}/win32ole.jar
22
+ dist.javadoc.dir=${dist.dir}/javadoc
23
+ endorsed.classpath=
24
+ excludes=**.dll
25
+ file.reference.jruby.jar=../../jruby-1.5.1/lib/jruby.jar
26
+ file.reference.jrwin32ole-lib=lib
27
+ file.reference.jrwin32ole-src=src
28
+ file.reference.racob.jar=lib/racob.jar
29
+ includes=**
30
+ jar.compress=false
31
+ javac.classpath=\
32
+ ${file.reference.jruby.jar}:\
33
+ ${file.reference.racob.jar}
34
+ # Space-separated list of extra javac options
35
+ javac.compilerargs=
36
+ javac.deprecation=false
37
+ javac.source=1.5
38
+ javac.target=1.5
39
+ javac.test.classpath=\
40
+ ${javac.classpath}:\
41
+ ${build.classes.dir}:\
42
+ ${libs.junit.classpath}:\
43
+ ${libs.junit_4.classpath}
44
+ javadoc.additionalparam=
45
+ javadoc.author=false
46
+ javadoc.encoding=${source.encoding}
47
+ javadoc.noindex=false
48
+ javadoc.nonavbar=false
49
+ javadoc.notree=false
50
+ javadoc.private=false
51
+ javadoc.splitindex=true
52
+ javadoc.use=true
53
+ javadoc.version=false
54
+ javadoc.windowtitle=
55
+ main.class=
56
+ manifest.file=manifest.mf
57
+ meta.inf.dir=${src.dir}/META-INF
58
+ platform.active=default_platform
59
+ run.classpath=\
60
+ ${javac.classpath}:\
61
+ ${build.classes.dir}
62
+ # Space-separated list of JVM arguments used when running the project
63
+ # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
64
+ # or test-sys-prop.name=value to set system properties for unit tests):
65
+ run.jvmargs=
66
+ run.test.classpath=\
67
+ ${javac.test.classpath}:\
68
+ ${build.test.classes.dir}
69
+ source.encoding=UTF-8
70
+ src.dir=${file.reference.jrwin32ole-src}
71
+ src.lib.dir=lib
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://www.netbeans.org/ns/project/1">
3
+ <type>org.netbeans.modules.java.j2seproject</type>
4
+ <configuration>
5
+ <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
6
+ <name>win32ole</name>
7
+ <source-roots>
8
+ <root id="src.lib.dir"/>
9
+ <root id="src.dir"/>
10
+ </source-roots>
11
+ <test-roots/>
12
+ </data>
13
+ </configuration>
14
+ </project>
@@ -0,0 +1,10 @@
1
+ require 'win32ole'
2
+
3
+ # Something tells me this just current browser and not specifically ie
4
+ ie = WIN32OLE.connect '{c08afd90-f2a1-11d1-8455-00a0c91f3880}'
5
+ ie.gohome
6
+ sleep 1
7
+ puts "NAME: #{ie.name}" # Lower-case
8
+ ie.quit
9
+
10
+
@@ -0,0 +1,10 @@
1
+ require 'win32ole'
2
+
3
+ module FOO
4
+ end
5
+
6
+ ie = WIN32OLE.new('InternetExplorer.Application')
7
+ WIN32OLE.const_load(ie, FOO)
8
+ FOO.constants.each do |c|
9
+ puts "#{c}: #{FOO.const_get(c)}"
10
+ end
@@ -0,0 +1,24 @@
1
+ require 'win32ole'
2
+ require 'benchmark'
3
+
4
+ COUNT = (ARGV[0] || 250).to_i
5
+ ITERATIONS = (ARGV[1] || 20).to_i
6
+
7
+ dir = 'C:/opt/test_data'
8
+ fso = WIN32OLE.new('Scripting.FileSystemObject')
9
+ drives = fso.GetFolder(dir).Files
10
+
11
+ total = 0.0
12
+ ITERATIONS.times do
13
+ printf "drives.each #{COUNT} of 120 calls: "
14
+ time = Benchmark.measure {
15
+ COUNT.times do
16
+ drives.each {|d| }
17
+ end
18
+ }
19
+ puts time
20
+ total += time.real
21
+ end
22
+ #sleep 1000
23
+
24
+ puts "Total time = #{total}"
@@ -0,0 +1,44 @@
1
+ require 'win32ole'
2
+ require 'benchmark'
3
+
4
+ COUNT = (ARGV[0] || 250).to_i
5
+ ITERATIONS = (ARGV[1] || 5).to_i
6
+
7
+ ie = WIN32OLE.new('InternetExplorer.Application')
8
+
9
+
10
+ ITERATIONS.times do
11
+ printf "visible+name #{COUNT} of 32 calls: "
12
+ puts Benchmark.measure {
13
+ COUNT.times do
14
+ ie.visible; ie.name; ie.visible; ie.name; ie.visible; ie.name
15
+ ie.visible; ie.name; ie.visible; ie.name; ie.visible; ie.name
16
+ ie.visible; ie.name; ie.visible; ie.name; ie.visible; ie.name
17
+ ie.visible; ie.name; ie.visible; ie.name; ie.visible; ie.name
18
+ ie.visible; ie.name; ie.visible; ie.name; ie.visible; ie.name
19
+ ie.visible; ie.name
20
+ end
21
+ }
22
+
23
+ printf "visible=false #{COUNT} of 32 calls: "
24
+ puts Benchmark.measure {
25
+ COUNT.times do
26
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
27
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
28
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
29
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
30
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
31
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
32
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
33
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
34
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
35
+ ie.Visible = false; ie.Visible = false; ie.Visible = false;
36
+ ie.Visible = false; ie.Visible = false
37
+ end
38
+ }
39
+ end
40
+
41
+ ie.quit
42
+
43
+
44
+
@@ -0,0 +1,7 @@
1
+ require 'win32ole'
2
+
3
+ fso = WIN32OLE.new('Scripting.FileSystemObject')
4
+ folder = fso.GetFolder('C:/')
5
+ folder.SubFolders.each { |file| puts file.Path + '\\' }
6
+ folder.Files.each { |file| puts file.Path }
7
+
data/samples/fs.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'win32ole'
2
+
3
+ def showDriveType(drive)
4
+ case drive.DriveType
5
+ when 1 then # DriveTypeRemovable
6
+ "Removable"
7
+ when 2 then # DriveTypeFixed
8
+ "Fixed"
9
+ when 3 then # DriveTypeNetwork
10
+ "Network"
11
+ when 4 then # DriveTypeCDROM
12
+ "CD-ROM"
13
+ when 5 then # DriveTypeRAMDick
14
+ "RAM Disk"
15
+ else
16
+ "Uknown #{drive.DriveType}"
17
+ end
18
+ end
19
+
20
+ fso = WIN32OLE.new('Scripting.FileSystemObject')
21
+ drives = fso.Drives
22
+
23
+ puts "Number of Drives: #{drives.Count}"
24
+ puts ""
25
+ puts ['' , '', 'Drive', 'File', 'Total', 'Free', 'Avail.', 'Serial'].join("\t")
26
+ puts ['Path', 'Type', 'Ready?', 'Name', 'Space', 'Space', 'Space', 'Number'].join("\t")
27
+ 100.times { printf "-" }
28
+ puts ""
29
+
30
+ drives.each do |drive|
31
+ printf [drive.Path, showDriveType(drive), drive.IsReady].join("\t")
32
+ if drive.IsReady
33
+ if drive.DriveType == 3 # DriveTypeNetwork
34
+ printf "\t#{drive.ShareName}\t"
35
+ else
36
+ printf "\t#{drive.VolumeName}\t"
37
+ end
38
+ printf [drive.FileSystem, drive.TotalSize, drive.FreeSpace, drive.AvailableSpace, drive.SerialNumber].join("\t")
39
+ end
40
+ puts ""
41
+ end
42
+
43
+ dir = 'C:/opt'
44
+ puts ""
45
+ puts "#{dir} contents"
46
+ folder = fso.GetFolder(dir)
47
+ folder.files.each do |file|
48
+ puts file
49
+ end
50
+
@@ -0,0 +1,45 @@
1
+ require 'win32ole'
2
+
3
+
4
+ $urls = []
5
+
6
+
7
+ def navigate(url)
8
+ $urls << url
9
+ end
10
+
11
+
12
+ def stop_msg_loop
13
+ puts "IE has exited..."
14
+ $done = true
15
+ end
16
+
17
+
18
+ def default_handler(event, *args)
19
+ case event
20
+ when "BeforeNavigate"
21
+ puts "Now Navigating to #{args[0]}..."
22
+ end
23
+ end
24
+
25
+
26
+ ie = WIN32OLE.new('InternetExplorer.Application')
27
+ ie.visible = TRUE
28
+ ie.gohome
29
+ ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
30
+
31
+
32
+ ev.on_event {|*args| default_handler(*args)}
33
+ ev.on_event("NavigateComplete2") {|obj, url| navigate(url)}
34
+ ev.on_event("OnQuit") {|*args| stop_msg_loop}
35
+
36
+
37
+ while !$done do
38
+ WIN32OLE_EVENT.message_loop
39
+ sleep 0.5
40
+ end
41
+
42
+ puts "You Navigated to the following URLs: "
43
+ $urls.each_with_index do |url, i|
44
+ puts "(#{i+1}) #{url}"
45
+ end
@@ -0,0 +1,20 @@
1
+ require 'win32ole'
2
+
3
+ ie = WIN32OLE.new('InternetExplorer.Application')
4
+ vis = ie.ole_method_help('Visible')
5
+ puts "VISIBLE: #{ie.visible}"
6
+ puts "VISIBLE w/ []: #{ie['Visible']}"
7
+ puts "VISIBLE w/ Invoke: #{ie.invoke('Visible')}"
8
+ ie._setproperty(vis.dispid, [true], [true])
9
+ ie.Visible = TRUE # Upper-case
10
+ puts "VISIBLE: #{ie.visible}"
11
+ sleep 4
12
+ ie['Visible'] = false
13
+ puts "VISIBLE: #{ie.visible}"
14
+ #puts ie.ole_methods
15
+ ie.gohome
16
+ puts "NAME: #{ie.name}" # Lower-case
17
+ ie.quit
18
+
19
+
20
+
@@ -0,0 +1,13 @@
1
+ require 'win32ole'
2
+
3
+ # Something tells me this just current browser and not specifically ie
4
+ ie = WIN32OLE.new '{c08afd90-f2a1-11d1-8455-00a0c91f3880}'
5
+ puts "VISIBLE: #{ie.visible}"
6
+ ie.Visible = TRUE # Upper-case
7
+ puts "VISIBLE: #{ie.visible}"
8
+ sleep 1
9
+ #ie.gohome
10
+ puts "NAME: #{ie.name}" # Lower-case
11
+ ie.quit
12
+
13
+
data/samples/sbem.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'win32ole'
2
+
3
+ VALUES = ['CategoryString', 'Message', 'TimeGenerated', 'User', 'Type']
4
+ query = "select #{VALUES.join(',')} from Win32_NtLogEvent where Logfile = 'Application' and TimeGenerated > '20100713000000.000000-***'"
5
+
6
+ wmi = WIN32OLE.new "WbemScripting.SWbemLocator"
7
+ connection = wmi.connectserver
8
+ connection.ExecQuery(query).each do |result|
9
+ puts VALUES.map { |v| "#{v}: #{result.__send__(v).to_s}" }.join(", ")
10
+ end
11
+
@@ -0,0 +1,126 @@
1
+ require 'win32ole'
2
+ require 'benchmark'
3
+
4
+ COUNT = (ARGV[0] || 250).to_i
5
+ ITERATIONS = (ARGV[1] || 20).to_i
6
+
7
+ fso = WIN32OLE.new('Scripting.FileSystemObject')
8
+ drives = fso.Drives
9
+
10
+ total = 0.0
11
+ ITERATIONS.times do
12
+ printf "drives.each #{COUNT} of 120 calls: "
13
+ time = Benchmark.measure {
14
+ COUNT.times do
15
+ drives.each {|d| }
16
+ drives.each {|d| }
17
+ drives.each {|d| }
18
+ drives.each {|d| }
19
+ drives.each {|d| }
20
+ drives.each {|d| }
21
+ drives.each {|d| }
22
+ drives.each {|d| }
23
+ drives.each {|d| }
24
+ drives.each {|d| }
25
+ drives.each {|d| }
26
+ drives.each {|d| }
27
+ drives.each {|d| }
28
+ drives.each {|d| }
29
+ drives.each {|d| }
30
+ drives.each {|d| }
31
+ drives.each {|d| }
32
+ drives.each {|d| }
33
+ drives.each {|d| }
34
+ drives.each {|d| }
35
+ drives.each {|d| }
36
+ drives.each {|d| }
37
+ drives.each {|d| }
38
+ drives.each {|d| }
39
+ drives.each {|d| }
40
+ drives.each {|d| }
41
+ drives.each {|d| }
42
+ drives.each {|d| }
43
+ drives.each {|d| }
44
+ drives.each {|d| }
45
+ drives.each {|d| }
46
+ drives.each {|d| }
47
+ drives.each {|d| }
48
+ drives.each {|d| }
49
+ drives.each {|d| }
50
+ drives.each {|d| }
51
+ drives.each {|d| }
52
+ drives.each {|d| }
53
+ drives.each {|d| }
54
+ drives.each {|d| }
55
+ drives.each {|d| }
56
+ drives.each {|d| }
57
+ drives.each {|d| }
58
+ drives.each {|d| }
59
+ drives.each {|d| }
60
+ drives.each {|d| }
61
+ drives.each {|d| }
62
+ drives.each {|d| }
63
+ drives.each {|d| }
64
+ drives.each {|d| }
65
+ drives.each {|d| }
66
+ drives.each {|d| }
67
+ drives.each {|d| }
68
+ drives.each {|d| }
69
+ drives.each {|d| }
70
+ drives.each {|d| }
71
+ drives.each {|d| }
72
+ drives.each {|d| }
73
+ drives.each {|d| }
74
+ drives.each {|d| }
75
+ drives.each {|d| }
76
+ drives.each {|d| }
77
+ drives.each {|d| }
78
+ drives.each {|d| }
79
+ drives.each {|d| }
80
+ drives.each {|d| }
81
+ drives.each {|d| }
82
+ drives.each {|d| }
83
+ drives.each {|d| }
84
+ drives.each {|d| }
85
+ drives.each {|d| }
86
+ drives.each {|d| }
87
+ drives.each {|d| }
88
+ drives.each {|d| }
89
+ drives.each {|d| }
90
+ drives.each {|d| }
91
+ drives.each {|d| }
92
+ drives.each {|d| }
93
+ drives.each {|d| }
94
+ drives.each {|d| }
95
+ drives.each {|d| }
96
+ drives.each {|d| }
97
+ drives.each {|d| }
98
+ drives.each {|d| }
99
+ drives.each {|d| }
100
+ drives.each {|d| }
101
+ drives.each {|d| }
102
+ drives.each {|d| }
103
+ drives.each {|d| }
104
+ drives.each {|d| }
105
+ drives.each {|d| }
106
+ drives.each {|d| }
107
+ drives.each {|d| }
108
+ drives.each {|d| }
109
+ drives.each {|d| }
110
+ drives.each {|d| }
111
+ drives.each {|d| }
112
+ drives.each {|d| }
113
+ drives.each {|d| }
114
+ drives.each {|d| }
115
+ drives.each {|d| }
116
+ drives.each {|d| }
117
+ drives.each {|d| }
118
+ drives.each {|d| }
119
+ drives.each {|d| }
120
+ end
121
+ }
122
+ puts time
123
+ total += time.real
124
+ end
125
+
126
+ puts "Total time = #{total}"