# Win32ole

**URL:** <https://www.ruby-forum.com/t/win32ole/109166>\
**Category:** Ruby\
**Created:** [July 12, 2007, 1:56am UTC](https://www.ruby-forum.com/t/win32ole/109166 "2007-07-12T01:56:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AgustSSS\_n\_Ramos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@AgustSSS\_n\_Ramos](https://www.ruby-forum.com/u/AgustSSS_n_Ramos)\
**Post date:** [July 12, 2007, 1:56am UTC](https://www.ruby-forum.com/t/win32ole/109166/1 "2007-07-12T01:56:02Z")

</div>

Hi everybody, i´m trying to manage the mouse with Ruby. Like move it in  
the  
Desktop, clicking de Start button, like a macro.

Well, i would like to recive some information about that.

Thanks!

---

<div class="post-metadata">

**Author:** ![AgustSSS\_n\_Ramos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@AgustSSS\_n\_Ramos](https://www.ruby-forum.com/u/AgustSSS_n_Ramos)\
**Post date:** [July 12, 2007, 4:05am UTC](https://www.ruby-forum.com/t/win32ole/109166/2 "2007-07-12T04:05:52Z")

</div>

AgustÃ­n Ramos wrote:

> Hi everybody, i?m trying to manage the mouse with Ruby. Like move it in  
> the  
> Desktop, clicking de Start button, like a macro.
> 
> Well, i would like to recive some information about that.
> 
> Thanks!

I’m fairly new to to win32ole myself, but I see it as more of a “ole”  
interface (hence the name) than a “programming interface” (aka, API, as  
in WIN32API).

Perhaps WIN32API is what you are searching for.

Now, certain applications that you might “new up” with WIN32OLE have  
functions, like Excel has “sendleys()” where you can mimis keystokes.  
Perhaps that is what you want to do.

They also have events, and you can set up event handlers. Study the  
Object Model of the windows application you want to drive.

What I have found is this:

IF I knew the Object Model for the application I wanted to drive with  
Ruby,  
THEN actual implementation is pretty straight forward.  
ELSE, without knowing the object model, you’ll find youself staring at  
the screen.

Todd

---

<div class="post-metadata">

**Author:** ![AgustSSS\_n\_Ramos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@AgustSSS\_n\_Ramos](https://www.ruby-forum.com/u/AgustSSS_n_Ramos)\
**Post date:** [July 12, 2007, 5:41am UTC](https://www.ruby-forum.com/t/win32ole/109166/3 "2007-07-12T05:41:16Z")

</div>

> Hi everybody, i´m trying to manage the mouse with Ruby. Like move it in the  
> Desktop, clicking de Start button, like a macro.
> 
> Well, i would like to recive some information about that.

You can move and click the mouse with AutoIt.  
Try playing around with this code to get you started.  
Use carefully.

require ‘win32ole’  
mytest = WIN32OLE.new(“AutoItX3.Control”)

mytest.MouseMove(150,440)  
sleep 1  
#mytest.MouseDown(“Left”)  
#mytest.MouseUp(“Left”)  
mytest.MouseMove(250,240)  
sleep 1  
mytest.MouseMove(350,340)

Harry

---

<div class="post-metadata">

**Author:** ![AgustSSS\_n\_Ramos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@AgustSSS\_n\_Ramos](https://www.ruby-forum.com/u/AgustSSS_n_Ramos)\
**Post date:** [July 12, 2007, 4:06pm UTC](https://www.ruby-forum.com/t/win32ole/109166/4 "2007-07-12T16:06:20Z")

</div>

On Jul 11, 11:39 pm, “Harry K.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> mytest = WIN32OLE.new(“AutoItX3.Control”)
> 
> –  
> A Look into Japanese Ruby List in Englishhttp://www.kakueki.com/

Here’s a link to the AutoIt website ([http://www.autoitscript.com/](http://www.autoitscript.com/)  
autoit3/index.php) where you can download the program. This is a handy  
utility for sure. I script it with Ruby for doing lots of monotonous  
keyboard entry in old DOS programs that I have shelling out after  
hours. I just pick up the DOS box’s window title and then go to town!
