win32ole.AppActivate broken in VISTA?

Discussion in 'Ruby' started by Robert Batzinger, Jan 26, 2008.

  1. 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, Jan 26, 2008
    #1
    1. Advertising

  2. Robert Batzinger

    David Mullet Guest

    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
    --
    Posted via http://www.ruby-forum.com/.
    David Mullet, Jan 27, 2008
    #2
    1. Advertising

  3. Robert Batzinger

    Dirk Meijer Guest

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

    2008/1/27, David Mullet <>:
    >
    > 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
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >



    --
    Procrastinate today! (Tomorrow may be too late...)
    Dirk Meijer, Jan 27, 2008
    #3
  4. Robert Batzinger

    Jano Svitok Guest

    On Jan 27, 2008 2:09 PM, Dirk Meijer <> 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 <>:
    >
    > >
    > > 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.
    Jano Svitok, Jan 27, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    850
  2. Michael
    Replies:
    5
    Views:
    890
    Bjoern Schliessmann
    Nov 3, 2007
  3. Replies:
    1
    Views:
    98
    gregarican
    Dec 28, 2005
  4. Masaki Suketa
    Replies:
    4
    Views:
    372
    Dave Burt
    Mar 27, 2006
  5. zxem
    Replies:
    1
    Views:
    225
Loading...

Share This Page