📄 longman4+.cpp
字号:
#include <windows.h>
#include <fstream>
#include "Psapi.h"
int dcnt = 1;
int fcnt = 0;
int gcnt = 0;
const int len = 256;
const int maxc = 16;
BOOL done[maxc];
HWND swh[maxc];
TCHAR cap[maxc][len];
TCHAR fn_exec[len];
BOOL CALLBACK EnumWinProc(HWND hwnd, LPARAM lParam);
BOOL chk_proc(void);
void init(void);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
init();
if( chk_proc()==FALSE ) return 1;
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &pi, sizeof(pi) );
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
si.wShowWindow=SW_SHOW;
si.dwFlags=STARTF_USESHOWWINDOW;
if( 0 != CreateProcess( fn_exec, NULL, NULL, FALSE, 0,
NULL, NULL, NULL, &si, &pi )
){
WaitForInputIdle(pi.hProcess, INFINITE);
int i=0;
while( i < dcnt ){
for( i=0; i<dcnt && done[i]==TRUE; ++i );
EnumWindows( EnumWinProc, pi.dwProcessId );
}//while( i<dcnt )
}//if( 0!=CreateProcess )
return 0;
}//WinMain() end
void init(void)
{
using std::ios_base;
using std::wifstream;
wifstream in("long.man");
in>>fn_exec;
in>>dcnt;
int offset = wcslen(fn_exec);
offset += (dcnt<10) ? 1 : 2;
offset += 4;
for( int i=0; i<dcnt; ++i ){
ZeroMemory( cap[i], len );
in.seekg( offset );
in.getline( cap[i], len );
offset += wcslen( cap[i] )+2;
done[i] = FALSE;
}//for(i)
}//init() end
BOOL chk_proc(void)
{
int i;
DWORD Proc[1024], ByteNum, ProcNum;
if( !EnumProcesses( Proc, sizeof(Proc), &ByteNum ) )
return FALSE;
ProcNum = ByteNum / sizeof(DWORD);
HANDLE hProc;
HMODULE hMod;
TCHAR ProcName[ len+len ];
for( i=0; i<ProcNum; i++ ){
hProc = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE, Proc[i] );
if( EnumProcessModules( hProc, &hMod, sizeof(hMod), &ByteNum ) ){
GetModuleBaseName( hProc, hMod, ProcName, len+len );
if( wcscmp( fn_exec, ProcName ) == 0 ) return FALSE;
GetModuleFileNameEx( hProc, hMod, ProcName, len+len );
if( wcscmp( fn_exec, ProcName ) == 0 ) return FALSE;
}//if(EnumProcessModules)
CloseHandle( hProc );
}//for(i)
return TRUE;
}//chk_proc() end
BOOL CALLBACK EnumWinProc(HWND hwnd, LPARAM lParam)
{
TCHAR str[len];
DWORD PID=1;
GetWindowThreadProcessId(hwnd, &PID);
++gcnt;
if( (DWORD)lParam == PID ){
GetWindowText( hwnd, str, len );
for( int i=0; i<dcnt; ++i ){
if( 0 == wcscmp( str, cap[i] ) && FALSE == done[i] ){
SetForegroundWindow( hwnd );
keybd_event( VK_ESCAPE, 0, 0, 0 );
done[i] = TRUE;
break;
}//if( 0== )
}//for(i)
Sleep(120);
return TRUE;
}//if( 0< )
else return gcnt<0xffffff;
}//EnumWinProc() end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -