Hola,
Usa SendKeys.Send("abcd")
Aquí muestro la lista:
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER}or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC} (reserved for future use)
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
Keypad add {ADD}
Keypad subtract {SUBTRACT}
Keypad multiply {MULTIPLY}
Keypad divide {DIVIDE}
COMBINACIONES DE TECLAS
SHIFT +
CTRL ^
ALT %
Adjunto un zip sobre SendKeysToWindow. Tengo un ejemplo de como desactivar las teclas Ctrl + Alt + Supr, no sé si te sirve de algo...
Código:
'Up at the very top !!!
Imports System.Threading
Imports System.Reflection
Imports System.Runtime.InteropServices
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
HookKeyboard()
apiSystemParametersInfoA(SPI_SETKEYBOARDDELAY, -1, 0, 0)
apiSystemParametersInfoA(SPI_SETKEYBOARDSPEED, 1, 0, 0)
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
UnhookKeyboard()
apiSystemParametersInfoA(SPI_SETKEYBOARDDELAY, 20, 0, 0)
apiSystemParametersInfoA(SPI_SETKEYBOARDSPEED, 20, 0, 0)
End Sub
Public Function IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean
On Error Resume Next
' block task manager from the ctrl alt delete combo
If (Hookstruct.vkCode = Keys.Delete Or CBool(GetAsyncKeyState(Keys.Delete) And &H8000) = True) And (Hookstruct.vkCode = VK_CONTROL Or CBool(GetAsyncKeyState(VK_CONTROL) And &H8000) = True) And (Hookstruct.vkCode = Keys.Menu Or CBool(GetAsyncKeyState(Keys.Menu) And &H8000) = True) Then
Dim t As New Thread(AddressOf KillTask)
t.Start()
Return True
End If
'block task manager from the control alt escape combo
If (Hookstruct.vkCode = Keys.Escape Or CBool(GetAsyncKeyState(Keys.Escape) And &H8000) = True) And CBool(GetAsyncKeyState(VK_CONTROL) And &H8000) And CBool(GetAsyncKeyState(Keys.Shift) And &H8000) Then
Dim t As New Thread(AddressOf KillTask)
t.Start()
Return True
End If
If (Hookstruct.vkCode = Keys.RWin) Then 'block right win key, or any single key press like this
Return True
End If
If (Hookstruct.vkCode = Keys.LWin) Then 'block left win key
Return True
End If
'Block ctrl escape Stops from opening the start menu, as above with win keys.
If CBool(GetAsyncKeyState(VK_CONTROL) And &H8000) And (Hookstruct.vkCode = Keys.Escape) Then
Return True
End If
'Block control F4 Stops the closing of a window within an application without closing the main application
If CBool(GetAsyncKeyState(VK_CONTROL) And &H8000) And (Hookstruct.vkCode = Keys.F4) Then
Return True
End If
'Block Alt F4 from directly closing this the application
If CBool(GetAsyncKeyState(Keys.Menu) And &H8000) And (Hookstruct.vkCode = Keys.F4) Then
Return True
End If
'Block Alt Space Stops the opening of the titlebar menu, that can close the alt+f4 combo above
If CBool(GetAsyncKeyState(Keys.Menu) And &H8000) And (Hookstruct.vkCode = Keys.Space) Then
Return True
End If
'Stop from switching focus to previous application
If CBool(GetAsyncKeyState(Keys.Menu) And &H8000) And (Hookstruct.vkCode = Keys.Tab) Then
Return True
End If
'Stop from switching focus to previous application
If CBool(GetAsyncKeyState(Keys.Menu) And &H8000) And (Hookstruct.vkCode = Keys.Escape) Then
Return True
End If
'block any keys you like here
Return False
End Function
Public Sub KillTask()
On Error Resume Next
Dim i As Integer
Do
Dim clt() As Process = Process.GetProcessesByName("taskmgr")
For Each p As Process In clt
p.Kill()
Next
Thread.Sleep(1)
i += 1
If i = 100 Then
Exit Do
End If
Loop
End Sub
Const VK_CONTROL As Integer = &H11
Const SPI_SETKEYBOARDDELAY As Integer = 23
Const SPI_SETKEYBOARDSPEED As Integer = 11
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scanCode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure
Public Delegate Function KeyboardHookDelegate(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
<MarshalAs(UnmanagedType.FunctionPtr)> Private callback As KeyboardHookDelegate
Public KeyboardHandle As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As KeyboardHookDelegate, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As KBDLLHOOKSTRUCT) As Integer
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Integer) As Integer
Public Declare Function apiSystemParametersInfoA Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As Integer, ByVal fuWinIni As Integer) As Integer
Dim clt() As Process = Process.GetProcessesByName("taskmgr")
Dim t As New Thread(AddressOf KillTask)
Public Sub HookKeyboard()
callback = New KeyboardHookDelegate(AddressOf KeyboardCallback)
KeyboardHandle = SetWindowsHookEx(13&, callback, Marshal.GetHINSTANCE([Assembly].GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
End Sub
Public Sub UnhookKeyboard()
If (Hooked()) Then
Call UnhookWindowsHookEx(KeyboardHandle)
End If
End Sub
Private Function Hooked()
Hooked = KeyboardHandle <> 0
End Function
Public Function KeyboardCallback(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
If (Code = 0) Then
If (IsHooked(lParam)) Then
Return 1
End If
End If
Return CallNextHookEx(KeyboardHandle, Code, wParam, lParam)
End Function Un saludo :-)