|
@@ -31,7 +31,7 @@ Home::Home(QWidget *parent) :
|
|
|
connect(myTimer,&QTimer::timeout,[this](){
|
|
|
captureScreen();
|
|
|
});
|
|
|
- myTimer->start(60000);
|
|
|
+ myTimer->start(10000);
|
|
|
setWindowTitle(tr("智能工时管家"));
|
|
|
//set ui data
|
|
|
webWidget = new QWebEngineView(this);
|
|
@@ -53,79 +53,9 @@ Home::Home(QWidget *parent) :
|
|
|
QString str = "http://47.100.37.243:9092/#/desktop/" + id;
|
|
|
loadNavigate(str);
|
|
|
|
|
|
-
|
|
|
- /**HANDLE hCurrentCursor = GetForegroundWindow();
|
|
|
- qDebug()<<hCurrentCursor<<endl;
|
|
|
-// EnumWindows(StaticEnumWindowsProc,reinterpret_cast<LPARAM>(this));
|
|
|
- PROCESSENTRY32 pe32;
|
|
|
- //再使用这个结构体前先定义它的大小
|
|
|
- pe32.dwSize=sizeof(pe32);
|
|
|
- //给系统内的所有进程拍一个快照
|
|
|
- HANDLE hProcessSnap=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
|
|
|
- if (hProcessSnap==INVALID_HANDLE_VALUE)
|
|
|
- {
|
|
|
- printf("Create ToolHelp32Snaphhot调用失败!\n");
|
|
|
-
|
|
|
- }
|
|
|
- BOOL bMore=::Process32First(hProcessSnap,&pe32);
|
|
|
-
|
|
|
- ::CloseHandle(hProcessSnap);
|
|
|
-**/
|
|
|
}
|
|
|
|
|
|
-/**BOOL Home::StaticEnumWindowsProc(HWND hwnd, LPARAM lParam)
|
|
|
-{
|
|
|
- //窗口是否可视
|
|
|
- if (!::IsWindowVisible(hwnd))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- //窗口是否可激活
|
|
|
- if (!::IsWindowEnabled(hwnd))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- //确定给定窗口是否是最小化(图标化)的窗口。
|
|
|
- //if(IsIconic(hwnd))
|
|
|
- // return TRUE;
|
|
|
-
|
|
|
- //窗口是否具有父窗口?
|
|
|
- HWND hParent = (HWND)GetWindowLong(hwnd, -8);
|
|
|
- //父窗口是否可激活?
|
|
|
- //据 Spy++ 观察,如“运行”对话框等被应列入列表的程序有一个隐藏的,具有 WS_DISABLED 的父窗口
|
|
|
- if (IsWindowEnabled(hParent))
|
|
|
- return TRUE;
|
|
|
- //父窗口是否可视?
|
|
|
- if (IsWindowVisible(hParent))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- LONG gwl_style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
- if ((gwl_style & WS_POPUP) && !(gwl_style & WS_CAPTION))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- CHAR caption[256];
|
|
|
- memset(caption, 0, sizeof(caption));
|
|
|
- ::GetWindowTextA(hwnd, caption, 255);
|
|
|
-
|
|
|
- if (strcmp(caption, ""))
|
|
|
- {
|
|
|
- if (GetClassLong(hwnd, -14))
|
|
|
- {
|
|
|
- HICON hIcon =(HICON)GetClassLong(hwnd, -14);
|
|
|
- if(hIcon)
|
|
|
- {
|
|
|
-// handleIcon.push_back(hIcon);
|
|
|
-// handleWindow.push_back(hwnd);
|
|
|
- qDebug()<<"hIcon="<<hIcon<<", title="<<GetClassLong(hwnd, -8);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- qDebug() <<"title=="<< caption;
|
|
|
- }
|
|
|
|
|
|
- return TRUE;
|
|
|
-}
|
|
|
-
|
|
|
-**/
|
|
|
void Home::captureScreen() {
|
|
|
QScreen *screen = QGuiApplication::primaryScreen();
|
|
|
QString filePathName = "timeManager_screencap.jpg";
|
|
@@ -210,8 +140,9 @@ void Home::captureScreen() {
|
|
|
textPart2.setBody(indate.toUtf8());
|
|
|
multiPart->append(textPart2);
|
|
|
|
|
|
+
|
|
|
QString processList = getProcessList();
|
|
|
-// qDebug() << processList ;
|
|
|
+ qDebug() << processList;
|
|
|
QHttpPart textPart3;
|
|
|
textPart3.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"processList\""));
|
|
|
textPart3.setBody(processList.toUtf8());
|
|
@@ -223,7 +154,18 @@ void Home::captureScreen() {
|
|
|
|
|
|
QString Home::getProcessList() {
|
|
|
QProcess process;
|
|
|
+ #ifdef Q_OS_WIN
|
|
|
+ qDebug() <<"This is Windows platform";
|
|
|
process.start("tasklist.exe");
|
|
|
+ #endif
|
|
|
+ #ifdef Q_OS_MAC
|
|
|
+ qDebug() <<"This is Mac platform, run ps aux";
|
|
|
+ process.start("ps aux");
|
|
|
+ #endif
|
|
|
+ #ifdef Q_OS_LINUX
|
|
|
+ qDebug() <<"This is Linux platform, run ps aux";
|
|
|
+ process.start("ps aux");
|
|
|
+ #endif
|
|
|
if(process.waitForFinished())
|
|
|
{
|
|
|
QByteArray result = process.readAll();
|