neciu
neciu

Reputation: 4485

How to generate key press events in Qt app to system (win7) (simulate user pressing keys on keyboard)?

Question in the title is quite precise.

I need to generate certain key events in my app, so OS can handle them as "normal, user" key presses. How to deal with that in Qt? Is there any neat way to solve this problem?

Upvotes: 0

Views: 1486

Answers (1)

Matt H
Matt H

Reputation: 6532

You can simulate Windows keyboard presses using the Win API function keybd_event, e.g.:

#include "windows.h"

keybd_event(VK_RETURN, 0, 0, 0);
keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);

Upvotes: 3

Related Questions