Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 32

Thread: [SOLVED] How do I run a key press as a command?

  1. #11
    Join Date
    Jul 2006
    Beans
    1,152

    Re: How do I run a key press as a command?

    Quote Originally Posted by yabbadabbadont View Post
    Is btnx what you are looking for?
    No, but thank you. As far as i can tell, btnx can assign any keystroke or command to any button of your mouse, but that is not what I want (though some of the other posters seem to, though).

    I want an application that I can use to simulate a key press at the command line. So that nameoftheapp keycode (or whatever form the command takes) equals pressing the key that has that keycode.

    I was hoping something like that would exist. What if you have a script that needs some sort of confirmation from the command line (done automatically, without you pressing that key)?

    I'd like to use this thing -- once I find it! -- to trigger certain actions of applications that only run by pressing a key assigned to it globally.

  2. #12
    Join Date
    Mar 2006
    Beans
    49

    Re: How do I run a key press as a command?

    Your heading for a mass of problems when you do this.. You will learn soon what I mean...
    I have tried many Linux distro's and Ubuntu is the one I'm sure everyone should be using.=D>

  3. #13
    Join Date
    May 2005
    Location
    Indiana
    Beans
    1,933
    Distro
    Hardy Heron (Ubuntu Development)

    Re: How do I run a key press as a command?

    Why not just make a bash script and echo the letter? For the letter Y,

    Code:
    #!/bin/bash
    echo Y
    Then just save the file as whatever you want and run it like a command. You could even make a link to it in your panel or something so that if you click that icon, it will echo the letter Y to the terminal.

    That's about as simple as it gets.
    Today you are You, that is truer than true. There is no one alive who is Youer than You. - Dr. Seuss

  4. #14
    Join Date
    Jul 2006
    Beans
    1,152

    Re: How do I run a key press as a command?

    Thanks forrestcupp. That looks very simple. I'll try it out later, but would this work with something like ScrollLock, PrintScreen, Ctrl, Delete, etc.?

  5. #15
    Join Date
    Feb 2006
    Beans
    120
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: How do I run a key press as a command?

    I don't know the exact details but I thought this was done using something like

    echo KEY > /dev/keyboard

    or I could be imagining things.

  6. #16
    Join Date
    Apr 2006
    Location
    UK
    Beans
    6,646
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How do I run a key press as a command?

    I was looking for something that would simulate repeated keystrokes in order to turn off my power saving screen settings when I watch films.

    But doesn't echo display text, rather than simulating key presses?

  7. #17
    Join Date
    Dec 2004
    Location
    Tampere
    Beans
    20
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Re: How do I run a key press as a command?

    Quote Originally Posted by urukrama View Post
    I was hoping something like that would exist. What if you have a script that needs some sort of confirmation from the command line (done automatically, without you pressing that key)?
    In bash scripts you can do something like this:

    Code:
    cat  <<+                                                                        
    Input for program "cat" here between the plus-signs.                                                                       
    +
    And now it gives automatically the input between plus signs to the program before the <<

    This way you can give automatically input to programs which ask for input during use.

  8. #18
    Join Date
    Sep 2007
    Beans
    Hidden!
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: How do I run a key press as a command?

    Try xkbevd.

    E.g.

    Code:
    /usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]"
    Will send the Alt+Left key combination.

  9. #19
    Join Date
    Jul 2006
    Beans
    1,152

    Re: How do I run a key press as a command?

    Quote Originally Posted by Namtabmai View Post
    Try xkbevd.
    Thank you. This is interesting, but this only works (as far as I can tell) to send text to the focussed windows. That is what the man pages said, and that is how it worked for me.

    But I want to send a (global) key press that triggers a command of an application. Xvkbd doesn't help with that, it seems.

    (I had xkbevd installed, but needed to install xvkbd separately, btw)
    Last edited by urukrama; January 6th, 2008 at 10:31 PM.

  10. #20
    Join Date
    Jul 2006
    Beans
    1,152

    Re: How do I run a key press as a command?

    Sorry to bring this up again, but I haven't had any luck so far. I have tried all the suggestions, but nothing did what I wanted (I couldn't quite grasp what ReiKn and napsilan suggested, though).

    To clarify why I want to achieve this, I'll give an example of why I want to use a command to simulate a keypress. When running, tilda is only shown when a particular key is pressed (F1) by default. I would like to bind that to a mouse action in Openbox or Pekwm, but I can only bind commands (or Openbox and Pekwm actions) to mouse actions in those window managers. That is why I would like to simulate a keypress.

    The keys I am interested in are not the general letters or numbers, but things like F1-F12, Scroll_Lock, Print_Screen, etc.

    So, any further suggestions?

Page 2 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •