win32ole.AppActivate broken in VISTA?

I have been trying to use the win32ole module on Vista. However, the
AppActivate method always fails regardless of whether simple or
root-relative address are used in the following program. The module
appears to be working well on all other versions of Windows. Does
anyone know the fix to this?

require ‘win32ole’
wsh = WIN32OLE.new(‘Wscript.Shell’)
if wsh.AppActivate(‘notepad’)
print ‘Success’
else
print ‘Fail’
end

BTW Just typing the word notepad works at the DOS prompt and the
WIN32OLE does open the OLE object

================
Bob Batzinger
Arkfriends
South Bend, Indiana

Robert Batzinger wrote:

I have been trying to use the win32ole module on Vista. However, the
AppActivate method always fails regardless of whether simple or
root-relative address are used in the following program. The module
appears to be working well on all other versions of Windows. Does
anyone know the fix to this?

require ‘win32ole’
wsh = WIN32OLE.new(‘Wscript.Shell’)
if wsh.AppActivate(‘notepad’)
print ‘Success’
else
print ‘Fail’
end

BTW Just typing the word notepad works at the DOS prompt and the
WIN32OLE does open the OLE object

================
Bob Batzinger
Arkfriends
South Bend, Indiana

Bob-

For what it’s worth, your code works for me using Ruby 1.8.6 on Windows
Vista Home Premium.

David
http://rubyonwindows.blogspot.com

i’m on vista ultimate, and when notepad’s allready on, it switches to
the
notepad screen and prints “succes”
but when notepad’s not activated, i get a “fail” as well.

2008/1/27, David M. [email protected]:

On Jan 27, 2008 2:09 PM, Dirk M. [email protected] wrote:

root-relative address are used in the following program. The module

BTW Just typing the word notepad works at the DOS prompt and the
WIN32OLE does open the OLE object

http://msdn2.microsoft.com/en-us/library/wzcddbek(VS.85).aspx says
AppActivate searches by window title. That means the app must be
already running.
You might want to use the Run method instead (if you want to start a
new instance of notepad).

Other than that, you may try

  1. checking whether the window title really contains the specified
    string
  2. running the script from another language (.vbs, .wsh, vba, python)

(I’m not an expert on wsh, so please take these as hints only)

J.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs