淘宝旺旺自动发消息

View Code
 1 HWND hwnd = FindWindowEx(0, 0, L"StandardFrame", L"淘宝旺旺窗口名称");
 2 if (hwnd)
 3 {
 4 SetForegroundWindow(hwnd);
 5 EnumChildWindows(hwnd, EnumWindowCallback, 0);
 6 }
 7 
 8 BOOL WINAPI EnumWindowCallback(HWND hwnd, LPARAM lparameter)
 9 {
10 TCHAR text[128] = { 0 };
11 GetClassName(hwnd, text, 128);
12 
13 if (text[0] == L'R')
14 {
15 TCHAR* temp = L"RichEditComponent";
16 int result = strcmp((LPCSTR)temp, (LPCSTR)text);
17 
18 if (result == 0)
19 {
20 keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL,0), 0, 0);
21 keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN,0), 0, 0);
22 keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0);
23 keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0);
24 
25 return FALSE;
26 }
27 }
28 
29 
30 return TRUE;
31 }

 

posted on 2012-05-09 11:50  哥是技术人  阅读(3447)  评论(0)    收藏  举报

导航