Commit 4953633d by NitefullWind

1. 临时版本:定时向屏幕中间点击,使程序获取焦点。

parent 49d66828
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <QTcpSocket> #include <QTcpSocket>
#include <Windows.h> #include <Windows.h>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QTimer>
#include <QDebug> #include <QDebug>
FMPVipServer *FMPVipServer::instance() FMPVipServer *FMPVipServer::instance()
...@@ -21,7 +22,8 @@ FMPVipServer::FMPVipServer() : ...@@ -21,7 +22,8 @@ FMPVipServer::FMPVipServer() :
connect(this, &QTcpServer::newConnection, this, &FMPVipServer::onNewConnection); connect(this, &QTcpServer::newConnection, this, &FMPVipServer::onNewConnection);
isNeedSocketHeader = FMPVipSettings::instance()->getIsNeedSocketHeader(); isNeedSocketHeader = FMPVipSettings::instance()->getIsNeedSocketHeader();
_centerPoint = QPoint(qApp->desktop()->width()/2, qApp->desktop()->height()/2); QRect rc = qApp->desktop()->availableGeometry();
_centerPoint = QPoint(rc.width()/2, rc.height()/2);
} }
void FMPVipServer::Listen(quint16 port) void FMPVipServer::Listen(quint16 port)
...@@ -71,6 +73,10 @@ void FMPVipServer::onReadyRead() ...@@ -71,6 +73,10 @@ void FMPVipServer::onReadyRead()
recvData = recvData.mid(sizeof(FMSOCKEHEADER)); recvData = recvData.mid(sizeof(FMSOCKEHEADER));
} }
QTimer timer;
timer.singleShot(200, this, &FMPVipServer::onWindowShown);
timer.start();
QByteArray rspData; QByteArray rspData;
dispatcher->doTask(recvData, rspData); dispatcher->doTask(recvData, rspData);
...@@ -80,8 +86,18 @@ void FMPVipServer::onReadyRead() ...@@ -80,8 +86,18 @@ void FMPVipServer::onReadyRead()
socket->close(); socket->close();
socket->deleteLater(); socket->deleteLater();
socket = nullptr; socket = nullptr;
}
void FMPVipServer::onWindowShown()
{
// qDebug() << qApp->desktop()->availableGeometry() << _centerPoint;
//! WARNING 这是一个临时版本,以解决程序有时获取不到焦点问题。
SetCursorPos(_centerPoint.x(), _centerPoint.y());
mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_ABSOLUTE, _centerPoint.x(), _centerPoint.y(),0,0);
mouse_event(MOUSEEVENTF_LEFTUP|MOUSEEVENTF_ABSOLUTE, _centerPoint.x(), _centerPoint.y(),0,0);
//! WARNING 这是一个临时版本,以解决POS接收消息后获取不到焦点问题。 //
mouse_event(MOUSEEVENTF_LEFTDOWN, _centerPoint.x(), _centerPoint.y(),0,0); // qDebug() << PostMessage(NULL, WM_LBUTTONDOWN, 0, 17+34*65536);
mouse_event(MOUSEEVENTF_LEFTUP, _centerPoint.x(), _centerPoint.y(),0,0); // mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_ABSOLUTE, 10, 10, 0,0);
// mouse_event(MOUSEEVENTF_LEFTUP|MOUSEEVENTF_ABSOLUTE, 10, 10, 0,0);
} }
...@@ -23,6 +23,9 @@ public: ...@@ -23,6 +23,9 @@ public:
void Write(const QByteArray &data); void Write(const QByteArray &data);
void SetPluginContext(ctkPluginContext *ctx); void SetPluginContext(ctkPluginContext *ctx);
public slots:
void onWindowShown();
//signals: //signals:
private slots: private slots:
void onNewConnection(); void onNewConnection();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment