I would like to detect when the window running my CLI-program becomes active/inactive.
In concrete terms, my program receives regularly data from a server and displays them on the terminal window. Whenever new data are received I change the title of the window to notify the user. What I want to do is to reset the name of the window once he saw those new data.
I'm using python but I think I can go ahead if you have a generic solution.
Some terminals such as xterm let you get that information as focus events. If you enable DEC mode 1004
CSI ? 1004 h
then you'll get focus in / focus out events sent as
CSI I # focus in
CSI O # focus out
Related
First of all hi guys!
I was trying to write a mouse controller app for mac os x which is reading inputs from keyboard and moves the mouse accordingly. By garbage input i will describe the input was intented for a mouse event but it creates text on screen.
Before anyone points to the fact that there is a built in one, It was laggy even in shortest lag setting and cannot registers more than two buttons at the same time (you have to press diagonals to go to the diagonal.) If you accidentally press another button when release of the accident button your motion stops. My first and last reaction was "rubbish!". Adding customization and extra features is my goal.
I want to create a key combination that will block the garbage input to be passed to other programs while it was held. But global monitoring and seems like it always passes the event. And unfortunately I see qqqqqqqwwwwwww like text in unwanted places.
I want to see that when i press q w and up, it will make the mouse go up. But i create qqqqqqqwwwwww mess on the way. My first idea was creating a view on popover and handle events there, but whenever I want to use my mouse from keyboard seeing a popover is anoying and I couldn't find a way to show the popover without leaving any garbage keyboard input.
What should i do in this situation?
You will want to use Quartz Event Taps. Note that for an application to tap keyboard events, it has to be trusted for accessibility (as in System Preferences > Security & Privacy > Privacy > Accessibility). Your app can ask to be made trusted using AXIsProcessTrustedWithOptions().
I'm working on a gtk UI for an IRC client.
I'd like to add the following interaction to it:
On user input: /join #channel
Create a new tab < -- Working
Set focus on it < -- Not working
I Can't seem to set the focus (not the input focus, the view focus like sttign the widget to be the active view) on the created GtkWidget* on my notebook.
I tried using the grab_focus() function but the focus is still on the is created tab.
What am I missing?
The widget has to be focusable (gtk_widget_can_focus), otherwise gtk_widget_grab_focus will not do anything.
Also there is no such thing as "view-focus". You have the input focus and the window focus.
window focus - makes your application receive mouse/keyboard events.
widget input focus - makes your widget receive keyboard events if the window is focussed
Note that input here means input event (a GtkButton usually only handles the Enter whereas a GtkScale handles 0123...9.+- and may handle the Enter as well).
Is there any way to give focus to two application in same time in windows.
They need to be controlled by two input type (one can be mouse, other can be keyboard, or both can be controlled with two keyboards). On windows only one window (application) can have focus and you can send input to one of window.
No. Focus is used for controlling which process and or scope has user input. It's associated with the message pump and follows focus. All user events pertinent to the application are trapped by the system and sent to the application that has focus. The best you can hope for is something that will take focus and redirect according to input type.
A program has called XGrabKey() to make a hotkey.
The user presses that key combination (while another window is focused).
The program receives control to do something in response to the key combination. Meanwhile, the program has been temporarily focused (because of the effects of XGrabKey (see man XGrabKey, man XGrabKeyboard)).
I want the program to create a synthetic X event (a keypress or mouse click) to the originally focused window. In some cases this means I need to focus that window before sending it the event (Firefox ignores synthetic events when it is not focused), which means I need to know which window it is. How can I find out which window it is?
Wait for the next FocusOut event, verify that the mode is set to NotifyUngrab, get the focus with XGetInputFocus(), and send away your synthetic events.
How can I fire an automatic key press or mouse click event when a color appears on the screen
on other application or browser?
It depends a lot on what you want. Do you want to send the keys to
your Application
another fixed Application
Simulate a global keypress
Simulating keys globally
All of these will cause problems targeting a specific application and the active window changes.
SendKeys Sends Messages to the active app. It's a high level function taking a string which encodes a sequence of keys.
keybd_event is very low level and injects a global keypress. In most cases SendKeys is easier to use.
mouse_event simulates mouse input.
SendInput supersedes these functions. It's more flexible but a bit harder to use.
Sending to a specific window
When working with a fixed target window, sending it messages can work depending on how the window works. But since this doesn't update all states it might not always work. But you don't have a race condition with changing window focus, which is worth a lot.
WM_CHAR sends a character in the basic multilingual plane (16 bit)
WM_UNICHAR sends a character supporting the whole unicode range
WM_KEYDOWN and WM_KEYUP Sends keys which will be translated to characters by the keyboard layout.
My recommendation is when targeting a specific window/application try using messages first, and only if that fails try one of the lower level solutions.
when a color appears on the screen on other application or browser
I made one program using OpenCV and C++ for operating mouse with finger gesture. I used 3 color strips for 3 mouse function.
Yellow color for Left click
Blue color for Right click
Pink color for controlling cursor position
Whenever camera detect these colors, associated function takes place, I have used mouse_event for performing mouse function.
For more information you may read my code, blog, video.
I'm not 100% sure what you want, but if all you are after is running the method linked the the button.Clicked event, then you can manually run the method just like any other method.
You can use the .NET SendKeys class to send keystrokes.
Emulating mouse clicks requires P/Invoke.
I don't know how to detect colors on the screen.