On Jan 27, 2008 2:09 PM, Dirk Meijer <hawkman / gelooft.nl> wrote:
> 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 Mullet <david.mullet / gmail.com>:
>
> >
> > 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

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.