Iocane: poison the rodent (simulate X11 mouse events from keyboard)

Iocane: the colorless, oderless, tasteless poision that will rid your system of its rodent infestation.  Though no promises about its effectiveness against Rodents Of Unusual Size.
Iocane simulates mouse events from the keyboard.  Iocane can be passed a few parameters which - ideally - could each have a key binding in your favorite window manager.
If iocane is called with no parameters it starts in interactive mode (which currently lacks documentation ... hey, I just wrote this this morning).  In interactive mode the directional arrows or h/j/k/l keys move the mouse cursor.  The number keys simulate button presses (1 = left button, 2 = middle, 3 = right).  The page up and page down keys simulate mouse wheel activation.  "q" quits from interactive mode returning any grabbed keys to their normal behavior.  Key bindings are all controlled from a simple rc file.
Iocane can also be passed a series of commands on the command line or the filename for a script file with a list of iocane commands.  Iocane can also read command from its standard input.
Iocane is conceptually similar to some functions of xdotool, but iocane should work under any window manager (or no wm at all), is much smaller, and the interactive mode allows for a sequence of many actions without the program having to start up and close down many times in rapid succession.
Please report bugs or feature requests here.  Iocane is currently 127 lines of C, and it will remain small; in other words, features will only be added if the can be added without substantially increasing resource use.
EDIT: Version 0.2 is now in the AUR
Last edited by Trilby (2012-11-03 02:23:15)

