Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Setting Focus on Console Window

Reply
Thread Tools

Setting Focus on Console Window

 
 
Hayato Iriumi
Guest
Posts: n/a
 
      03-10-2008
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
 
Reply With Quote
 
 
 
 
Rodrigo Bermejo
Guest
Posts: n/a
 
      03-11-2008
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/.

 
Reply With Quote
 
 
 
 
Hayato Iriumi
Guest
Posts: n/a
 
      03-25-2008
Ah, that's cool. I never thought of using WSCript.Shell. Thanks!

On Mar 11, 11:06*am, Rodrigo Bermejo <(E-Mail Removed)>
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/.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows: setting title of console window Ethan Furman Python 0 07-30-2011 05:23 PM
window.focus() brings source code into focus Spizzat2 Javascript 2 01-09-2008 03:45 PM
emulating window.focus in Body onload() event and setting focus to a control on same page Jason ASP .Net 4 05-07-2007 05:54 PM
this.window.focus() vs. window.focus() vs. this.focus() Roger Javascript 3 03-08-2007 08:53 PM
Preventing the console window from closing when writing a console program in C++ Miktor C++ 7 08-09-2005 09:22 PM



Advertisments