Private Type Msg hwnd As Long Message As Long wParam As Long lParam As Long time As Long End Type Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long Private Declare Function WaitMessage Lib "user32" () As Long Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private monhwnd As Long, basta As Boolean Private Sub userform_Initialize() monhwnd = FindWindowA(vbNullString, Me.Caption) basta = False RegisterHotKey monhwnd, &HBFFF&, 0, vbKeyA Show ProcessMessages End Sub Private Sub ProcessMessages() Dim Message As Msg Do While Not basta WaitMessage If PeekMessage(Message, monhwnd, &H312, &H312, &H1) Then MsgBox "voila ! tu viens de presser la touche A ! mets ici tes instructions à la ^place de ce msgbox" End If DoEvents Loop End Sub Private Sub UserForm_Terminate() basta = True UnregisterHotKey monhwnd, &HBFFF& End Sub
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 65 Then MsgBox "essai passé coup suivant" Application.Wait Now + TimeValue("00:00:3") j1.Value = True End If End Sub '*************************************************************************** '******************* programme principal *********************************** '***** quand la partie commence et que je suis en deuxième de parole ****** Private Sub j2_Click() j1.Enabled = False position = 2 nb_main_joue = nb_main_joue + 1 nbmain.Caption = nb_main_joue anbbluff.Caption = Int((nb_bluff / nb_main_joue) * 100) & "%" '1. j'efface et j'affiche la réaction de mon adversaire avant flop effacer_texte reaction_adversaire2.Visible True: reac1_adversaire2.Visible True: reac2_adversaire2.Visible = True reac3_adversaire2.Visible True: reac4_adversaire2.Visible True: reac5_adversaire2.Visible = True texte1_reaction_adversaire2.Visible True: texte2_reaction_adversaire2.Visible True texte3_reaction_adversaire2.Visible True: texte4_reaction_adversaire2.Visible True texte5_reaction_adversaire2.Visible = True KeyPreview = True End Sub 'si l'adversaire abandonne Private Sub reac1_adversaire2_Click() effacer_texte j1.Value = True End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question