[#39106] What processor do you run ruby on? — "K.Sasada" <ko1@...>

 ささだです。

13 messages 2004/02/09
[#39200] Re: What processor do you run ruby on? — "K.Sasada" <ko1@...> 2004/02/17

"K.Sasada" <ko1@namikilab.tuat.ac.jp> wrote :

[#39207] Re: What processor do you run ruby on? — Isamu KOZUKA <kozuka@...> 2004/02/17

小塚@しなきゃならないテストがいっぱいだ〜....です。

[#39129] InternetExplorer ってインターフェースとして使える? — Shin-ichiro HARA <sinara@...>

原です。

34 messages 2004/02/10
[#39130] Re: InternetExplorer ってインターフェースとして使える? — Yac <yac@...> 2004/02/10

岡です。

[#39136] Re: InternetExplorer ってインターフェースとして使える? — Yac <yac@...> 2004/02/10

岡です。

[#39140] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/11

artonです。別件。

[#39144] Re: InternetExplorer ってインターフェースとして使える? — Shin-ichiro HARA <sinara@...> 2004/02/12

原です。

[#39145] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/12

artonです。

[#39146] Re: InternetExplorer ってインターフェースとして使える? — nobu.nakada@... 2004/02/12

なかだです。

[#39147] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/12

artonです。

[#39150] Re: InternetExplorer ってインターフェースとして使える? — nobu.nakada@... 2004/02/12

なかだです。

[#39151] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/12

artonです。

[#39275] DnD on win32 — Shinichiro HIDA <shinichiro@...>

飛田と申します。

21 messages 2004/02/26
[#39276] Re: DnD on win32 — たむらけんいち <sgs02516@...> 2004/02/26

たむらです。

[#39277] Re: DnD on win32 — Shinichiro HIDA <shinichiro@...> 2004/02/27

飛田です。

[#39278] Re: DnD on win32 — Itou-T15@... 2004/02/27

[#39288] 固有値、固有ベクトルの計算 — Masahiro Sato <msato@...>

19 messages 2004/02/27

[ruby-list:39141] Re: InternetExplorer ってインターフェースとして使える?

From: Shin-ichiro HARA <sinara@...>
Date: 2004-02-11 04:24:37 UTC
List: ruby-list #39141
原です。

> 岡です。
> >ruby から InternetExplorer を立ち上げて、適当なページを見
> >せて、画面上で起こったイベントを何かのメソッドの返値として 
> >ruby に戻すことってできるのでしょうか。
> 
> 私も実はよく理解していないんですが、こんな感じでIEで発生する
> イベントを取り込んだことがあります。
> require 'win32ole'
> def event_handler(event, *args)
>   puts "***** #{event} event fired. ***********"
> end
> ie = WIN32OLE.new('InternetExplorer.Application')
> ie.visible = true
> event = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
> event.on_event {|*args| 
>   event_handler(*args)
> }
> ie.Navigate('http://www.ruby-lang.org/')
> loop do
>   WIN32OLE_EVENT.message_loop
> end

わお。無理かと思っていた。出来るんですね。

こんな風にしてみました。

-----^ test-event.rb
#!/usr/bin/env ruby
require 'win32ole'
require 'cgi'

file = File.expand_path(ARGV.shift)
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
e = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
e.on_event('NavigateComplete'){|*args|
  query = /^[^?]*\??(.*)/.match(args[0]).to_a[1]
  if msg = CGI::parse(query)["text1"][0]
    Thread.start do
      ie.document.getElementById("id1").innerText =
        "#{msg} = #{eval(msg)}"
      ie.document.getElementById("id0").focus
    end
  end
}
puts "IE read \"file://#{file}\""
ie.Navigate("file://#{file}")
sleep 0.1 while ie.readystate != 4
begin
  ie.document.getElementById("id0").focus
  ie.document.getElementById("id0").innerText = 'Math.sqrt(2)'
  loop do
    WIN32OLE_EVENT.message_loop
    sleep 0.05
  end
ensure
  ie.quit
end
-----$ test-event.rb

-----^ test.html
<html>
<head><title>win32ole</title></head>
<body>
<h1>Hello, win32ole!</h1>
<form>
Calc: <input type="text" name="text1" value="" id="id0">
('exit' for quit)
</form>
<pre id="id1"></pre>
</html>
-----$

使い方は

ruby test-event.rb c:/home/sinara/ruby/test.html
                   ^^^^^^ フルパスの方がいいかも

です。リターンを押すたびにリロードするのがちょっと
かっこ悪いですが、結局、IE は、ユーザー・インター
フェースとして使えるか?というと、

  使えそう

ですね。

Windows95 の時代にこれを作っていた助田さんはスゴイ。


In This Thread