Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > programming a bird -- yes!

Reply
Thread Tools

programming a bird -- yes!

 
 
Gerard A.W. Vreeswijk
Guest
Posts: n/a
 
      07-14-2003
Hello all,

Hi all,

Serious (but possibly less attracting) subject title: Win32ole event loop
with MSAgent.

Thanks to Suketa Masaki for doing such a good job on giving us 'win32ole'.
It relieves us from Microsoft's RSI-stimulating clickfests.

Inspired by Rubytalk 36676, Shusaku <(E-Mail Removed)>:

http://blade.nagaokaut.ac.jp/cgi-bin...uby-list/36676

I decided I wanted to beef up my Agent-app with MSAgent (sorry, Unix):

http://www.microsoft.com/msagent/downloads/user.asp
(download merlin + speech engine + maybe more, depending on your
hardware)

Tried out the script below. All works fine --- as a matter of fact, I
showed one of the characters who happens to be a bird called Peedy to my
4-year old son pronouncing my son's name. He ran down to his mom and said
that a bird talked to him and knew his name

Anyway:
================================================== ====================
#!/usr/bin/ruby
require 'win32ole'

agent = WIN32OLE.new('Agent.Control.1')
agent.Connected = true
agent.Characters.Load("some random string, 'peedy' or so", "peedy.acs")

peedy = agent.Characters("some random string, 'peedy' or so")

# The way we should officialy check when we're done:
ev = WIN32OLE_EVENT.new(agent, nil)
ev.on_event("RequestComplete") { |rRequest|

# rRequest.ole_obj_help.name -> "IAgentCtlRequest"
# rRequest.ole_obj_help.typekind -> 4 ( TKIND_DISPATCH )
# rRequest.ole_obj_help.ole_type -> "Dispatch"
# rRequest.ID -> 197 ( ?? )

if rRequest.ID == $peedySpeak.ID
peedy.Hide # or exit, or move on, or ..
end

}

peedy.Show

# You can program gestures here. Nothing fancy at the moment, just
speak.

$peedySpeak = peedy.Speak <<EOF
Thanks Suketa Masaki, for giving us win32ole!
And thanks Shusaku, for giving us a link between Ruby-win32ole and
MsAgent!
EOF

# speak = peedy.ole_method("Speak") #=> WIN32OLE_METHOD
# speak.return_vtype #=> 26
# speak.return_type #=> "IAgentCtlRequest"
# speak.return_type_detail #=> ["PTR", "USERDEFINED", "IAgentCtlRequest"]


# More mundane check to see when we're done:
loop do
$stderr.puts $peedySpeak.Status
$stderr.flush
# status should become 0 or so, see
#
http://msdn.microsoft.com/library/de...ntrol_3tws.asp
break if $peedySpeak.Status != 2
sleep 1
end

# never get here

================================================== ====================


As you see, the WIN32OLE_EVENT-loop doesn't seem to recognize events,
which is needed to recognize that an action is over.
Also, the "Status" attribute does not work. Status could also be used to
see that an action is over. Currently, Status keeps returning 2's. This
is different from Perl's,

foreach my $animation ($c->AnimationNames)
{
my $request = $c->Play($animation);
$c->Speak($animation);
my $i = 0;
while (($request->Status == 2) || ($request->Status == 4))
{ $c->Stop($request) if $i >10; sleep(1); $i++}
}


where it *does** work (not the events, though). (Thanks, Jouke). See

http://www.cpan.org/modules/by-authors/id/J/JO/JOUKE/

Examined Suketa Masaki "ienavi.rb" example for inspiration. There must be
some "DWebBrowserEvents" event sink identifier for MSAgent as well, but
which??

Thanks.
Gerard



 
Reply With Quote
 
 
 
 
Shusaku
Guest
Posts: n/a
 
      07-14-2003
Hi, Gerard

On Mon, 14 Jul 2003 09:55:35 GMT
http://www.velocityreviews.com/forums/(E-Mail Removed) (Gerard A.W. Vreeswijk) wrote:

> loop do
> $stderr.puts $peedySpeak.Status
> $stderr.flush
> break if $peedySpeak.Status != 2

WIN32OLE_EVENT.message_loop # <== You should insert this!
> sleep 1
> end


Now, the loop would be terminated by 'Status == 4', although it
means "Request in progress". I think the break condition might
be 'Status == 0', which means "Request successfully completed".

--
Shusaku <(E-Mail Removed)>


 
Reply With Quote
 
 
 
 
Shusaku
Guest
Posts: n/a
 
      07-14-2003
I forgot to answer your other question.

On Mon, 14 Jul 2003 09:55:35 GMT
(E-Mail Removed) (Gerard A.W. Vreeswijk) wrote:

> Examined Suketa Masaki "ienavi.rb" example for inspiration. There must be
> some "DWebBrowserEvents" event sink identifier for MSAgent as well, but
> which??


"_AgentEvents" is the one you are looking for.

agent = WIN32OLE.new('Agent.Control.1')
ev = WIN32OLE_EVENT.new(agent, '_AgentEvents')

--
Shusaku <(E-Mail Removed)>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
T'Bird MAil Forwarding as file Peter Arnold Firefox 6 08-04-2004 05:19 PM
My t-bird icon pipe.thread@plumber.fi Firefox 3 05-08-2004 03:54 AM
Proper way to install the Bird & the Fox? @micro$oft.linuxworx Firefox 0 04-25-2004 04:22 AM
To Fly or not to fly? Should I move from Mozilla 1.5 to T-bird andF-bird? Daniel Steinberg Firefox 7 11-06-2003 11:31 AM
To Fly or not to fly? Should I move from Mozilla 1.5 to T-bird andF-bird? Daniel Steinberg Firefox 5 11-05-2003 06:23 AM



Advertisments