Forum: Ruby windows application automation

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.
Wolfgang (Guest)
on 2006-04-07 22:53
(Received via mailing list)
Hi all,

I wan't to automate some applications which are running on mswin. Is it
somehow possible to "send" key prints to that application? For example
like "control s" for save.

Any suggestions?

Wolfgang
Keith S. (Guest)
on 2006-04-07 23:00
(Received via mailing list)
require 'win32ole' and read up on your favorite OLE browser.

What I've found is that I wind up fighting the (lack of) Ole
documentation as much as anything.

Here's a simple Ruby script I've written to check a mail store via
Mapi for #of new messages and attachments:

require 'win32ole'

mapiSession = WIN32OLE::new('Mapi.Session')
logonParam = "server" + "\n" + "account"
mapiSession.Logon('ProfileInfo' => logonParam)

new_messages = 0
total_messages = 0

mapiSession.Inbox.Messages.each {
    |message|
    begin
        new_messages += 1 if(message['UnRead'])
        total_messages += 1
        puts message['Sender'].Address
        puts message['Subject']
        puts 'Number of Attachments: ' +
message['Attachments'].count.to_s
    end
}

 puts "You have #{new_messages} new message(s)"
 puts "You have #{total_messages} total message(s)"

 mapiSession.Logoff

Was there a particular application(Outlook, Excel, etc?) that you were
hoping to automate?
Wolfgang (Guest)
on 2006-04-07 23:15
(Received via mailing list)
Hello Keith,

I have absolutely no information about OLE object that software uses. It
is a software for a microtomograph and I need to save images every
minute or so. All I would need is to send keyboard shortcuts to do the
task.

Wolfgang

Keith S. schrieb:
Cristi BALAN (Guest)
on 2006-04-08 00:00
(Received via mailing list)
On 4/7/06, Wolfgang <removed_email_address@domain.invalid> wrote:
> Hello Keith,
>
> I have absolutely no information about OLE object that software uses. It
> is a software for a microtomograph and I need to save images every
> minute or so. All I would need is to send keyboard shortcuts to do the task.
>
> Wolfgang
>

You can use the AutoItX com control to automate windows apps.
http://www.autoitscript.com/autoit3/

Try searching the list for autoit, there have been recent posts about
it and some have code samples.
Wolfgang (Guest)
on 2006-04-08 00:13
(Received via mailing list)
Hello Cristi,

that looks really good! Thanks a lot!
Wolfgang

Cristi BALAN schrieb:
This topic is locked and can not be replied to.