[英]keybd_event on Qt won't work
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). 我正在尝试通过从我的应用程序向应用程序外部(系统)发送“键盘压力机”,在Qt上创建某种“虚拟控制器”。 I tried to use keybd_event, but I'm having problems.
我尝试使用keybd_event,但是出现问题。 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) mainwindow.obj:-1:错误:LNK2019:在函数“私有:void __thiscall MainWindow :: on_pushButton_clicked(void)”中引用的未解析的外部符号_ imp _keybd_event @ 16(?on_pushButton_clicked @ MainWindow @@ AAEXXZ)
Can please someone explain why is wrong with the code? 请问有人可以解释为什么代码错误吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.