Sending a paste command to a specific X11 window - linux

I'm launching multiple instances of a game via bash. Each instance has it's own login password, which I can retrieve from my password manager, which will place it in the clipboard. I'd like to send each instance it's corresponding password and an "Enter" key event, to log them in automatically. The game runs inside a wine virtual desktop, and each instance has a unique window title in WM_NAME.
Any way I can automate the login process?

try xte & wmctrl packages... Using wmctrl, you can focus any specific window & using xte, you can fake keystrokes.
Based on title, you can focus any window, using wmctrl.
They add some time delay, if required
Send keystrokes using xte
Check the man-pages for syntax.

Related

Detect Keypress in background Linux in c/bash

I want to detect a key combination like alt+g in an application that runs as a background process (other keypresses/combinations should be executed normally) ,
if the combination is pressed i want to block all keypresses and send them via serial to another linux pc instead of executing them. I cannot find a solution for detecting the key combination and recording the keys within a background process.
I'd prefer to use a bash script, but c is ok aswell.
I just cant find a starting point. Any directions or help are appreciated.
Using Xlib I managed to fetch the keyboard Input http://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html
Doesn't the application screen do what you want? Allows you to detach & reattach to sessions on another PC over network (which could be connected over a serial line)?
10 Screen command examples and
How to use Linux Screen

Use kvkbd without window manager

I am currently developing a kiosk application in QML and I want to use kvkbd virtual keyboard for user input.
When used with a window manager (such as icewm), kvkbd works well, but since my application runs without a window manager (it is a kiosk application), kvkbd does not send the keys to the focused field (e.g. a text input).
A simple script for testing would be (I am using OpenSUSE 13.1):
X :1
export DISPLAY=:1
kvkbd
xterm
After switching to the new display (Ctrl + Alt + F_digit), I am able to send input to xterm from keyboard, but not from kvkbd.
Do you have any ideas how can explicitly specify the focused window to kvkbd?
Or any ideas how I can accomplish this issue?
Thanks.

How to prohibit user to change OS window focus/type keys for several seconds on Linux

I write automated tests for a website. One of the tests needs to press Ctrl+S and type some letters to save a webpage including CSS/JS. The test should require Firefox to have window focus for those several seconds to be able to type the filename and click "Save" (currently XDoTool is used for pressing keys and clicking the mouse).
Sometimes I run the tests on my computer. I don't want to occasionally type something or change the window focus while the page is being saved, so I want to prohibit changing focus for those several seconds when those mouse clicks/key presses are running.
It's not possible to do it at the Webdriver level (a tool that I use for controlling the browser), so I think I should do it at the OS level. Can I prohibit the user from changing window focus or typing anything for a period of time? It may look like:
prohibit user from typing keys/change window focus
save page
allow user to type/change window focus
I guess that another way to achieve the desired effect would be to run Firefox and your automated tests on a nested X server (xf86-video-nested/Xephyr/Xnest).
$ Xnest :1
$ export DISPLAY=:1.0
$ firefox http://something/to/test &
$ your-test-script
Since the nested X server has it's own idea of the focused window, moving the focus on your desktop shouldn't affect it.
(If you don't actually need to see the test progressing, you could use a dummy X server (xf86-video-dummy/Xvfb/Xfake) instead)

Is it possible to display multiple choice dialog in gVIM?

I have a gVIM script that parses current buffer and offers user to select one of multiple choices. It is implemented as console input, but since i'm using graphical version of gVIM, maybe it's possible to use graphical version of multiple choice dialog? I have tried to use python + Tkinter but it's very unstable and is not working on some NIX boxes :(. Any ideas?
GVim has, in its functions and settings, nothing that would enable showing GUI elements (with a few noble exceptions, like closing dialog and such.).
That being said, GVim is open source, and nothing stops you from downloading the source and messing with it.
After some research i have found a solution. VIM supports so-called "clientserver" mode and external application can send a command to it. So this task (and many others) can be solved with following technique (tested on Windows, OSX and Ubuntu):
VIMscript that handles a command launches standalone GUI script in
separate process and returns.
Standalone GUI script (python/ruby/.exe/whatever) displays GUI and
waits for user interaction.
After user interaction, standalone GUI script closes it's window,
communicates back to VIM via "clientserver" interface (call another
script, open file, move cursor etc) and exits.

Call my application through keyword

My problem is very simple, but implementation can be hard!
I want that my application (Windows Application:: Visual C# .net) is launched whenever the user uses some keys combinations (on his keyboard).
For example it types Ctrl+W+W and my application is launched, that's all, I want the simplest implementation, less code, memory...
Thanks :D
You would need to write a keylogger type application in conjunction with your app which monitors for keyboard events. Once your specific shortcut is triggered you could then load your application.
See here for information on how to capture keystrokes.
Create a shortcut to the application, and assign a hot-key combination to the shortcut. Depending on the O/S, not every keystroke combination can be assigned to a shortcut, e.g. you may be able to assign Ctrl+Alt+W but not Ctrl+W+W.
On Windows, you can create a shortcut (on the desktop) to your application.
When you open the properties of the shortcut, on the second tab (labeled "Shortcut"), you can assign a shortcut key. But you can use only Ctrl+Alt+key shortcuts.
I don't think this is possible in the way that you framed this question. What is possible, however, is to have your application run automatically on startup without showing any forms, have it hook into Windows to monitor all keystrokes (I'm not sure how to do that part, exactly) and then show a form when the user presses a particular sequence of keys.
So in other words, your application would have to be running from the time Windows starts, but only show itself (make a form visible) when the user clicks a particular key sequence.
Update: here is a link to an article that discusses how to do global keystroke capture using C#: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx.

Resources