Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How to simulate Mouse Click with Ruby, or mouse library

Reply
Thread Tools

How to simulate Mouse Click with Ruby, or mouse library

 
 
Kid Kid
Guest
Posts: n/a
 
      01-24-2007

Hi, I would like to simulate a Mouse click through Ruby. Is there a way
to do this through Ruby? Does Ruby have any library for simulating
mouse events. Can someone provide me with some info on this topic.
Thanks in advance.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Benjohn Barnes
Guest
Posts: n/a
 
      01-24-2007

On 24 Jan 2007, at 22:12, Kid Kid wrote:

>
> Hi, I would like to simulate a Mouse click through Ruby. Is there
> a way
> to do this through Ruby? Does Ruby have any library for simulating
> mouse events. Can someone provide me with some info on this topic.
> Thanks in advance.


I think you'll need to provide a little more info to help people get
started with this one. What GUI environment are you using and trying
to make mouse clicks in?

Cheers,
Benj



 
Reply With Quote
 
 
 
 
Kid Kid
Guest
Posts: n/a
 
      01-24-2007
Thanks for the suggestion Ben, I would like to use ruby to simulate a
mouse click on any general Windows program such as Internet Explorer.
I'm aware that I can use WATIR to automate clicking on elements on the
webpages. However what i'm looking for is the ability to use Ruby to
issue a "Mouse click" no matter where the cursor is or what program is
running.

Thanks,
KidK


Benjohn Barnes wrote:
> On 24 Jan 2007, at 22:12, Kid Kid wrote:
>
>>
>> Hi, I would like to simulate a Mouse click through Ruby. Is there
>> a way
>> to do this through Ruby? Does Ruby have any library for simulating
>> mouse events. Can someone provide me with some info on this topic.
>> Thanks in advance.

>
> I think you'll need to provide a little more info to help people get
> started with this one. What GUI environment are you using and trying
> to make mouse clicks in?
>
> Cheers,
> Benj



--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Marcelo Alvim
Guest
Posts: n/a
 
      01-24-2007
Well, AutoIt is a fine automation program for windows, although it
uses it's own language. But the latest version also provides a DLL to
do this programmatically, so you should be able to interface Ruby with
the DLL and be all set.

Marcelo.

On 1/24/07, Kid Kid <(E-Mail Removed)> wrote:
> Thanks for the suggestion Ben, I would like to use ruby to simulate a
> mouse click on any general Windows program such as Internet Explorer.
> I'm aware that I can use WATIR to automate clicking on elements on the
> webpages. However what i'm looking for is the ability to use Ruby to
> issue a "Mouse click" no matter where the cursor is or what program is
> running.
>
> Thanks,
> KidK
>
>
> Benjohn Barnes wrote:
> > On 24 Jan 2007, at 22:12, Kid Kid wrote:
> >
> >>
> >> Hi, I would like to simulate a Mouse click through Ruby. Is there
> >> a way
> >> to do this through Ruby? Does Ruby have any library for simulating
> >> mouse events. Can someone provide me with some info on this topic.
> >> Thanks in advance.

> >
> > I think you'll need to provide a little more info to help people get
> > started with this one. What GUI environment are you using and trying
> > to make mouse clicks in?
> >
> > Cheers,
> > Benj

>
>
> --
> Posted via http://www.ruby-forum.com/.
>
>


 
Reply With Quote
 
Kid Kid
Guest
Posts: n/a
 
      01-24-2007

Thanks for the help Marcelo. Using AutoIt through Ruby does exactly what
I needed. Thanks!


Marcelo Alvim wrote:
> Well, AutoIt is a fine automation program for windows, although it
> uses it's own language. But the latest version also provides a DLL to
> do this programmatically, so you should be able to interface Ruby with
> the DLL and be all set.
>
> Marcelo.



--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Chad Brewbaker
Guest
Posts: n/a
 
      05-08-2007
Kid Kid wrote:
>
> Hi, I would like to simulate a Mouse click through Ruby. Is there a way
> to do this through Ruby? Does Ruby have any library for simulating
> mouse events. Can someone provide me with some info on this topic.
> Thanks in advance.


KLUDGE:
Write a ruby script that outputs this to a file named Bot.java, runs
javac, then runs the JVM:

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
class Bot {
public static void main(String[] args) {
try {
Robot robot = new Robot();
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} catch (AWTException e) {
e.printStackTrace();
}
}
}

Less of a kludge: Find how java.awt.Robot is implemented in C now that
Sun has relased Java as open source.

I hope mouse functionality is part of the standard library in Ruby2.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
brenton.leanhardt@gmail.com
Guest
Posts: n/a
 
      05-08-2007
On May 8, 2:44 am, Chad Brewbaker <(E-Mail Removed)> wrote:
> Kid Kid wrote:
>
> > Hi, I would like to simulate a Mouse click through Ruby. Is there a way
> > to do this through Ruby? Does Ruby have any library for simulating
> > mouse events. Can someone provide me with some info on this topic.
> > Thanks in advance.

>
> KLUDGE:
> Write a ruby script that outputs this to a file named Bot.java, runs
> javac, then runs the JVM:
>
> import java.awt.AWTException;
> import java.awt.Robot;
> import java.awt.event.InputEvent;
> import java.awt.event.KeyEvent;
> class Bot {
> public static void main(String[] args) {
> try {
> Robot robot = new Robot();
> robot.mousePress(InputEvent.BUTTON1_MASK);
> robot.mouseRelease(InputEvent.BUTTON1_MASK);
> } catch (AWTException e) {
> e.printStackTrace();
> }
> }
>
> }
>
> Less of a kludge: Find how java.awt.Robot is implemented in C now that
> Sun has relased Java as open source.
>
> I hope mouse functionality is part of the standard library in Ruby2.
>
> --
> Posted viahttp://www.ruby-forum.com/.


I would imagine you could use
> public static void main(String[] args) {
> try {
> Robot robot = new Robot();
> robot.mousePress(InputEvent.BUTTON1_MASK);
> robot.mouseRelease(InputEvent.BUTTON1_MASK);
> } catch (AWTException e) {
> e.printStackTrace();
> }
> }
>
> }
>
> Less of a kludge: Find how java.awt.Robot is implemented in C now that
> Sun has relased Java as open source.
>
> I hope mouse functionality is part of the standard library in Ruby2.
>
> --
> Posted viahttp://www.ruby-forum.com/.


I would imagine you could use the Robot class from jruby, though I
don't know if jruby is an option in KidK's case.

--Brenton

 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Simulate button click on Return key press Dan ASP .Net 7 05-18-2009 03:44 PM
This code requires the user 2 click the mouse twice, how do i do itin just one mouse-click? Daniish Javascript 2 06-13-2008 08:41 PM
simulate button click xzzy ASP .Net 7 12-03-2005 07:25 PM
simulate button click in C# =?Utf-8?B?TWF4?= ASP .Net 5 04-06-2004 08:35 AM



Advertisments