Click here to Skip to main content
15,997,462 members

Comments by mediamcce (Top 4 by date)

mediamcce 24-Jul-16 12:01pm View    
sendkey.send() function using keyup event not use.
mediamcce 5-Jan-16 5:29am View    
any developer solve this problem
mediamcce 4-Jan-16 22:44pm View    
do not solve this problem
mediamcce 4-Jan-16 21:34pm View    
Deleted
Imports System.Runtime.InteropServices
Public Class Form1
Private Const WH_KEYBOARD_LL As Integer = 13
Private Const WM_KEYUP As Integer = &H101
Private Const WM_SYSKEYUP As Integer = &H105
Private proc As LowLevelKeyboardProcDelegate = AddressOf HookCallback
Private hookID As IntPtr
Private Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode As Integer, ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr

<DllImport("user32")> _
Private Shared Function SetWindowsHookEx(ByVal idHook As Integer, ByVal lpfn As LowLevelKeyboardProcDelegate, _
ByVal hMod As IntPtr, ByVal dwThreadId As UInteger) As IntPtr
End Function

<DllImport("user32.dll")> _
Private Shared Function UnhookWindowsHookEx(ByVal hhk As IntPtr) As <marshalas(unmanagedtype.bool)> Boolean
End Function

<DllImport("user32.dll")> _
Private Shared Function CallNextHookEx(ByVal hhk As IntPtr, ByVal nCode As Integer, ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function


<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)> _
Private Shared Function GetModuleHandle(ByVal lpModuleName As String) As IntPtr
End Function

Sub New()
InitializeComponent()
Text = "KeyboardPlus 1.01"
hookID = SetHook(proc)
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
UnhookWindowsHookEx(hookID)
End Sub

Private Function SetHook(ByVal proc As LowLevelKeyboardProcDelegate) As IntPtr
Using curProcess As Process = Process.GetCurrentProcess()
Using curModule As ProcessModule = curProcess.MainModule

Return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0)

End Using
End Using
End Function

Private Function HookCallback(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
' "The WM_KEYUP message is posted to the window with the keyboard focus
' when a nonsystem key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed,
' or a keyboard key that is pressed when a window has the keyboard focus."


If nCode >= 0 AndAlso (wParam.ToInt32 = WM_KEYUP OrElse wParam.ToInt32 = WM_SYSKEYUP) Then
Dim vkCode As Integer = Marshal.ReadInt32(lParam)
'vkCode = Keys.B
If vkCode = Keys.A Then
'SendKeys.Send(vbBack)
If Console.CapsLock = True Then
SendKeys.Send("B")
'vkCode = Keys.B
Else
'vkCode = Keys.B
SendKeys.Send("b")
End If

End If
End If
Return CallNextHookEx(hookID, nCode, wParam, lParam)
End Function

End Class

this coding press a but print ab
i have press a print b