How to send actions directly to input event? - linux

I have a touch screen with events at /dev/input/event12 and /dev/input/event13. /dev/input/event12 is the main touch input, and in essence, I'd like to send instructions to the event directly to control behavior (ie, click location etc).
Tools like xdotool do not want to work because this device is being set as a second pointer (see: https://dwm.suckless.org/multi-pointer/) and the recommendation of using xinput set-cp <window> <master> does not appear to work as expected.

A solution was found using Python and Python-evdev. Using evdev you can assign the device and pass parameters within the allowed functions. In my case it is as follows:
device.write(e.EV_KEY, e.BTN_TOUCH, 1)
device.write(e.EV_KEY, e.BTN_TOUCH, 0)
device.write(e.EV_SYN, 0, 0)

Related

I cannot send keystrokes to a selected input box

from pywinauto.application import Application
app = Application().Start(cmd_line=u'"path to program" ')
afx = app[u'Afx:01360000:0']
afx.Wait('ready')
afxtoolbar = afx[u'1']
toolbar_button = afxtoolbar.Button(3)
toolbar_button.Click()
window = app.Dialog
window.Wait('ready')
edit = window.Edit4
edit.Click()
app.typekeys ("Success")
So at this point, I've gotten the application to open, the correct window to pop up and also a mouse click on the box that I want to populate with a short string. I cannot for the life of me, figure out how to pass keyboard input to this field. I have read all the docs for PyWinAuto, and nothing is helping...
Basically all I need to do is figure out how to send a string, and then how to send the TAB key six times. I can then finish my program to automate this application.
I am also using Swapy64bit to help. The program uses a win32 backend. I'm using Python 3.6.
Am I not prefixing typekeys correctly? The PyWinAuto documentation leaves much to be desired.
First the correct name of the method is type_keys, but assume you use it correctly.
The reason might be losing focus at the edit control because type_keys tries to set focus automatically. The solution is:
app.type_keys("Success{TAB 6}", set_foreground=True)

Zebra RFD8500 : How to use read in ZETI

I have a Zebra RFD8500 here and I connected to it via the terminal. I am trying to use the ZETI command read to access epc's, but it does not read anything.
But if I use the ZETI command inventory it finds all the tags around.
Anyone knows how to use the read command properly? Also is there some kind of filter per default on?
I am using the developer example on page 174 Link to PDF
Not sure if you solved this problem, but I couldn't find anything else via Google. I had the same problem with using read in ZETI (Zebra RFD8500). The Zebra tech support told me that to use access operations like read and write, you have to turn off dynamic power (which I think is on by default).
Unfortunately, I am not using the iOS API/SDK (writing a custom one for another device), but here's the gist of what you'd be doing:
Turn off dynamic power
Do an inventory
Read some memory bank, like the EPC bank. Optionally, you can also specify access criteria to single out a tag.
To test how this worked in ZETI, I screened into the RFD8500 (on my Mac, doing ls /dev/tty.RFD* lists several ttys, I chose the one ending in "-R"):
screen /dev/tty.RFD8500{long number}-R
Then I issued these commands:
dp .disable
in
rd
Commands:
dp = setdynamicpower
in = inventory
rd = read
After issuing "rd", you should be able to see the user memory banks (the default bank for the "rd" command).

Get numbers of all screens in Xlib

I've been googling for quite a long time and I just can't find any information on how to get screen_number for every screen connected to computer. Here I found a list of macros and some of them (like for example ScreenOfDisplay(display, screen_number) ) use argument screen_number. However there is no such macro that could give me a list of those numbers (one for every connected screen). I know how to get number of default screen (DefaultScreen() ) and count of all screens ( ScreenCount() ) but what about other screens? I noticed that screen_number of default screen is 0, although I have only one screen connected to my computer so I can't really test what happens when there are more of them. I think that screen_number could be assigned in a very simple way which is screen_number=0 for first screen,screen_number=1 for second,screen_number=2 for third and so on but as I said... I can't test wheather it's true and even if I had multiple screens how could I be sure that it works like this for all computers .Please ,if anyone of you has more experience with X11 and knows all details about how it works,tell me if I am right.
The ScreenCount(dpy) macro and int XScreenCount(Display*) function both return the number of screens connected to the display. Valid screen numbers are 0 to ScreenCount(dpy)-1. Macros in Xlib.h confirm:
#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
#define ScreenOfDisplay(dpy, scr) (&((_XPrivDisplay)dpy)->screens[scr])
Your source (2.2.1. Display Macros) provides enough information. Normally the default screen-number is 0, e.g., when connecting to the local host you could use :0.0 as indicated in the documentation for XOpenDisplay.
That is "normally". If you run VNC, normally that runs on a different display (the first 0 in the simple connection string shown).
But (reading the documentation), when an application calls XOpenDisplay, it asks for the given screen-number (which the X server may/may not honor):
screen_number
Specifies the screen to be used on that server. Multiple screens can be controlled by a single X server. The screen_number sets an internal variable that can be accessed by using the DefaultScreen() macro or the XDefaultScreen() function if you are using languages other than C (see "Display Macros").

How to create TI-BASIC (TI-84+) input forms?

In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
You've set a rather tall order for TI-Basic to fill. user3932000 is correct; there is no built in function to create an input form of the type you request.
However, there is nothing stopping you from creating an interactive interface yourself. Creating it from scratch will be a time consuming and, it will consume a significant amount of memory on your calculator. There is no boilerplate code you plug your variables into to get the results you want, but you might have some luck modeling it after this quadratic solver I wrote.
ClrHome
a+bi
Output(1,1," QUADRATIC
Output(2,1," AX²+BX+C
Output(3,1,"ZEROS:
Output(6,1,"A=
Output(7,1,"B=
Output(8,1,"C=
DelVar YDelVar D
" →Str1
While Y≠105
getKey→Y
If Ans
Then
Output(X,4,Str1
Output(3,7,Str1+Str1+Str1+"
End
X+(Ans=34)-(Ans=25
If Ans<6:8
If Ans>8:6
Ans→X
Output(Ans,16,"◄
D(Y≠45→D
If Y=25 or Y=34
sum({A,B,C}(X={6,7,8→D
If Y=104:⁻D→D
10not(Y)+Y(102≠Y)-13int(Y/13(2>abs(5-abs(5-abs(Y-83
If Ans≤9
D10+Ans-2Ans(D<0→D
If X=6:D→A
If X=7:D→B
If X=8:D→C
If A
Then
2ˉ¹Aˉ¹(⁻B+{1,⁻1}√(B²-4AC
Else
If B
Then
⁻C/B
Else
If C
Then
"No Zeros
Else
"All Numbers
End
End
End
Output(3,7,Ans
Output(6,3,A
Output(7,3,B
Output(8,3,C
End
ClrHome
Ans
Here's a GIF of what it does for you.
With a little more work. This code could be used on the Graph screen instead of the home screen, giving more option in terms of layout and design.
In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
There are many ways to ask for input in your program:
Prompt: Asks for input and stores it in a variable. For example, Prompt A. Simplest way to ask for input, but not very visually appealing.
Input: Similar to the Prompt command, except that now you can include text within the input. For example, Input "What is your name?",A.
Menu(: Multiple choice input, and each choice is connected to a Lbl marker somewhere else in the script. Much like the error screen with the quit/goto choices that you've probably seen. For example, Menu("Are you a boy or a girl?","Boy",B,"Girl",G).
getKey: Checks if a certain key is pressed, and will output True (1) if that key is pressed. For example, getKey 105. See here for which numbers each key corresponds to.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function http://imgur.com/ulthDRV
I'm afraid that's not possible in programs. You can either put in multiple inputs, or you might be interested in looking into making apps instead.
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
If you're talking about the text on top of the screenshot, yes you can; just put a Disp command or something after each line of Input, so that it continuously overwrites the text above with new text after you input a variable.

Linux: Xautomation with fake mouse pointer

I have created a fake mouse pointer using the xinput command as outlined here which produces a second pointer that hovers in the center of my screen.
I would now like to automate it using the xte command, but unfortunately xte only seems grab control of the hardware mouse that I wish to keep free.
The man page for xte does not have any flags to specify which pointer to take control of.
I was wondering if anybody had any ideas?
NB: The second pointer is purely for me to able to work on the same computer whilst running the graphical pipeline
Edit: So by looking at the xte source I've found references to XQueryPointer
Bool XQueryPointer(display, w, root_return, child_return, root_x_return, root_y_return,
win_x_return, win_y_return, mask_return)
Display *display;
Window w;
Window *root_return, *child_return;
int *root_x_return, *root_y_return;
int *win_x_return, *win_y_return;
unsigned int *mask_return;
//Arguments:
display Specifies the connection to the X server.
w Specifies the window.
root_return Returns the root window that the pointer is in.
child_return Returns the child window that the pointer is located in, if any.
root_x_return
root_y_return Return the pointer coordinates relative to the root window's origin.
win_x_return
win_y_return Return the pointer coordinates relative to the specified window.
mask_return Returns the current state of the modifier keys and pointer buttons.
from the Xlib class, which as you can see returns only the first mouse pointer and does not give option for another.
Edit2: Looking through the libx11-dev source I'm finding mentions of it at ./src/QuPntr.c and Xlibint.h, but the code is getting harder to read and I'm out of my depth here
xinput makes use of the XI2 extension to allow for multiple pointers.
This library (X11/extensions/XInput2.h) provides functions prefixed by "XI" which accept a device parameter (the same referenced by xinput --list), for instance XIQueryPointer, XIWarpPointer or XIGetClientPointer.
Thus you can control your fake pointer programmatically if your automation tool doesn’t support XI2.
In a simpler way, it could suffice to xinput --reattach the hardware device (a slave device) to the new pointer (a master device).
Very late answer I know, but I came across this question via web search so I add what I know for reference.
Actually there isn't any mention of XQueryPointer inside the source code of xte.c (there are only a few inside xmousepos.c, which is code for a different tool).
I checked a few older versions that existed before you asked the question.
The relevant functions are XIWarpPointer and XTestFakeDeviceButtonEvent. As seen here in the reduced source code:
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
#include <X11/extensions/XTest.h>
int main (int argc, char *argv[])
{
int delta_x = 500, delta_y = 160;
Display *display = XOpenDisplay(0);
Window root = DefaultRootWindow(display);
XIWarpPointer(display, 14, None, root, 0, 0, 0, 0, delta_x, delta_y);
XDevice *device = NULL;
device = XOpenDevice(display, 16);
XTestFakeDeviceButtonEvent(display, device, 1, True, 0, 0, CurrentTime);
XTestFakeDeviceButtonEvent(display, device, 1, False, 0, 0, CurrentTime);
XCloseDisplay(display);
}
which does the same thing as xte -i 16 "mousemove 500 160" "mouseclick 1".
But what might bother you (at least it bothers me): Windows that got clicked gain focus, effectively unfocusing the window that you were working on.
Actually I asked a question that asks for an alternative to XTestFakeDeviceButtonEvent just recently (Sending a button press event for a second pointing device; I also provided some example code that actually performs mouse clicks without giving focus to a window, so it's possible but dunno how it's done with another pointing device)..
An alternative might be to work with multiple X sessions like this user did it: Controlling multiple pointers with Xlib or xinput in ubuntu/linux. Sadly he hasn't shared any code.
I have some hope with uinput (https://www.kernel.org/doc/html/v4.12/input/uinput.html) but haven't tried it yet.

Resources