用SPY++獲得了QQ連連看的 開始按鈕坐標! 利用坐標寫了如下代碼: m_hGame = FindWindow(NULL, "QQ游戲 - 連連看角色版"); int lparam; lparam = ((562)<<16) + 664; lparam = ((562)<<16)+(664); SendMessage(m_hGame, WM_LBUTTONDOWN, 0, lparam); SendMessage(m_hGame, WM_LBUTTONUP, 0, lparam); SendMessage(m_hGame, WM_LBUTTONDOWN, 0, lparam); SendMessage(m_hGame, WM_LBUTTONUP, 0, lparam); 上述代碼不能實現(xiàn)開始按鈕的點擊這是怎么回事??? 上述代碼應該是屬于軟件模擬,所以我嘗試了使用硬件模擬: //獲取游戲窗口句柄 HWND gameh; gameh=::FindWindow(NULL,"QQ游戲 - 連連看角色版"); CRect r1; ::GetWindowRect(gameh,&r1); //保存當前鼠標指針 //取得當前鼠標位置 CPoint p; GetCursorPos(&p); //設置鼠標指針位置 取開局所在坐標:x=655;y=577 //lparam 0x0241028f SetCursorPos(655+r1.left,577+r1.top); //模擬鼠標的 單擊(鼠標按下/鼠標抬起) //MOUSEEVENTF_LEFTDOWN Specifies that the left button is down. //MOUSEEVENTF_LEFTUP //鼠標在當前位置按下 mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); //鼠標在當前位置抬起 mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); //還原鼠標位置 Sleep(200);//過一段時間 再執(zhí)行后邊的代碼 SetCursorPos(p.x,p.y); 利用這段代碼就正確實現(xiàn)了開始按鈕的點擊! |
|
來自: 昵稱15242507 > 《C#》