Bonjour,

J'aimerai que lorsque mon application s'ouvre elle désactive et change la touche Entrée pour la touche Tab pas seulement sur le form mais sur n'importe quelle application qui est ouvert en parallèle. J'ai chercher sur google mais je ne trouve rien.

De plus, j'utilise VB2008 et je suis débutant.

J'ai deja un code qui fonctionne a moitier. Il fonctionne sur n'importe quelle application ouvert en parallèle, il detecte la touche entrée quand elle est appuier mais il ne la bloque pas. En d'autres mots, lorsque la touche entrée est appuié le code ne bloque pas la touche entrée mais il appuie sur la touche tab aussi

Merci

__________________________________________________________

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Option Strict On 
Imports System.Runtime.InteropServices 
 
Public Class Form1 
 
Private Const KEYEVENTF_EXTENDEDKEY As Long = &H1 
Private Const KEYEVENTF_KEYUP As Long = &H2 
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _ 
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) 
 
Private Const WH_KEYBOARD_LL As Integer = 13 
Private Const WM_KEYUP As Integer = &H101 
Private Shared _proc As LowLevelKeyboardProc = AddressOf HookCallback 
Private Shared _hookID As IntPtr = IntPtr.Zero 
 
Public Declare Auto Function SetWindowsHookEx Lib "user32.dll" ( _ 
ByVal idHook As Integer, ByVal lpfn As LowLevelKeyboardProc, _ 
ByVal hMod As IntPtr, ByVal dwThreadId As UInteger) As IntPtr 
 
Public Declare Auto Function UnhookWindowsHookEx _ 
Lib "user32.dll" (ByVal hhk As IntPtr) As IntPtr 
 
Public Declare Auto Function CallNextHookEx _ 
Lib "user32.dll" (ByVal hhk As IntPtr, ByVal nCode As Integer, _ 
ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr 
 
Public Declare Auto Function GetModuleHandle Lib "kernel32.dll" ( _ 
ByVal lpModuleName As String) As IntPtr 
 
 
Private Shared Function SetHook( _ 
ByVal proc As LowLevelKeyboardProc) As IntPtr 
 
Dim curProcess As Process = Process.GetCurrentProcess() 
Dim curModule As ProcessModule = curProcess.MainModule 
 
Return SetWindowsHookEx(WH_KEYBOARD_LL, proc, _ 
GetModuleHandle(curModule.ModuleName), 0) 
 
End Function 
 
Public Delegate Function LowLevelKeyboardProc( _ 
ByVal nCode As Integer, ByVal wParam As IntPtr, _ 
ByVal lParam As IntPtr) As IntPtr 
 
Public Shared Function HookCallback( _ 
ByVal nCode As Integer, _ 
ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr 
 
If nCode >= 0 And wParam = CType(WM_KEYUP, IntPtr) Then 
Dim vkCode As Keys = CType(Marshal.ReadInt32(lParam), Keys) 
If vkCode = Keys.Return Or vkCode = Keys.Enter Then 
keybd_event(CByte(Keys.Tab), 0, KEYEVENTF_EXTENDEDKEY, 0) 
End If 
End If 
 
Return CallNextHookEx(_hookID, nCode, wParam, lParam) 
End Function 
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
_hookID = SetHook(_proc) 
End Sub 
 
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed 
UnhookWindowsHookEx(_hookID) 
End Sub 
 
End Class