Any arbitrary number of buttons should be easy enough to simulate - provided the Xserver actually responds to events with that button number.  An update I'll push to github tomorrow will include a few changes, including buttons 1-9, but if there is need/desire I could increase that.  Sticking to 1-9 allows for the computationally cheaper hack of converting a string to a number by simple substracting 48 from the value of the first character; numbers greater than 9 would require the use of atoi() or some funky conditionals.  In the grand scheme of things this is fairly trivial, but unless there is a real reason to use more than 9 mouse buttons I'd prefer to keep the lighter code.
Passing a window name and getting it's coordinates is possible but after considering it I've decided it wouldn't fit well in iocane.  The reason being that to do a half-arsed job of it would be pretty easy.  To do it properly, however, it would take quite a bit of scanning through recursive calls to XQueryTree, polling atoms/wmhints, matching strings, checking for subwindows in the case of reparenting window managers, and a bunch of other nonsense ... all to get two coordinates.
However iocane will play nicely with any tool that will provide those coordinates from a given window name, so I can imagine and invocation such as the following to move the mouse 10 pixels right and down from the top left of a window - lets call it FlamingSquirrel - and simulate a click there:
iocane $(cool_app FlamingSquirrel) : move 10 10 : button 1
Currently that could only be done from a command line invocation, not from a script or interactive session, as it requires shell processing for the command substitution.  I can add support for this type of invocation in scripts and interactive mode as well.  Then all you need to do is find (or write) a program that will give coordinates for a window given a title/name.  I suspect such a program probably exists out there, or if you are comfortable with C, I could give you the starting framework for it as I made something that would have much code in common for another task on these forums (it's in jumpstart.c in the "misc" repo on my github).
In fact, you could use the following
xdotool mousemove --window FlamingSquirrel 0 0 && iocane offset 10 10 : button 1
Though if you are using xdotool anyways, I'm not sure if iocane would serve much of a purpose, unless you just prefer iocane's syntax.
Last edited by Trilby (2012-11-01 00:21:14)

Similar Messages

  • How to catch the mouse event from the JTable cell of  the DefaultCellEditor

    Hi, my problem is:
    I have a JTable with the cells of DefaultCellEditor(JComboBox) and added the mouse listener to JTable. I can catch the mouse event from any editor cell when this cell didn't be focused. However, when I click the editor to select one JComboBox element, all the mouse events were intercepted by the editor.
    So, how can I catch the mouse event in this case? In other word, even if I do the operation over the editor, I also need to catch the cursor position.
    Any idea will be highly appreciated!
    Thanks in advance!

    Hi, bbritta,
    Thanks very much for your help. Really, your code could run well, but my case is to catch the JComboBox event. So, when I change the JTextField as JComboBox, it still fail to catch the event. The following is my code. Could you give me any other suggestion?
    Also, any one has a good idea for my problem? I look forward to the right solution to this problem.
    Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test3
    extends JFrame {
    // JTextField jtf = new JTextField();
    Object[] as = {"aa","bb","cc","dd"};
    JComboBox box = new JComboBox(as);
    public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    String[] head = {
    "One", "Two", "Three"};
    String[][] data = {
    "R1-C1", "R1-C2", "R1-C3"}
    "R2-C1", "R2-C2", "R2-C3"}
    JTable jt = new JTable(data, head);
    box.addMouseListener(new MouseAdapter() {
    // jtf.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JComboBox mouseclick....");
    jt.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JTable mouseclick....");
    // jt.setDefaultEditor(Object.class, new DefaultCellEditor(jtf));
    jt.setDefaultEditor(Object.class, new DefaultCellEditor(box));
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    setSize(300, 300);
    public static void main(String[] args) {
    new Test3().setVisible(true);
    }

  • Finding Screen Location of the Cursor without a Mouse Event

    How can I find the absolute screen location of the mouse cursor if I do not have a mouse event? I have an application where I need to warp the location of the mouse cursor using the robot class and would like to return the mouse cursor to its original location once I'm done.

    I had similar problem and asked in the forums a while back, basically what I did was to set the mouse to a "Start" position and go from there.
    I know this will not get it back to your current location.

  • How to make the row header of the JTable respond to mouse events?

    Is there an easy way to enable the row header of a JTable so it listens to mouse events? I have put a button in the first cell of the row header but I can't click in it.
    I'm asking for an easy way because I've seen some fairly complicated examples on the web that seem close to what I want but I was hoping something simple like getRowHeader().setEnabled(true) would do the trick for my case...

    What's your row header, another JTable or something else? Check out camickr's [url http://tips4java.wordpress.com/2009/07/12/table-button-column/]Table Button Column.
    db
    edit Or to get better help sooner, post a [url http://mindprod.com/jgloss/sscce.html]SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
    Edited by: Darryl Burke

  • Capturing mouse events from a loaded module.

    I've defined a module and have it to were the mouse
    coordinates (through mouse events) are updating bindable, public
    variables in the module itself.
    In the app parent app (that's loaded the module), i want to
    display the coordinates from the loaded module as it moves around.
    Like I said, I'm close, to where I capture and handle the
    move event in the module itself, I just need to access that info
    from the parent app, etc...
    Any help is appreciated.
    -fd

    not that it matters now, but i figured it out.
    thanks anyway...
    -fd

  • Simulate any mouse click from webview

    How can I simulate any mouse click on any element of the site in webview ? (I have not managed yet to jquery and javascript control 100% of cases)

    http://forum.java.sun.com/thread.jsp?forum=4&thread=191468
    http://forum.java.sun.com/thread.jsp?forum=5&thread=135141
    http://forum.java.sun.com/thread.jsp?forum=54&thread=202069
    http://forum.java.sun.com/thread.jsp?forum=5&thread=11443
    this are some results of search applet browser +close                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • What's the fastest way to signal events from a dll to LabVIEW?

    We have a dll that does some number crunching. We would like to signal events without polling from LabVIEW. I've researched three possible solutions: create a windows message and grab from LabVIEW, turn the dll into an ActiveX control and send events, or put the polling in a subvi running in a separate thread. Any comments about speed or pros/cons on the three approaches will be greatly appreciated.
    Thanks,
    Kurt

    Hi,
    sometime ago we worked with dll in LV and we have found the next effect:
    we loaded the library into memory with some program (not LV). Dll had global variables and we could change them from this program. If we tried to work with this DLL at the same time with LV we could see the changes of this variables (the changes were made with first program).
    I think that windows keeps in the memory only one copy of DLL so you can organize the data exchange between applications using global variables in this DLL. Let your non LV application make some operations and then change variable when the event ocures. And let LV at the same time read this variable from DLL and look if the event has ocured.
    Hope it helps, but I'm not sure, because we saw this effect but didn't use i
    t.
    Oleg Chutko.

  • Passing a string as the name of a Mouse Event Listener function?

    Hello,
    I am trying to essentially pass a string as a function name into an event listener, but I am not sure how to approach this.  Is there a way to convert a string into a function?  I am not sure how to word my question, so I apologize.
    Here is some code I have for me to show you what I am doing.
    package{
         //some import statements
         public class changes extends MovieClip{
              var functionName:String
              var aBox:Sprite;
              public function changes(){
                       functionName = "testThis";
                       createButtonBox(16, 16, 32, 32,  functionName);
              public function createButtonBox(anX:Number, aY:Number, aWidth:Number, aHeight:Number, aFunction:String){
                   aBox = new Sprite();
                   //Some drawing box code
                   aBox.addEventListener(MouseEvent.CLICK,[aFunction]()?)
                   addChild(aBox)
              public function aFunction(event:MouseEvent){
                   trace("test");
    Am I on the right track or is this not possible?
    Anyhow, thank you in advance.

    I guess I misworded my question.  Essentially what I am trying to do is create buttons that have functions called to from an event listener, referenced by a string like this:
    public class Document{
         var functionName:String;
         public function Document(){
                 createAButton("Test Button A", 32, 32, "testThis");
                 createAButton("Test Button B", 64, 64, "testThis2");
         public function createAButton(textOnButton:String, anX:Number, aY:Number, functionToCallTo:String){
                   var aButton:Sprite = new Sprite();
                   //draw the button
                   //set a textfieldup for the button to have
                  aButton.addEventListener(MouseEvent.CLICK, functionToCallTo)
         public function testThis(event:MouseEvent){
                   trace("testA");
         public function testThis2(event:MouseEvent){
                    trace("testB");
    Unfortunately aButton.addEventListener(MouseEvent.CLICK, functionToCallTo) gives me a coercian error, which is a given.
    aButton.addEventListener(MouseEvent.CLICK, [functionToCallTo]()) gives me TypeError: Error #1006: value is not a function.
    I mean I could create a bunch of if statements, but for the number of functions I plan to call to, like about 25 or so, that is pretty tedious.

  • Stopping mouse events from accumulating

    Hi,
    I have a GUI made using swing. on the gui i have a progress bar which uses another thread. now when that thread is working and i click on the various parts of the GUI, all the events get accumulated and when the progressbar has finished its job, all those events get executed one by one.....i want the events to b taken care of immedaitely rather than being accumulated. any way to do that

    Hello,
    have a look at this tutorials:
    http://java.sun.com/docs/books/performance/1st_edition/html/JPSwingThreads
    http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html
    and especially the [url http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html#SwingWorker]SwingWorker
    regards,
    Tim

  • Firefox mouse event not behaving the same on PC and Mac computers

    I use the FCKEditor and having a very strange problem. When I click on the FCKEditor's editing area, the keyboard gets disabled untill I click the mouse somewhere outside of the editing window. The problem only happen on Firefox (3.6.10) on Mac computer (Snowleopard 10.6.4). Doing exactly the same steps on PC works without any problem.
    What I want to know:
    - Is it possible that the Firefox on Mac is different than the PC in handling mouse events? Or some other areas?

    Sounds more that Firefox is treating that editor area as read-only.
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • Resolved: The Install Badge requires a mouse event (?)

    Edit:
    I came across this page which specifies that the restriction of installing only within the context of user event handler is by design. Nuts.
    ===
    Hi,
    I've recently tweaked our application's install badge thru the fla provided with the sdk. All works well but apparently, calling the function installApplication from the loaded air.swf has no effect if the caller is not in the context of a mouse event handler. A Flash mouse event handler, that is, since calling from a js mouse event handler has no effect.
    Without this restriction, it would be easy to use air.swf as an installation engine, keeping all the UI in html and allocating to flash only a display area suitable for notifications such as 'installing AIR'. This would greatly facilitate the development of installation pages, no longer restricted by the properties exposed by the badge swf.
    Looking forward to a reply from the powers that be,
    David

    I'm trying to draw that way too but I'm not able to find the solution, i've searched long way from all docs and tutorials but it's not easy for a beginner. And the Apple's gesture drawing tutorial was "replaced" by a GL ES sample wich do not match my needing.
    I just want to draw a line following the touch using drawrect and touchesmoved.
    If anyone could help me i would really appreciate. Thank you.

  • Can i capture the the mouse events

    i am writting application in which i have to send the screen image to client as well as mouse events and keyboard events. i am successfull in doing screen image but mouse events are not traped
    please send me any suggestion about how i will do it.
    [email protected]

    Have you tried to implement MouseListener?

  • Mouse events during Thread.sleep

    hi.
    I have an applet .
    I have a alghoritm simulator.
    Everytime I find a solution I call the method Thread.sleep .
    I want to pause the application and I create a JToggleButton Pause .
    When I press the Pause during sleep mouse event are managed at the end of alghoritm.
    How can I manage mouse events during sleep?

    All UI events (such as mouse events) occur on the event dispatch thread (EDT).
    That means if you sleep on the EDT, you lock up the UI. For this reason, you shouldn't be sleeping on the EDT.
    I'm not sure what your sleep is trying to do but you need to manage your threads a little more carefully. For instance, any time consuming process which is invoked as a result of a UI event needs to be fired on a new thread to prevent the UI freezing. The fun starts when you have to update the UI as a result of that process, because you should then hook back onto the EDT to avoid the risk of deadlock.
    Some utility classes are provided, such as SwingUtilities, and other example code is provided on Sun's site, such as SwingWorker - but if you do much UI work you'll probably end up with your own core set of threading tools and so on to make life easier.

  • Mouse Event Listeners with Full Screen JMF

    I am trying to call the mouseClicked function from JMFs addMouseListner API in order to stop a media file when a user clicks the mouse button (or a key) like in a screensaver
    I am able to access the function just before the player is started but once the media file begins to play I am not?
    Here is the code I am using for the player and listener:
    public static void main(String[] argv) {
    JMF myFrame = new JMF("Java Media Framework Project");
    myFrame.setUndecorated(true);
    myFrame.show();
    Dimension screenDim =Toolkit.getDefaultToolkit().getScreenSize();
    myFrame.setSize(screenDim.width, screenDim.height);
    myFrame.setResizable(false);
    myFrame.addMouseListener(
    new MouseAdapter(){
    public void mouseClicked(MouseEvent e) {
    System.out.println("Mouse was clicked");
    System.exit(0);
    myFrame.play();
    Are there any other methods to get around this? Is it possible to embed a JMF application in a window that I can then monitor mouse events from??

    I passed the player object to a Listener class and I can get it to work ok with keyboard controls so Im sure the thread is not being blocked...but my problem still exists in being able to monitor mouse events within the JMF display while the media is being played at full screen. (i.e. in order to stop the media)
    Maybe I can use the ControllerListener within the JMF player to monitor mouse events? Any ideas on how I do this?
    Is it possible to layer the display with a transparent window from which I can monitor mouse events from?
    You mentioned asynchronical playback...I am looking into this idea, are there any examples of this on the web I can look at?
    Thanks for your speedy reply also!!
    Regards,
    Joe
    public static void main(String[] argv) {
    JMF myFrame = new JMF("Java Media Framework Project");
    myFrame.setUndecorated(true);
    myFrame.show();
    Dimension screenDim =Toolkit.getDefaultToolkit().getScreenSize();
    myFrame.setSize(screenDim.width, screenDim.height);
    myFrame.setResizable(false);
    myFrame.new Listener(myFrame);
    myFrame.play();
    public class Listener implements KeyListener,
    MouseListener,
    MouseMotionListener,
    WindowListener {
    private JMF owner;
    Listener(JMF w) {
    owner = w;
    owner.addMouseListener(this);
    owner.addKeyListener(this);
    owner.addMouseMotionListener(this);
    //owner.addWindowListener(this);
    private void stop() { owner.stop(); }
    //---------- KeyListener Implementation ------------------
    public void keyPressed (KeyEvent evt) { stop(); System.out.println("key pressed");}
    public void keyReleased(KeyEvent evt) { stop(); }
    public void keyTyped (KeyEvent evt) { stop(); }
    //---------- MouseListener Implementation ----------------
    public void mouseClicked (MouseEvent e) { stop(); System.out.println("Mouse clicked");}
    public void mousePressed (MouseEvent e) { stop(); }
    public void mouseReleased(MouseEvent e) { stop(); }
    public void mouseEntered (MouseEvent e) { }
    public void mouseExited (MouseEvent e) { }
    //---------- MouseMotionListener Implementation ----------
    public void mouseDragged(MouseEvent e) { }
    public void mouseMoved (MouseEvent e) {
    if (oldMouse == null)
    oldMouse = new Point(e.getX(), e.getY());
    else if (e.getX() != oldMouse.x
    || e.getY() != oldMouse.y)
    stop();
    Point oldMouse;
    //---------- WindowListener Implementation ---------------
    public void windowOpened (WindowEvent e) { stop(); }
    public void windowClosing (WindowEvent e) { stop(); }
    public void windowClosed (WindowEvent e) { stop(); }
    public void windowIconified (WindowEvent e) { stop(); }
    public void windowDeiconified(WindowEvent e) { stop(); }
    public void windowActivated (WindowEvent e) { stop(); }
    public void windowDeactivated(WindowEvent e) { stop(); }
    }

  • Mouse event not working on JTable in JAVA 1.4.2

    mouse event is not recognised on empty table when using with java 1.4.2. Please specify if there is any chnge done for mouse event capture for table from java 1.3.1 to java 1.4.2.
    since mouse events are working fine for JTableHeader.
    if anybody have an idea please let me know.

    Hi
    JTable is there on JPanel . same code is working in JAVA 1.3.1
    actually its a bug in java 1.4.2 ( ref. bug_id=4940522 )
    here is the code reference..
    public class TableEditor extends JPanel
    �implements ListSelectionListener, Selector, Editor
    private JTable�myTable;
    private JPopupMenu myPopup;
    private Vector�myActions;
    private Vector�myListeners;

    public TableEditor(String anAssociation, Editor anEditor, int type)
    super(new GridLayout(1,1));

    myListeners = new Vector();
    myActions�= new Vector();
    myPopup�= new JPopupMenu();
    myTable�= new JTable();
    ��
    myTable.getSelectionModel().addListSelectionListener(this);
    myTable.addMouseListener(new MouseAdapter() {
    �public void mouseClicked(MouseEvent me)
    �{
    � if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    � {
    ��// Update actions in case ListSelectionModel are out of sync.
    ��for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(myTable, me.getX(), me.getY());
    �}
    // Added mouse listener to JTableHeader
    // This is a temporary solution to open popup menu on blank table,
    // as in Java 1.4.2 no mouse event captured on blank table.
    // So for now we will capture the event from the table header.
    JTableHeader myTableHeader = myTable.getTableHeader();
    myTableHeader.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    �{
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    ��{
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    ���}
    myPopup.show(me.getComponent(), me.getX(), me.getY());
    � }
    �});
    The solution given is temporary ( adding JTableHeader component)..
    we want to retain the same functionality .. mouse event should get captured on empty table only..

Maybe you are looking for

  • How can I embed AWT drawings in a servlet?

    I want to embed some drawing I did with java.awt(few lines and rectangles) in a servlet and show it to the user as response. How can I do that? thanks Mahesh

  • Monitor looks posterized

    So my cat sat on my keyboard and he did something wierd, and I cant figure out how to undo it. My entire monitor looks like it is in negatve, or posterized- I dont even know what to call it. Everything, from the background image to the buttons, to ev

  • Hide URL

    I'm developing a site using servlets and jsp pages. In the servlets I have RequestDispatcher dispatcher = request.getRequestDispatcher(url); dispatcher.forward(request, response); where url is the url of the jsp page I want to load. The thing is that

  • I need to comunicate two apps using tcp/ip

    I need to comunicate two apps using tcp/ip Hello. I need to comunicate two apps using tcp/ip. I am trying with mswinsck.ocx but if I use TCP mode I get an error while trying to accpet the conection; and if I use UDP, I cannot get the data when I call

  • Capacity list from work center

    Hi all, there's some BAPI or MF to retrieve a capacity's list from work center ? tks, bye