IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API, COM et SDKs Delphi Discussion :

touche pour accéder à une application : hook system?


Sujet :

API, COM et SDKs Delphi

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Septembre 2002
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2002
    Messages : 25
    Points : 22
    Points
    22
    Par défaut touche pour accéder à une application : hook system?
    Est-ce que quelqu'un sait comment implémenter un hook système pour appeler une application Delphi qui n'a pas le focus. J'ai déjà vu ca mais je ne sais plus où. Je crois qu'il faut intercepter la boucle des messages Windows.

    Merci de votre réponse.

  2. #2
    Expert éminent sénior

    Avatar de Nono40
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2002
    Messages
    8 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mai 2002
    Messages : 8 640
    Points : 19 104
    Points
    19 104
    Par défaut
    J'ai réalisé un KeyLogger il y a quelque-temps, il utilise un hook système sur le clavlier, tu peux trouver le source ici :
    http://nono40.fr.st/sources/source0007.html

  3. #3
    Membre à l'essai
    Inscrit en
    Mars 2002
    Messages
    17
    Détails du profil
    Informations forums :
    Inscription : Mars 2002
    Messages : 17
    Points : 20
    Points
    20
    Par défaut
    Il y a aussi beaucoup plus simple, l'API RegisterHotKey:

    Citation Envoyé par MSDN
    The RegisterHotKey function defines a system-wide hot key.

    Syntax

    BOOL RegisterHotKey( HWND hWnd,
    int id,
    UINT fsModifiers,
    UINT vk
    );
    Parameters

    hWnd
    [in] Handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.
    id
    [in] Specifies the identifier of the hot key. No other hot key in the calling thread should have the same identifier. An application must specify a value in the range 0x0000 through 0xBFFF. A shared dynamic-link library (DLL) must specify a value in the range 0xC000 through 0xFFFF (the range returned by the GlobalAddAtom function). To avoid conflicts with hot-key identifiers defined by other shared DLLs, a DLL should use the GlobalAddAtom function to obtain the hot-key identifier.
    fsModifiers
    [in] Specifies keys that must be pressed in combination with the key specified by the uVirtKey parameter in order to generate the WM_HOTKEY message. The fsModifiers parameter can be a combination of the following values.
    MOD_ALT
    Either ALT key must be held down.
    MOD_CONTROL
    Either CTRL key must be held down.
    MOD_SHIFT
    Either SHIFT key must be held down.
    MOD_WIN
    Either WINDOWS key was held down. These keys are labeled with the Microsoft® Windows® logo.
    vk
    [in] Specifies the virtual-key code of the hot key.
    Return Value

    If the function succeeds, the return value is nonzero.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.



    Remarks

    When a key is pressed, the system looks for a match against all hot keys. Upon finding a match, the system posts the WM_HOTKEY message to the message queue of the thread that registered the hot key. This message is posted to the beginning of the queue so it is removed by the next iteration of the message loop.

    This function cannot associate a hot key with a window created by another thread.

    RegisterHotKey fails if the keystrokes specified for the hot key have already been registered by another hot key.

    If the window identified by the hWnd parameter already registered a hot key with the same identifier as that specified by the id parameter, the new values for the fsModifiers and vk parameters replace the previously specified values for these parameters.

    Windows NT4 and Windows 2000/XP: The F12 key is reserved for use by the debugger at all times, so it should not be registered as a hot key. Even when you are not debugging an application, F12 is reserved in case a kernel-mode debugger or a just-in-time debugger is resident.

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Septembre 2002
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2002
    Messages : 25
    Points : 22
    Points
    22
    Par défaut
    Merci à tous les deux.

    J'ai de plus trouvé un exemple de la fonction RegisterHotKey dans le composant TJvApplicationHotKey de la JVCL.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 16/09/2014, 10h36
  2. Réponses: 2
    Dernier message: 22/10/2007, 14h33
  3. Conseils pour developper une application avec Oracle
    Par belugha dans le forum Langages de programmation
    Réponses: 5
    Dernier message: 02/06/2003, 16h03
  4. Droits pour distribuer une application
    Par aliasjcdenton dans le forum JBuilder
    Réponses: 4
    Dernier message: 17/03/2003, 13h15
  5. Réponses: 1
    Dernier message: 13/05/2002, 09h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo