Send keystrokes help c++
-
Hi! I don't know what you're doing there but it's far too complicated. The way to go is to create QKeyEvent's and send them to the widget of your choice via postEvent. You can do the same with other events, like mouse input.
-
What is the exact content of this file ?
-
Then why not just show its content in a QLabel or a QTextEdit/QPlainTextEdit if you want to be able to modify it ?
-
The function for send my keys is this:
void enviarTecla(int tecla)
{Display *display = XOpenDisplay(NULL); XKeyEvent event; switch (tecla) { case Qt::Key_Return: tecla = XK_Return ; break; case Qt::Key_Backspace: tecla = XK_BackSpace ; break; case Qt::Key_Escape: tecla = XK_Escape; break; case Qt::Key_Shift: tecla = XK_Shift_L ; break; case Qt::Key_CapsLock: tecla = XK_Caps_Lock; break; } int a; event.display = display; XGetInputFocus(display,&event.window,&a); event.root = 0; event.subwindow = None; event.time = CurrentTime; event.x = 1; event.y = 1; event.x_root = 1; event.y_root = 1; event.same_screen = TRUE; event.type = KeyPress; //event.type = KeyRelease; event.keycode = XKeysymToKeycode (display,tecla); event.state = 0; XSendEvent(event.display, event.window, TRUE, KeyPressMask, (XEvent *)&event); event.display = display; XGetInputFocus(display,&event.window,&a); event.root = 0; event.subwindow = None; event.time = CurrentTime; event.x = 1; event.y = 1; event.x_root = 1; event.y_root = 1; event.same_screen = TRUE; event.type = KeyRelease; event.keycode = XKeysymToKeycode (display,tecla); event.state = 0; XSendEvent(event.display, event.window, TRUE, KeyReleaseMask, (XEvent *)&event); XCloseDisplay(display);
}
And when i send i am trying with this format:
http://i.imgsafe.org/7e29fc31bc.pngNot works
-
Can you explain what you are trying to achieve ? That would help us help you more efficiently.
-
the question is very easy; in the table ascii between 0 and 32 exists keys of control for example enter. How i could simulate enter when someone press 13 ascii key for example? I am introducing these data in a file but shoz me events or i dont know look: http://i.imgsafe.org/7e29fc31bc.png
thanks in advance. in Qt -
How did you solved it ?
In any case, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)