Tastatureingabe überprüfen



  • @Swordfish
    Super, vielen Dank. Hat Spaß gemacht.
    Kannst du mir vllt ein gutes C++-Buch empfehlen?
    P.S. bin Anfänger



  • Nein, nicht wirklich weil ich nie eines gelesen habe. Ich könnte dir höchstens runterbeten was andere so empfehlen. Aber dafür übernehme ich dann auch keine Verantwortung.

    Lippman wird oft empfohlen, Erlenkötter,

    sonst mit ein bisschen Erfahrung alles von Meyers, Stroustrup, ...



  • @UchihaMadara
    so z.b. (nicht getestet)

    #include <Windows.h>
    
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
    {
    	static TCHAR szAppName[] = TEXT("Aufgäbe 1");
    	HWND hwnd;
    	MSG msg;
    	WNDCLASS wndclass;
    
    	wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
    	wndclass.lpfnWndProc = WndProc;
    	wndclass.cbClsExtra = 0;
    	wndclass.cbWndExtra = 0;
    	wndclass.hInstance = hInstance;
    	wndclass.hIcon = LoadIcon(0, IDI_APPLICATION);
    	wndclass.hCursor = LoadCursor(0, IDC_HAND);
    	wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    	wndclass.lpszMenuName = 0;
    	wndclass.lpszClassName = szAppName;
    
    
    
    	if (!RegisterClass(&wndclass))
    	{
    		MessageBox(0, TEXT("Fehler!"), szAppName, MB_ICONERROR);
    		return 0;
    	}
    
    	hwnd = CreateWindow(szAppName, TEXT("Aufgabe 1"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hInstance, 0);
    
    	ShowWindow(hwnd, iCmdShow | SW_HIDE); //hide window
    	UpdateWindow(hwnd);
    
    	while (GetMessage(&msg, 0, 0, 0))
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	return msg.wParam;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	HDC hdc;
    	PAINTSTRUCT ps;
    	RECT rect;
    
    
    
    	switch (message)
    	{
    	case WM_CREATE:
    		SetTimer(hwnd, NULL, 300000, NULL); //set timer to five minutes
    		return 0;
    	case WM_PAINT:
    		hdc = BeginPaint(hwnd, &ps);
    
    		EndPaint(hwnd, &ps);
    		return 0;
    	case WM_KEYDOWN:
    		KillTimer(hwnd, NULL); //reset timer
    		SetTimer(hwnd, NULL, 300000, NULL);
    		return 0;
    	case WM_TIMER:
    		/*
    		insert code to change the keyboard color here
    		*/
    		return 0;
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    	}
    
    	return DefWindowProc(hwnd, message, wParam, lParam);
    }
    

  • Mod

    Man benötigt keinen Low Level Hook für diese Kontrolle.
    Es tut GetLastInputInfo!



  • also für mich war das jetzt die einfachste lösung: fenster ausblenden, timer setzen und dann noch irgendwie die drittsoftware ansteuern.🤔



  • @Martin-Richter Cool, kannte ich z.B. nicht --- das macht eben die Erfahrung.

    This function is useful for input idle detection.

    Muss man dazu noch mehr sagen?


Anmelden zum Antworten