简单QQ好友窗口抖动程序实现(希望大家给点建议)
程序代码:
// 窗口抖动程序.cpp : 定义应用程序的入口点。 // #include "stdafx.h" #include "窗口抖动程序4_13_1.h" #include <windows.h> #include "mmsystem.h" #include "winuser.h" #pragma comment(lib,"user32.lib") #pragma comment(lib,"winmm.lib") // 全局变量: LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { static TCHAR szAppName[] = TEXT ("HelloWin") ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_INFORMATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_SIZE); wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ; if (!RegisterClass(&wndclass)) { MessageBox (NULL, TEXT("创建窗口失败"), TEXT("ERROR"), MB_ICONERROR) ; return 0; } hwnd = CreateWindow ( szAppName, TEXT ("QQ窗口抖动程序"), WS_OVERLAPPEDWINDOW, 500, 500, 300, 300, NULL, NULL, hInstance, NULL); ShowWindow (hwnd, nCmdShow) ; UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; } LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,LPARAM lParam) { static PAINTSTRUCT ps ; static RECT rect,clientrect; static POINT pMouse;//原来的鼠标 static HDC hdc ; static HWND QQhwnd;//QQ好友对话窗口句柄 static TCHAR pQQName[20]=TEXT(""),//好友姓名 str[2]; static BOOL bJudge1=TRUE,bJudge2=TRUE; //判断变量 switch (message) { case WM_CREATE: GetClientRect(hwnd,&clientrect); return 0 ; case WM_PAINT: if(bJudge1==TRUE) { hdc=BeginPaint (hwnd, &ps) ; TextOut(hdc,0,0,TEXT("输入好友对话窗口名:"),wcslen(TEXT("输入好友对话窗口名:"))); TextOut(hdc,145,0,pQQName,wcslen(pQQName)); EndPaint (hwnd, &ps) ; } else { if(bJudge2==TRUE) { QQhwnd = FindWindow(NULL,pQQName); if(QQhwnd==NULL) { MessageBox(NULL,TEXT("没有找到该好友对话窗口"),TEXT("警告"),MB_OK); PostQuitMessage(0); } bJudge2=FALSE; } GetWindowRect(QQhwnd, &rect); GetCursorPos(&pMouse); SetCursorPos(103+rect.left,345+rect.top); mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); SetCursorPos(pMouse.x,pMouse.y); Sleep(10000); } InvalidateRect(hwnd,&clientrect,false); return 0; case WM_CHAR: if(wParam=='\r') bJudge1=FALSE; else { str[0]=(wchar_t)wParam; str[1]='\0'; wcscat(pQQName,str); } InvalidateRect(hwnd,&clientrect,false); return 0; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam); }GetWindowRect(QQhwnd, &rect); //取得窗口坐标
GetCursorPos(&pMouse); //取得鼠标坐标
SetCursorPos(103+rect.left,345+rect.top); //设置鼠标坐标 其中(103,345)为利用SPY++截取到的点击抖动按钮的坐标!
// 鼠标击键和鼠标动作
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
//再次将鼠标还原到原来的位置
SetCursorPos(pMouse.x,pMouse.y);
该程序有些地方不完善,由于还没接触到下面的知识,所以只能将就点!
首先窗口输入对话窗口上的窗口名,例如好友叫:菜豆王子(********) 这是对话窗口上的标题;
只要输入:菜豆王子 即可!输入这方面没有做的好,输入之后就不能修改,要关闭重新打开程序才行!这不是重点!以后再弄!至于好友上线自动提示并抖动,还没有个好的想法,希望大家多多帮助,给点建议,谢谢!