win32ole.AppActivate broken in VISTA?

R

Robert Batzinger

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
 
D

David Mullet

Robert said:
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
 
D

Dirk Meijer

[Note: parts of this message were removed to make it a legal post.]

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.
 
J

Jano Svitok

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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top