Forum: Ruby Keyboard access

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Harry (Guest)
on 2006-04-02 12:41
(Received via mailing list)
How can I gain access to the keyboard so that I can feed output from
my ruby program into an application that only accepts input via the
keyboard?

I want the application to think the input is coming from the keyboard
when it is really coming from a ruby program output.

Thanks for any help.
Harry (Guest)
on 2006-04-02 12:53
(Received via mailing list)
I am using Windows2000.
David V. (Guest)
on 2006-04-02 19:03
(Received via mailing list)
DÅ?a Nedeľa 02 Apríl 2006 10:39 Harry napísal:
> How can I gain access to the keyboard so that I can feed output from
> my ruby program into an application that only accepts input via the
> keyboard?
>
> I want the application to think the input is coming from the keyboard
> when it is really coming from a ruby program output.
>
> Thanks for any help.

Is it a console or window application?

In the former case, a simple pipe should suffice, in the latter, you're
probably looking at using OLE to run the application from within Ruby
and
fake keypresses using the Windows Scripting Host facilities.

David V.
Probably Wrong
James B. (Guest)
on 2006-04-02 19:35
(Received via mailing list)
Harry wrote:
> I am using Windows2000.

Go grab AutoItX, and script it from Ruby.

   require 'win32ole'
   app_window_title  = "The App I Want To Type Into"
   @au3 = WIN32OLE.new("AutoItX3.Control")
   @au3.opt("WinTextMatchMode", 2)
   @au3.Run( "C:\\Program Files\\SomeApp.exe" )
   @au3.WinWaitActive( app_window_title  )
   @au3.Send( "Some text to type to the application" )


--
James B.

http://web2.0validator.com    - We're the Dot in Web 2.0
http://refreshingcities.org   - Design, technology, usability
http://yourelevatorpitch.com  - Finding Business Focus
http://www.jamesbritt.com     - Playing with Better Toys
Harry (Guest)
on 2006-04-03 13:56
(Received via mailing list)
I neglected to say that it is a windows application.
OLE was the answer.

Thanks for your help.
Harry (Guest)
on 2006-04-03 13:59
(Received via mailing list)
That was exactly what I was looking for.
I tried it out Monday morning and it worked.
Excellent!!

Thank you.
This topic is locked and can not be replied to.