Setting Focus on Console Window

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

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.

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

On Mar 11, 11:06 am, Rodrigo B. [email protected]

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