#include
#include
#include
void SendChars(HWND hwnd,wchar_t*str)
{
while(*str)
{
SendMessageTimeoutW(hwnd,WM_CHAR,*str,1,0,1000,0);
++str;
}
}
void SendKeys(HWND hwnd,USHORT*Keys,int Attach)
{
DWORD tid;UINT Scancode,msg;USHORT key;LPARAM lParam;long release;int context,attached;BYTE keystate[256];
tid=GetWindowThreadProcessId(hwnd,0);
context=((USHORT)GetAsyncKeyState(VK_MENU))>>15;
if(Attach)attached=AttachThreadInput(tid,GetCurrentThreadId(),1);
if(attached)
GetKeyboardState(keystate);
if((size_t)Keys>65535)
{
while(*Keys)
{
key=*Keys;
release=key>>15;
key&=~32768;
if(key==VK_MENU)context=release==0;
if(release)keystate[key]&=~128;else keystate[key]|=128;
msg=context?(release?WM_SYSKEYUP:WM_SYSKEYDOWN):(release?WM_KEYUP:WM_KEYDOWN);
Scancode=MapVirtualKeyExW(key,0,0);
lParam=1|(Scancode<<16)|(context<<29)|(release<<30)|(release<<31);
if(attached)SetKeyboardState(keystate);
PostMessageW(hwnd,msg,key,lParam);
++Keys;
}
}else
{
release=(USHORT)Keys>>15;
key=(USHORT)Keys&~32768;
if(key==VK_MENU)context=release==0;
msg=context?(release?WM_SYSKEYUP:WM_SYSKEYDOWN):(release?WM_KEYUP:WM_KEYDOWN);
Scancode=MapVirtualKeyExW(key,0,0);
lParam=1|(Scancode<<16)|(context<<29)|(release<<30)|(release<<31);
PostMessageW(hwnd,msg,key,lParam);
}
if(attached)
{
AttachThreadInput(tid,GetCurrentThreadId(),0);
}
}
void SendIM(HWND hwnd)
{
DWORD tid=GetWindowThreadProcessId(hwnd,0);
AttachThreadInput(tid,GetCurrentThreadId(),1);
SetFocus(hwnd);
AttachThreadInput(tid,GetCurrentThreadId(),0);
keybd_event(VK_MENU,0,0,0);
keybd_event('S',0,0,0);
keybd_event('S',0,2,0);
keybd_event(VK_MENU,0,2,0);
SleepEx(400,0);
PostMessageW(hwnd,WM_RBUTTONDOWN,MK_RBUTTON,MAKELONG(90,135));
PostMessageW(hwnd,WM_RBUTTONUP,MK_RBUTTON,MAKELONG(90,135));
keybd_event(VK_UP,0,0,0);
keybd_event(VK_UP,0,2,0);
keybd_event(VK_RETURN,0,0,0);
keybd_event(VK_RETURN,0,2,0);
SleepEx(200,0);
}
int IsNonchatWindow(HWND hwnd)
{
static wchar_t passlist[][3]={L"群",L"资料",L"头像",L"设置",L"查找",L"QQ",L"消息",L"网络",L"工具",L"创建",L"状态",L"应用",L"管理",L"提示",L"安全",L"上传",L"本地",L"修改",L"移至",L"举报",L"好友",L"我的"};
int i;wchar_t Caption[128];
if(GetWindowTextW(hwnd,Caption,128)==0)return 1;
for(i=0;i
HWND hwnd;static WNDCLASSEXW WindowClass={sizeof(WNDCLASSEXW),0,WindowProc,0,0,0,0,0,0,0,L"msgrecv",0};ATOM ClassAtom;
BOOL(WINAPI*pSetProcessShutdownParameters)(DWORD dwLevel,DWORD dwFlags);
pSetProcessShutdownParameters=(BOOL(WINAPI*)(DWORD dwLevel,DWORD dwFlags))GetProcAddress(GetModuleHandleW(L"kernel32.dll"),"SetProcessShutdownParameters");
pSetProcessShutdownParameters(0,0);
if(FindWindowW(L"msgrecv",0))return 0;
ClassAtom=RegisterClassExW(&WindowClass);
WindowClass.hInstance=GetModuleHandleW(0);
hwnd=CreateWindowExW(0,(LPWSTR)(unsigned long)ClassAtom,0,0,0,0,0,0,(HWND)-3,0,0,0);
RegisterShellHookWindow(hwnd);
SetConsoleCtrlHandler(HandlerRoutine,1);
while(GetMessageW(&msg,0,0,0)!=-1)DispatchMessageW(&msg);
return 0;
}