Reputation: 11
I'm trying to create some sort of a "virtual controler" on Qt, by sending "keyboard presses" from my apliccation to outside of it (to the system). I tried to use keybd_event, but I'm having problems. Even this simple code won't work:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <windows.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
keybd_event(Qt::Key_Right, 0, 0, 0);
keybd_event(Qt::Key_Right, 0, KEYEVENTF_KEYUP, 0);
}
I get this error message:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol _imp_keybd_event@16 referenced in function "private: void __thiscall MainWindow::on_pushButton_clicked(void)" (?on_pushButton_clicked@MainWindow@@AAEXXZ)
Can please someone explain why is wrong with the code?
Upvotes: 1
Views: 578