How to simulate Mouse Click with Ruby, or mouse library

Discussion in 'Ruby' started by Kid Kid, Jan 24, 2007.

  1. Kid Kid

    Kid Kid Guest

    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/.
     
    Kid Kid, Jan 24, 2007
    #1
    1. Advertising

  2. 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
     
    Benjohn Barnes, Jan 24, 2007
    #2
    1. Advertising

  3. Kid Kid

    Kid Kid Guest

    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/.
     
    Kid Kid, Jan 24, 2007
    #3
  4. 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 <> 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/.
    >
    >
     
    Marcelo Alvim, Jan 24, 2007
    #4
  5. Kid Kid

    Kid Kid Guest

    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/.
     
    Kid Kid, Jan 24, 2007
    #5
  6. 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/.
     
    Chad Brewbaker, May 8, 2007
    #6
  7. Kid Kid

    Guest

    On May 8, 2:44 am, Chad Brewbaker <> 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
     
    , May 8, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davisro
    Replies:
    2
    Views:
    1,353
    Jim Corey
    Apr 23, 2004
  2. =?Utf-8?B?am9qb2Jhcg==?=
    Replies:
    1
    Views:
    4,169
    wwwtar
    Oct 2, 2006
  3. Michael J Whitmore

    Simulate Mouse/Keyboard to stop Screen Saver

    Michael J Whitmore, Nov 6, 2003, in forum: Python
    Replies:
    1
    Views:
    1,378
    Dave Brueck
    Nov 6, 2003
  4. Replies:
    4
    Views:
    365
  5. Daniish
    Replies:
    2
    Views:
    269
    Thomas 'PointedEars' Lahn
    Jun 13, 2008
Loading...

Share This Page