From: "brenton.leanhardt@..." Date: 2007-05-08T21:45:05+09:00 Subject: Re: How to simulate Mouse Click with Ruby, or mouse library 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