HotKey

Seth77 Messages postés 572 Date d'inscription mardi 30 avril 2002 Statut Membre Dernière intervention 4 mai 2020 - 20 juil. 2005 à 23:07
CTAC Messages postés 133 Date d'inscription mardi 24 décembre 2002 Statut Membre Dernière intervention 8 juin 2012 - 25 juil. 2005 à 18:40
Slu



comment faire pour aatribuer plusieurs HotKey a un programme ?

Herve

7 réponses

CTAC Messages postés 133 Date d'inscription mardi 24 décembre 2002 Statut Membre Dernière intervention 8 juin 2012 5
21 juil. 2005 à 01:37
0
Seth77 Messages postés 572 Date d'inscription mardi 30 avril 2002 Statut Membre Dernière intervention 4 mai 2020 1
21 juil. 2005 à 10:58
Slu



Merci ce code ne permet que d en mettre un...comment en mettre plusieur sutout a ce niveau :

If
PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE)
Then


Herve
0
CTAC Messages postés 133 Date d'inscription mardi 24 décembre 2002 Statut Membre Dernière intervention 8 juin 2012 5
21 juil. 2005 à 14:42
Bonjour.

Private Type Msg
hWnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As Long
End Type


Private Declare Function RegisterHotKey& _
Lib "user32" _
(ByVal hWnd&, ByVal id&, ByVal fsModifiers&, ByVal vk&)


Private Declare Function UnregisterHotKey& _
Lib "user32" _
(ByVal hWnd&, ByVal id&)


Private Declare Function PeekMessage& _
Lib "user32" Alias "PeekMessageA" _
(lpMsg As Msg, ByVal hWnd&, ByVal wMsgFilterMin&, ByVal wMsgFilterMax&, ByVal wRemoveMsg&)


Private Declare Function WaitMessage& _
Lib "user32" _
()


Private bCancel As Boolean


Private Sub ProcessMessages() Const PM_REMOVE& &H1&, WM_HOTKEY& &H312&
Dim Message As Msg
Do While Not bCancel
WaitMessage
If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
Select Case Message.wParam
Case Is = &HBFFF&
MsgBox "Ctrl-F hotkey"
Case Is = &HBFFE&
MsgBox "Ctrl-A hotkey"
End Select
End If
DoEvents
Loop
End Sub


Private Sub Form_Load()
Const MOD_CONTROL& = &H2&
Dim ret As Long
bCancel = False
ret = RegisterHotKey(Me.hWnd, &HBFFF&, MOD_CONTROL, vbKeyF)
ret = RegisterHotKey(Me.hWnd, &HBFFE&, MOD_CONTROL, vbKeyA)
Me.AutoRedraw = True
Me.Print "Press CTRL-F or CTRL-A"
Show
ProcessMessages
End Sub


Private Sub Form_Unload(Cancel%)
bCancel = True
Call UnregisterHotKey(Me.hWnd, &HBFFF&)
Call UnregisterHotKey(Me.hWnd, &HBFFE&)
End Sub

ctac
0
Seth77 Messages postés 572 Date d'inscription mardi 30 avril 2002 Statut Membre Dernière intervention 4 mai 2020 1
21 juil. 2005 à 16:26
Ahhh merci....



comment tu fais pour avoir la correspondance entre Ctrl-F hotkey et &HBFFF& ???

Herve
0

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

Posez votre question
CTAC Messages postés 133 Date d'inscription mardi 24 décembre 2002 Statut Membre Dernière intervention 8 juin 2012 5
25 juil. 2005 à 15:57
Bonjour.

Je ne comprend pas bien.
C'est toi qui fixe les valeurs avec ces lignes.

ret = RegisterHotKey(Me.hWnd, &HBFFF&, MOD_CONTROL, vbKeyF)
ret = RegisterHotKey(Me.hWnd, &HBFFE&, MOD_CONTROL, vbKeyA)

ctac
0
Seth77 Messages postés 572 Date d'inscription mardi 30 avril 2002 Statut Membre Dernière intervention 4 mai 2020 1
25 juil. 2005 à 15:59
ah d accord ...

on peut donc mettre n importe quelle valeur ?

Herve
0
CTAC Messages postés 133 Date d'inscription mardi 24 décembre 2002 Statut Membre Dernière intervention 8 juin 2012 5
25 juil. 2005 à 18:40
Bonjour.

Ma doc me dit:

Une valeur entre 0 et &HBFFF&

ctac

The RegisterHotKey function defines a hot key for the current thread.


BOOL RegisterHotKey(


HWND hWnd, // window to receive hot-key notification
int id, // identifier of hot key
UINT fsModifiers, // key-modifier flags
UINT vk // virtual-key code
);



Parameters


hWnd


Identifies 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


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


Specifies keys that must be pressed in combination with the key specified by the nVirtKey parameter in order to generate the WM_HOTKEY message. The fsModifiers parameter can be a combination of the following values:


Value Meaning
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.



vk


Specifies the virtual-key code of the hot key.


Return Values


If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.


Remarks


When a key is pressed, the system looks for a match against all thread 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.
0
Rejoignez-nous