sleipnir-api 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ == 0.4.1 / 2007-11-11
2
+
3
+ === Bug fix
4
+
5
+ * SleipnirAPI::Tab
6
+ +capture_page+:: find "Internet Explorer_Server" window properly.
7
+
8
+
1
9
  == 0.4.0 / 2007-10-28
2
10
 
3
11
  === New API:
data/README.txt CHANGED
@@ -32,12 +32,13 @@ sleipnir-api は _grepnir_ コマンドが付属しています。
32
32
 
33
33
  === INSTALL
34
34
 
35
- [Unix]
36
- sudo gem install sleipnir-api
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
 
@@ -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 == "Search...") {
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 = "search";
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="Search..."/>
121
+ <input accesskey="a" id="search" value=""/>
120
122
  </form>
121
123
 
122
124
  <table style="width: 100%">
@@ -9,22 +9,25 @@ pnir = SleipnirAPI.connect
9
9
 
10
10
  worker = ARGV.collect {|url|
11
11
  Thread.start {
12
- tab = lock.synchronize {
13
- if url =~ /[a-z]+:\/\//
14
- pnir.new_tab(url)
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.new_tab("file://#{File.expand_path(url)}")
19
+ [pnir.open(url), true]
17
20
  end
18
21
  }
19
22
  sleep 0.1 while tab.busy?
20
- sleep 1 # �ꉞ
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 = "\0" * 4
30
- th = GetWindowThreadProcessId.call(hwnd, n)
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
@@ -1,4 +1,3 @@
1
- require "timeout"
2
1
  require "sleipnir_api/ffi"
3
2
  require "sleipnir_api/bitmap"
4
3
 
@@ -1,3 +1,5 @@
1
+ require "timeout"
2
+
1
3
  require "sleipnir_api/util"
2
4
  require "sleipnir_api/tab"
3
5
  require "sleipnir_api/output"
@@ -54,7 +54,7 @@ module SleipnirAPI
54
54
  end
55
55
 
56
56
  def find_embedding_ie_hwnd #:nodoc:
57
- SleipnirAPI::FFI::User32.list_window(sleipnir_ieview_hwnd).flatten.last
57
+ SleipnirAPI::FFI::User32.find_child_window_by_classname(sleipnir_ieview_hwnd, "Internet Explorer_Server")
58
58
  end
59
59
 
60
60
  # call-seq:
@@ -2,7 +2,7 @@ module SleipnirAPI
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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
- SleipnirAPI::FFI::Kernel32.get_long_path_name("KEY_ST~2.RB").should == "key_state_mock_spec.rb"
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
- thread_id, proc_id = SleipnirAPI::FFI::User32::GetWindowThreadProcessId.should be_an_instance_of(::Win32API)
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.0
7
- date: 2007-10-27 00:00:00 +09:00
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