Setting Focus on Console Window

Discussion in 'Ruby' started by Hayato Iriumi, Mar 10, 2008.

  1. Hello,
    I'm having an issue with having a focus on the Ruby invoked console
    window on Windows platform when I start the process from one of the
    Scheduled Tasks.

    I have a Ruby script that gets kicked off by Scheduled Task. So the
    Run command looks like this: C:\ruby\bin\ruby.exe D:\Temp\HelloRuby.rb

    Now when I right click on the scheduled task and choose Run, the
    console window doesn't have the focus. I looked for ways to set the
    focus on the console window using kernel32 and stuff, but I haven't
    been able to find a solution.

    Does anyone know how best I can solve this problem?

    TIA
    Hayato Iriumi, Mar 10, 2008
    #1
    1. Advertising

  2. require 'win32ole'
    wsh = WIN32OLE.new('WScript.Shell')
    wsh.AppActivate("name of the window")

    I am not sure I understood your question 100% , but if I am ok with 50%
    It may help you.

    -ronnie.
    --
    Posted via http://www.ruby-forum.com/.
    Rodrigo Bermejo, Mar 11, 2008
    #2
    1. Advertising

  3. Ah, that's cool. I never thought of using WSCript.Shell. Thanks!

    On Mar 11, 11:06 am, Rodrigo Bermejo <>
    wrote:
    > require 'win32ole'
    > wsh = WIN32OLE.new('WScript.Shell')
    > wsh.AppActivate("name of the window")
    >
    > I am not sure I understood your question 100% , but if I am ok with 50%
    > It may help you.
    >
    > -ronnie.
    > --
    > Posted viahttp://www.ruby-forum.com/.
    Hayato Iriumi, Mar 25, 2008
    #3
    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. Miktor
    Replies:
    7
    Views:
    11,996
    Joe Bacigalupa
    Aug 9, 2005
  2. Jason
    Replies:
    4
    Views:
    1,588
    Jason
    May 7, 2007
  3. Ethan Furman

    Windows: setting title of console window

    Ethan Furman, Jul 30, 2011, in forum: Python
    Replies:
    0
    Views:
    386
    Ethan Furman
    Jul 30, 2011
  4. Roger
    Replies:
    3
    Views:
    303
  5. Spizzat2
    Replies:
    2
    Views:
    169
    Spizzat2
    Jan 9, 2008
Loading...

Share This Page