Bloquer le clavier et la souris

BsEtZeOpLhD Messages postés 61 Date d'inscription dimanche 22 décembre 2002 Statut Membre Dernière intervention 29 juin 2005 - 10 avril 2003 à 21:42
_Thy_ Messages postés 33 Date d'inscription mardi 24 août 2004 Statut Membre Dernière intervention 19 septembre 2005 - 30 sept. 2004 à 17:27
Salut.
Je suis sous winXP et j'utilise VC++.
Je chercher a bloquer le clavier ou au moins quelques touches (echap, enter, ctrl, alt, suppr, windows) ainsi que les cliques de la souris.
Si quelqu'un a un (petit) code pouvant expliquer ceci, merci de m'en faire profiter.
Bye.

6 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
10 avril 2003 à 22:10
Faut chercher, deja plusieurs fois que je le mets.
Exemple de chez MS:

#define _WIN32_WINNT 0x0400
#include <Windows.h>

LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
WPARAM wParam, LPARAM lParam) {

BOOL fEatKeystroke = FALSE;

if (nCode == HC_ACTION) {
switch (wParam) {
case WM_KEYDOWN: case WM_SYSKEYDOWN:
case WM_KEYUP: case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam; fEatKeystroke ((p->vkCode VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0));
break;
}
}
return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam, lParam));
}

int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) {

// Install the low-level keyboard & mouse hooks
HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc, hinstExe, 0);
// Keep this app running until we're told to stop
MessageBox(NULL,
TEXT("Alt+Esc, Ctrl+Esc, and Alt+Tab are now disabled.\n")
TEXT("Click "Ok" to terminate this application and re-enable these keys."),
TEXT("Disable Low-Level Keys"), MB_OK);
UnhookWindowsHookEx(hhkLowLevelKybd);
return(0);
}

BruNews, ciao...
0
BsEtZeOpLhD Messages postés 61 Date d'inscription dimanche 22 décembre 2002 Statut Membre Dernière intervention 29 juin 2005
10 avril 2003 à 22:35
Cela fonctionne pour Alt+Tab mais pas pour Ctrl+Alt+Suppr...
Merci.
0
BsEtZeOpLhD Messages postés 61 Date d'inscription dimanche 22 décembre 2002 Statut Membre Dernière intervention 29 juin 2005
10 avril 2003 à 22:46
tu utilise "p->vkCode == VK_TAB" pour savoir si tab est enfonsé...
aurai tu l'équivalent pour la touche Suppr ?

> -------------------------------
> Réponse au message :
> -------------------------------
>
> > Faut chercher, deja plusieurs fois que je le mets.
> > Exemple de chez MS:
> >
> > #define _WIN32_WINNT 0x0400
> > #include <Windows.h>
> >
> > LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
> > WPARAM wParam, LPARAM lParam) {
> >
> > BOOL fEatKeystroke = FALSE;
> >
> > if (nCode == HC_ACTION) {
> > switch (wParam) {
> > case WM_KEYDOWN: case WM_SYSKEYDOWN:
> > case WM_KEYUP: case WM_SYSKEYUP:
> > PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam; > > fEatKeystroke > > ((p->vkCode VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
> > ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
> > ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0));
> > break;
> > }
> > }
> > return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam, lParam));
> > }
> >
> > int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) {
> >
> > // Install the low-level keyboard & mouse hooks
> > HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
> > LowLevelKeyboardProc, hinstExe, 0);
> > // Keep this app running until we're told to stop
> > MessageBox(NULL,
> > TEXT("Alt+Esc, Ctrl+Esc, and Alt+Tab are now disabled.\n")
> > TEXT("Click "Ok" to terminate this application and re-enable these keys."),
> > TEXT("Disable Low-Level Keys"), MB_OK);
> > UnhookWindowsHookEx(hhkLowLevelKybd);
> > return(0);
> > }
> >
> > BruNews, ciao...
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
10 avril 2003 à 22:52
Tu as modifié et testé pour Ctrl+Alt+Suppr?
Moi non, mais normalement pas autorisé.
BruNews, ciao...
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_dominion Messages postés 230 Date d'inscription mardi 21 janvier 2003 Statut Membre Dernière intervention 15 mai 2008
26 juin 2003 à 11:33
Commment il marche ce switch ? Je l'ai essayé mais (kom d'hab) il veut pas marcher (ces prog qui font chier... pfff)

8.:DOMINION:.8
0
_Thy_ Messages postés 33 Date d'inscription mardi 24 août 2004 Statut Membre Dernière intervention 19 septembre 2005
30 sept. 2004 à 17:27
Aparemment ce code ne fonctionne que sous NT/2K/XP. Mais il fonctionne bien :)

J'aurais besoin de la même chose pour win98 (en évitant l'astuce du screensaver, qui fonctionne bien, mais qui me bloque sur autre chose)

En fait je veux simplement désactiver la touche CTRL à tous points de vue, comme si elle n'était plus câblée :
Pu de ctrl+alt+del, plus de ctrl+N qui fait sortir un internet explorer, etc..

*8)
0
Rejoignez-nous