#include <afx.h> #include <afxwin.h> #include <Windows.h> #include <vector> #include <iostream> #include <assert.h> #include <psapi.h> #include <tlhelp32.h> #include <WtsApi32.h> #include <locale.h> #include <stdio.h>
#pragma comment(lib,"WtsApi32.lib")
using namespace std;
char* getClipBoardValue(){ char *url,*pData; size_t length;
OpenClipboard(NULL);
HANDLE hData=GetClipboardData(CF_TEXT); assert(hData!=NULL);
length=GlobalSize(hData); url=(char*)malloc(length+1);
pData=(char*)GlobalLock(hData); strcpy_s(url, length,pData);
GlobalUnlock(hData); CloseClipboard(); url[length]=0; return url; }
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { if(IsWindowVisible(hwnd)){ char szTitle[100]; GetWindowText(hwnd, szTitle, 100); if(strcmp(szTitle,"") == 0){ RECT rect; GetWindowRect(hwnd,&rect); if((rect.right - rect.left) == 650 && (rect.bottom - rect.top) == 380){ for(int i=0;i<5;i++){ PostMessage(hwnd, WM_RBUTTONDOWN, 0,MAKELPARAM(200,200)); PostMessage(hwnd, WM_RBUTTONUP,0,MAKELPARAM(200,200)); Sleep(10); PostMessage(hwnd, WM_KEYDOWN,0x41,0); PostMessage(hwnd, WM_KEYUP,0x41,0); Sleep(10); PostMessage(hwnd, WM_RBUTTONDOWN, 0,MAKELPARAM(200,200)); PostMessage(hwnd, WM_RBUTTONUP,0,MAKELPARAM(200,200)); Sleep(10); PostMessage(hwnd, WM_KEYDOWN,0x43,0); PostMessage(hwnd, WM_KEYUP,0x43,0); } PostMessage(hwnd, WM_LBUTTONDOWN, 0,MAKELPARAM(200,200)); PostMessage(hwnd, WM_LBUTTONUP,0,MAKELPARAM(200,200)); cout << getClipBoardValue() << endl; string s_clipBoard = getClipBoardValue(); if(s_clipBoard.find("未来终生的伴侣")!=s_clipBoard.npos){ cout << "检测到特征" << endl; } } } }
return TRUE; }
int _tmain(int argc, _TCHAR* argv[]) { EnumWindows(EnumWindowsProc, 0); getchar(); return 0; }
|