Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

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

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

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

    I've found what I was looking for. With xmacro and following these instructions, I first recorded the keypress I wanted to simulate (with xmacrorec), and can now rerun that anytime I want (with xmacroplay).

    Problem solved.

  2. #22
    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
    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?
    You could try the program called xautomation (sudo apt-get install xautomation) . Then for sending F1 the call is

    xte "key F1"

  3. #23
    Join Date
    Jul 2006
    Beans
    1,152

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

    Thanks, that is a little simpler.

  4. #24
    Join Date
    Feb 2007
    Beans
    314
    Distro
    Ubuntu 7.04 Feisty Fawn

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

    try xsend, it does what you are looking for.
    <plexr> do you know std c++ ?
    <plexr> or is a weak understanding of VB your only strength
    <ahorse_> oohhhhh he just said the equivalent of *yo momma*
    www.acgla.net <--- My webpage : )

  5. #25
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Beans
    1,634
    Distro
    Ubuntu Development Release

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

    Quote Originally Posted by Namtabmai View Post
    Try xkbevd.

    E.g.

    Code:
    /usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]"
    Will send the Alt+Left key combination.
    Thanks, that works great for my purposes! (Using spotify as an alarm clock)

  6. #26
    Join Date
    Apr 2006
    Location
    Netherlands
    Beans
    6
    Distro
    Ubuntu 10.10 Maverick Meerkat

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

    I find the easiest way to use xdotool (it's in the universe repository).

    You can just use commands like:

    Code:
    xdotool key Ctrl+c
    xdotool key Super+a
    xdotool key Control+Alt+Right
    xdotool key Control+Alt+Left
    Last edited by lazyr; June 25th, 2010 at 09:42 PM.

  7. #27
    Join Date
    May 2008
    Beans
    5

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

    xdotool did my job.. thanx all of you for this wonderful post..


    linux rocks

  8. #28
    Join Date
    Sep 2008
    Location
    your profile
    Beans
    628
    Distro
    Ubuntu 12.04 Precise Pangolin

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

    Yay for xdotool!

  9. #29
    Join Date
    Feb 2010
    Beans
    2

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

    I need help ... I bought a multimedia control (http://www.dealextreme.com/details.dx/sku.26368) for use with XBMC. This control comes with four shortcut keys already set to "Ctrl Alt A", "Ctrl Alt B", "Ctrl Alt C" and "Ctrl Alt D". I wanted to create a script to simulate the pressure of "i" key, which opens in XBMC the information of the selected movie. So I could create a shortcut to this script that has already set in my control to simulate the pressure of that key.

    In Windows xp I could do exactly what I want to creating a VBScript like this:


    Set WshShell = WScript.CreateObject ("WScript.Shell")

    WshShell.SendKeys "{i}"
    WScript.Sleep 10

    After I created a shortcut to this script with "Ctrl Alt D", goes like every time I open XBMC and select a movie I can click on the button on my control that is set to "Ctrl Alt D" and display the Movie information.

    Worked perfect in XP but I really want to get it working in Ubuntu!

    I've tried to create several scripts and configured to run with the shortcut "Ctrl Alt D", but none of them work in XBMC.

    I tried the following ways:

    # First using xautomation:
    /usr/bin/xte "key i";

    # Attempt 2 with xdotool:
    xdotool key i

    These two options only work running through the terminal, nothing was displayed by the shortcut.

    # Third option xkbevd:
    /usr/bin/xvkbd-xsendevent-text "\ [i]"

    This method worked using the key for that shortcut in my control displaying the letter "i" in the terminal, in gedit, within vim, but for some reason does not work in XBMC. Neither worked in Google search.

    Anyone have any ideas?

  10. #30
    Join Date
    May 2007
    Beans
    525
    Distro
    Ubuntu Development Release

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

    Thanks a lot.
    I just used this to bind firefox 4 panorama to a screen edge

Page 3 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
  •