Announcement

Collapse
No announcement yet.

Custom Shortcut Key to send keys to specific non active Window

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom Shortcut Key to send keys to specific non active Window

    I am a Kubuntu 10.10 user, so I have been using for awhile. I have a normal window I renamed "G-Box" for simplicity sake. So now I want to press NumKey 1 and send C<space> into the G-Box window.

    The problems I am running into are;

    "Shortcuts and Gestures" does not distinguish between NumKey and the top row.
    "Shortcuts and Gestures" does not allow for the single key to be used as a hotkey.
    "Shortcuts and Gestures" requires the window to be active and not running in background or minimized.

    Shortcuts and Gestures is not well documented and even the examples lack much explanation. If there is a way to get at the list of shortcuts and edit them directly, I would like to know. If there is another program utility I should be using, by all means tell me. I am somewhat limited to using the NumPad keys because another program is also using many of the keys as macros and I cannot use many of the other keys.

    ---update-- 9.20.12 --
    I have explored the usage of xdotool and wmctrl to little avail. For those of you that know, wmctrl allows some basic window control. While xdotool seem to lack good examples to work with. I am beginning to believe I will be forced to write a c++ program... however this means I will also need examples in Linux, which is also difficult to find.

    Thanks.
    Last edited by Simon; Sep 20, 2012, 02:44 PM. Reason: Updating

    #2
    I think the issues you've identified aren't the fault of the Shortcuts and Gestures control module and in fact aren't (easily) fixable within KDE - they are how X works. (But I could be wrong.)

    distinguish between NumKey and the top row
    - I don't think even the hardware distinguishes between them (whereas the numbers on the numeric keypad are definitely different keystrokes from the numbers on the main keyboard at the hardware level)
    allow for the single key to be used as a hotkey
    - actually this could be addressed by KDE (I was thinking of the case of using a modifier key, as a single key, to generate a shortcut on its own, which X doesn't make easy) - but I think it's a reasonable design restriction not to allow regular typing keys to be remapped into shortcuts
    requires the window to be active and not running in background or minimized
    Via Edit... > New > global shortcut you can define shortcuts that run background commands, but not directly to type characters into another window.

    So you have two things to do: choose a keystroke combination that can be set in shortcuts and gestures - Ctrl-Alt-Shift-Meta-numkey1 is probably free

    and write a short script using xdotool (and perhaps wmctrl) to select the window and type the characters into it. Examples are out there, they just may take a little finding. I bookmarked this: xdotool - fake keyboard/mouse input, window management, and more :: semicomplete.com - Jordan Sissel
    I'd rather be locked out than locked in.

    Comment


      #3
      Thanks for the info, I have that bookmarked now. So far I keep running into stuff that is supposed to be "easy" but are just giving me headaches.

      Iron AHK at http://www.ironahk.net/ says this;

      Easy to learn PHP-like syntax
      Simulate keystrokes and mouse movements
      Manipulate windows and processes
      Scripts can be compiled into standalone executables
      Create Graphical User Interfaces (GUIs)
      Edit files and modify directories
      Runs on .NET or Mono for Linux/Mac
      Free and open source software
      But I haven't installed the program yet, because the zip file just says any OS (kind of scary) and the tutorial page is blank. I never liked having to use dot NET in Windows so I am not sure how I feel about this mono stuff. When did programmers stop writing there own material? LoL

      "Ctrl-Alt-Shift-Meta-numkey1" I will check but I think I will need to grow some more fingers.

      Comment


        #4
        I would persevere with xdotool rather than pull in Mono.
        I'd rather be locked out than locked in.

        Comment


          #5
          After much effort on my part I came up with a rather tedious method. I have 2 windows which I used wmctrl to call Slave and Master. Since both have the same name because they are the same program I must run the one I plan to work in then rename that window Master and then start the second and name that one Slave because I am tossing crap into it from the Master.
          Code:
          wmctrl -r Window -N Master
          wmctrl -r Window -N Slave
          Next I tile both side by side (which personally I hate) then I have scripts like this linked to icons on my taskbar.
          Code:
          #!/bin/bash
          wmctrl -a Slave
          sleep 0.2
          xdotool type '99:02:'
          xdotool key 'ctrl+v'
          wmctrl -a Master
          In short; this script, when the icon on my taskbar is clicked, gives focus to the "slave" window. Then types 99:02: into that window then pastes the data I copied from the prior screen into this one. After that it returns focus to the "master" window. So now I have my panel full of stupid little icons but I don't have to type as much. I don't care much for the screen flipping process.

          Comment

          Working...
          X