|
|

楼主 |
发表于 6-4-2026 12:23 PM
|
显示全部楼层
本帖最后由 fodizi 于 6-4-2026 02:08 PM 编辑
#include <stdio.h>
#include <stdbool.h>
#include <windows.h>
#include <winuser.h>
HHOOK hook;
LPMSG msg;
int counter = 0;
bool pausecount = false;
void Stealth()
{
HWND Stealth;
AllocConsole();
Stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(Stealth,SW_SHOWNORMAL);
}
LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam){
if (wParam == WM_KEYDOWN)
{
if (*(char *)lParam == 'P')
{
if(pausecount == false)
{
printf("Pause\n");
pausecount = true;
}else
{
printf("Resume\n");
pausecount = false;
return 0;
}
}
if(pausecount == false){
counter++;
printf("Current count: %d\n", counter);
}
}
return 0;
}
int main() {
Stealth();
hook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, 0);
if (hook != NULL)
puts("All is good" ) ;
else
puts("Something went wrong : (");
while(GetMessage(msg, NULL, 0, 0) > 0) {
TranslateMessage(msg);
DispatchMessage(msg);
}
return 0;
}
|
|