Close Internet Explorer

Hi,
I’ve got a problem. I want to close any Internet Explorer Window, even those
ruby didn’t open with WIN32OLE.
Does anyone know how to do this?

thanks

I’ve got a problem. I want to close any Internet Explorer Window, even
those
ruby didn’t open with WIN32OLE.
Does anyone know how to do this?

I’m guessing your best bet will be to dive into API calls (see Win32API).
There are routines to enumerate existing windows and get handles to them,
you should be able to shut them down that way.

Sorry I don’t have more specifics, it would take some digging. But hit up
groups.google.com and I’m sure you can find some non-Ruby code to do this.

Chris

“Bass” miner@arcor.de wrote in message news:apn35g$pt9$07$1@news.t-online.com

Hi,
I’ve got a problem. I want to close any Internet Explorer Window, even those
ruby didn’t open with WIN32OLE.
Does anyone know how to do this?

thanks

here is the code I am using (to only close IE windows that I have opened)

require ‘win32ole’

iefrom = WIN32OLE.new(‘InternetExplorer.Application’)
iefrom.visible = true

iefrom.navigate “http://www.yahoo.com
#sleep 2 while @iefrom.Busy == true

iefrom.quit #this is actually what closes the window.

As far as I know, Win32API.so can not support API that uses a
callback procedure such as EnumWindows(). Ruby/DL will be the
better one for his problem.

Ruby/DL – http://www.ruby-lang.org/en/raa-list.rhtml?id=629

require ‘dl’

User32 = DL.dlopen(“user32”)
enum_windows = User32[‘EnumWindows’, ‘IPL’]
post_message = User32[‘PostMessage’, ‘ILILL’]
get_class_name = User32[‘GetClassName’, ‘ILpI’]

name = “IEFrame”
buff = " " * 16
WM_CLOSE = 0x0010
TRUE = 1

enum_windows_proc = DL.callback(‘ILL’) {|hwnd,lparam|
r,rs = get_class_name.call(hwnd, buff, buff.size)
if /^#{name}$/ =~ rs[1].to_s
r,rs = post_message.call(hwnd, WM_CLOSE, 0, 0)
end
TRUE
}

r,rs = enum_windows.call(enum_windows_proc, 0)

···

On Wed, 30 Oct 2002 22:07:21 +0900 “Chris Morris” chrismo@clabs.org wrote:

I’m guessing your best bet will be to dive into API calls (see Win32API).
There are routines to enumerate existing windows and get handles to them,
you should be able to shut them down that way.


Shusaku tsyk@yk.rim.or.jp

At Thu, 31 Oct 2002 16:49:10 +0900,

callback procedure such as EnumWindows(). Ruby/DL will be the
better one for his problem.
Ruby/DL – http://www.ruby-lang.org/en/raa-list.rhtml?id=629

require ‘dl’

In the alternative, we rewrite your code with `dl/import.rb’ as follows.

require ‘dl/import’

module Foo
extend DL::Importable

dlload “user32”

extern “BOOL EnumWindows(void *, long)”
extern “BOOL PostMessage(long, int, long, long)”
extern “BOOL GetClassName(long, void *, int)”

WM_CLOSE = 0x0010

def enum_windows_proc(hwnd, lparam)
buff = DL.malloc(16)
name = “IEFrame”
r = getClassName(hwnd, buff, buff.size)
if /^#{name}$/ =~ buff.to_s
r = postMessage(hwnd, WM_CLOSE, 0, 0)
end
1
end

EnumWindowsProc = callback “int enum_windows_proc(long, long)”
end

Foo.enumWindows(Foo::EnumWindowsProc, 0)

···


Takaaki Tateishi ttate@kt.jaist.ac.jp

callback procedure such as EnumWindows(). Ruby/DL will be the
better one for his problem.
Ruby/DL – http://www.ruby-lang.org/en/raa-list.rhtml?id=629

require ‘dl’

In the alternative, we rewrite your code with `dl/import.rb’ as follows.

require ‘dl/import’

Cool stuff - I didn’t even know about Ruby/DL - thanks for the posts.

Chris

I only have a windows environment. Does anybody know how to install the
Ruby/DL library in Ruby under Windows???

Thanks

“Chris Morris” chrismo@clabs.org wrote in message
news:002d01c281a8$a1411100$22973acc@ntossu2lch…

···

callback procedure such as EnumWindows(). Ruby/DL will be the
better one for his problem.
Ruby/DL – http://www.ruby-lang.org/en/raa-list.rhtml?id=629

require ‘dl’

In the alternative, we rewrite your code with `dl/import.rb’ as follows.

require ‘dl/import’

Cool stuff - I didn’t even know about Ruby/DL - thanks for the posts.

Chris

You can use Ruby 1.7.2 or compile dl/import according to the install
instructions using Visual C++.

···

-----Original Message-----
From: Tom Stone [mailto:miner@arcor.de]
Sent: Friday, November 01, 2002 11:56 AM
To: ruby-talk ML
Subject: Re: Close Internet Explorer

I only have a windows environment. Does anybody know how to install the
Ruby/DL library in Ruby under Windows???

Thanks

“Chris Morris” chrismo@clabs.org wrote in message
news:002d01c281a8$a1411100$22973acc@ntossu2lch…

callback procedure such as EnumWindows(). Ruby/DL will be the
better one for his problem. Ruby/DL –
http://www.ruby-lang.org/en/raa-list.rhtml?id=629

require ‘dl’

In the alternative, we rewrite your code with `dl/import.rb’ as
follows.

require ‘dl/import’

Cool stuff - I didn’t even know about Ruby/DL - thanks for the posts.

Chris

Even if you think i’m dumb, but he asks me for a file named dlfcn.h and
windows.h if i want to create the makefile.
I don’t have much experience in c++.
And i can’t use 1.7.2 because, it’s missing some functions i need.
Do you have suggestions to solve this problem?

“Michael Hale” mhale@rolemodelsoft.com wrote in message
news:001901c281c9$5e071fd0$2a01a8c0@MICHAELS8200…

···

You can use Ruby 1.7.2 or compile dl/import according to the install
instructions using Visual C++.

-----Original Message-----
From: Tom Stone [mailto:miner@arcor.de]
Sent: Friday, November 01, 2002 11:56 AM
To: ruby-talk ML
Subject: Re: Close Internet Explorer

I only have a windows environment. Does anybody know how to install the
Ruby/DL library in Ruby under Windows???

Thanks

“Chris Morris” chrismo@clabs.org wrote in message
news:002d01c281a8$a1411100$22973acc@ntossu2lch…

callback procedure such as EnumWindows(). Ruby/DL will be the
better one for his problem. Ruby/DL –
http://www.ruby-lang.org/en/raa-list.rhtml?id=629

require ‘dl’

In the alternative, we rewrite your code with `dl/import.rb’ as
follows.

require ‘dl/import’

Cool stuff - I didn’t even know about Ruby/DL - thanks for the posts.

Chris

Even if you think i’m dumb, but he asks me for a file named dlfcn.h and
windows.h if i want to create the makefile.
I don’t have much experience in c++.
And i can’t use 1.7.2 because, it’s missing some functions i need.
Do you have suggestions to solve this problem?

I don’t have any suggestions about compiling problem, but
here is a binary package.

http://www.dm4lab.to/~usa/ruby/index_en.html

At the “Extention libraries” section in the above page, you
can find the “Ruby Shim” which include dl.so for ruby 1.6.

···

On Sat, 2 Nov 2002 03:16:07 +0900 “Tom Stone” basti.steiner@gmx.de wrote:

shim-20020912-i586-mswin32-1.6.zip
Ruby Shim 20020912 (for ruby 1.6)


Shusaku tsyk@yk.rim.or.jp

Thanks a lot for the posts. That finally worked.

Shusaku" tsyk@yk.rim.or.jp wrote in message
news:20021102074933.0DDD.TSYK@yk.rim.or.jp…

···

On Sat, 2 Nov 2002 03:16:07 +0900 > “Tom Stone” basti.steiner@gmx.de wrote:

Even if you think i’m dumb, but he asks me for a file named dlfcn.h and
windows.h if i want to create the makefile.
I don’t have much experience in c++.
And i can’t use 1.7.2 because, it’s missing some functions i need.
Do you have suggestions to solve this problem?

I don’t have any suggestions about compiling problem, but
here is a binary package.

http://www.dm4lab.to/~usa/ruby/index_en.html

At the “Extention libraries” section in the above page, you
can find the “Ruby Shim” which include dl.so for ruby 1.6.

shim-20020912-i586-mswin32-1.6.zip
Ruby Shim 20020912 (for ruby 1.6)


Shusaku tsyk@yk.rim.or.jp