sleipnir-api 0.4.0 → 0.4.1
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/History.txt +8 -0
- data/README.txt +6 -5
- data/examples/command_list.rb +5 -3
- data/examples/screenshot.rb +9 -6
- data/lib/sleipnir_api/ffi/user32.rb +15 -2
- data/lib/sleipnir_api/screen_captor.rb +0 -1
- data/lib/sleipnir_api/sleipnir.rb +2 -0
- data/lib/sleipnir_api/tab.rb +1 -1
- data/lib/sleipnir_api/version.rb +1 -1
- data/spec/sleipnir_api/ffi_spec.rb +4 -2
- metadata +2 -2
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -32,12 +32,13 @@ sleipnir-api は _grepnir_ コマンドが付属しています。
|
|
32
32
|
|
33
33
|
=== INSTALL
|
34
34
|
|
35
|
-
[
|
36
|
-
|
37
|
-
|
38
|
-
[Windows]
|
35
|
+
[gem 派]
|
36
|
+
以下のコマンドでインストール。
|
39
37
|
gem install sleipnir-api
|
40
|
-
|
38
|
+
[非 gem 派]
|
39
|
+
{プロジェクトページ}[http://rubyforge.org/projects/sleipnir-api] から
|
40
|
+
アーカイブをダウンロード・展開して以下のコマンドでインストール。
|
41
|
+
ruby setup.rb
|
41
42
|
|
42
43
|
=== CAVEATS
|
43
44
|
|
data/examples/command_list.rb
CHANGED
@@ -80,15 +80,17 @@ __END__
|
|
80
80
|
|
81
81
|
function setup_event() {
|
82
82
|
var input = document.getElementById("search");
|
83
|
+
var init_value = "Search...";
|
84
|
+
input.value = init_value;
|
83
85
|
input.onfocus = function() {
|
84
|
-
if (input.value ==
|
86
|
+
if (input.value == init_value) {
|
85
87
|
input.value = "";
|
86
88
|
input.style.color = "black";
|
87
89
|
}
|
88
90
|
};
|
89
91
|
input.onblur = function() {
|
90
92
|
if (input.value == "") {
|
91
|
-
input.value =
|
93
|
+
input.value = init_value;
|
92
94
|
input.style.color = "#393f4c";
|
93
95
|
}
|
94
96
|
};
|
@@ -116,7 +118,7 @@ __END__
|
|
116
118
|
<p>Sleipnir 1.66 �p�ł��B2.x �� ExecCommand ���T�|�[�g���Ă��܂���B</p>
|
117
119
|
|
118
120
|
<form id="search_box">
|
119
|
-
<input accesskey="a" id="search" value="
|
121
|
+
<input accesskey="a" id="search" value=""/>
|
120
122
|
</form>
|
121
123
|
|
122
124
|
<table style="width: 100%">
|
data/examples/screenshot.rb
CHANGED
@@ -9,22 +9,25 @@ pnir = SleipnirAPI.connect
|
|
9
9
|
|
10
10
|
worker = ARGV.collect {|url|
|
11
11
|
Thread.start {
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
unless url =~ /[a-z]+:\/\//
|
13
|
+
url = "file://#{File.expand_path(url)}"
|
14
|
+
end
|
15
|
+
tab, new = lock.synchronize {
|
16
|
+
if r = pnir.get_url_tab(url)
|
17
|
+
[r, false]
|
15
18
|
else
|
16
|
-
pnir.
|
19
|
+
[pnir.open(url), true]
|
17
20
|
end
|
18
21
|
}
|
19
22
|
sleep 0.1 while tab.busy?
|
20
|
-
sleep
|
23
|
+
sleep 5 # �ꉞ
|
21
24
|
lock.synchronize {
|
22
25
|
digest = Digest::MD5.hexdigest(url)
|
23
26
|
filename = "#{digest}.bmp"
|
24
27
|
puts "#{url} => #{filename}"
|
25
28
|
tab.capture_page(filename)
|
26
29
|
}
|
27
|
-
tab.close
|
30
|
+
tab.close if new
|
28
31
|
}
|
29
32
|
}
|
30
33
|
|
@@ -9,6 +9,7 @@ module SleipnirAPI::FFI
|
|
9
9
|
GW_HWNDNEXT = 2
|
10
10
|
GW_HWNDPREV = 3
|
11
11
|
|
12
|
+
define_ffi_entry(:GetClassName, 'LPI', 'I', 'user32', "GetClassNameA")
|
12
13
|
define_ffi_entry(:GetWindowThreadProcessId, "LP", "L", "user32")
|
13
14
|
define_ffi_entry(:GetDC, 'L', 'L', 'user32')
|
14
15
|
define_ffi_entry(:GetWindowDC, 'L', 'L', 'user32')
|
@@ -25,9 +26,16 @@ module SleipnirAPI::FFI
|
|
25
26
|
|
26
27
|
module_function
|
27
28
|
|
29
|
+
def get_class_name(hwnd)
|
30
|
+
buf = "\0" * 255
|
31
|
+
r = GetClassName(hwnd, buf, buf.length)
|
32
|
+
raise Win32APIError, "GetClassName failed" if r.nil? or r.zero?
|
33
|
+
buf[0...r]
|
34
|
+
end
|
35
|
+
|
28
36
|
def get_window_thread_process_id(hwnd)
|
29
|
-
n =
|
30
|
-
th = GetWindowThreadProcessId
|
37
|
+
n = [0].pack("L")
|
38
|
+
th = GetWindowThreadProcessId(hwnd, n)
|
31
39
|
return [th, n.unpack("L")[0]]
|
32
40
|
end
|
33
41
|
|
@@ -112,5 +120,10 @@ module SleipnirAPI::FFI
|
|
112
120
|
r
|
113
121
|
end
|
114
122
|
|
123
|
+
def find_child_window_by_classname(root_hwnd, classname)
|
124
|
+
w = list_window(root_hwnd).flatten
|
125
|
+
w.find{|e| get_class_name(e) == classname}
|
126
|
+
end
|
127
|
+
|
115
128
|
end
|
116
129
|
end
|
data/lib/sleipnir_api/tab.rb
CHANGED
@@ -54,7 +54,7 @@ module SleipnirAPI
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def find_embedding_ie_hwnd #:nodoc:
|
57
|
-
SleipnirAPI::FFI::User32.
|
57
|
+
SleipnirAPI::FFI::User32.find_child_window_by_classname(sleipnir_ieview_hwnd, "Internet Explorer_Server")
|
58
58
|
end
|
59
59
|
|
60
60
|
# call-seq:
|
data/lib/sleipnir_api/version.rb
CHANGED
@@ -7,7 +7,9 @@ describe SleipnirAPI::FFI::Kernel32 do
|
|
7
7
|
SleipnirAPI::FFI::Kernel32.should respond_to(:get_long_path_name)
|
8
8
|
|
9
9
|
Dir.chdir(File.dirname(__FILE__)) do
|
10
|
-
|
10
|
+
long = "dialog_mock_spec.rb"
|
11
|
+
short = `dir /x`[/\s+(\S+)\s+#{long}$/, 1]
|
12
|
+
SleipnirAPI::FFI::Kernel32.get_long_path_name(short).should == long
|
11
13
|
SleipnirAPI::FFI::Kernel32.get_long_path_name("ffi_spec.rb").should == "ffi_spec.rb"
|
12
14
|
SleipnirAPI::FFI::Kernel32.get_long_path_name("no_such_file.rb").should == ""
|
13
15
|
end
|
@@ -23,7 +25,7 @@ describe SleipnirAPI::FFI::User32 do
|
|
23
25
|
wbem = locator.ConnectServer(".")
|
24
26
|
set = wbem.ExecQuery("select * from Win32_Process where Name='Sleipnir.exe'").extend(Enumerable)
|
25
27
|
|
26
|
-
|
28
|
+
SleipnirAPI::FFI::User32::GetWindowThreadProcessId.should be_an_instance_of(::Win32API)
|
27
29
|
thread_id, proc_id = SleipnirAPI::FFI::User32.get_window_thread_process_id(pnir.handle)
|
28
30
|
set.map{|e| e.ProcessId }.should be_include(proc_id)
|
29
31
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: sleipnir-api
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.4.1
|
7
|
+
date: 2007-11-11 00:00:00 +09:00
|
8
8
|
summary: Ruby interface to the Sleipnir.API WIN32OLE object.
|
9
9
|
require_paths:
|
10
10
|
- lib
|