[VB]SendKeys Using Native APIS

Learn or Teach General Knowledge Related to Coding or Hacking

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

[VB]SendKeys Using Native APIS

Postby x4NG3L » Wed Nov 25, 2009 11:43 am

This is an exemple to SENDKEYS() Using Native APIS.
SendInput and CopyMemory.

It is GREAT for Make Automation in Games ^^
It is in VB, more u can translate easy to another lenguage.

^^

Code: Select all
'---------------------------------------
'SendKeys Using Native APIS
'mdl By x4NG3L
'SendInput By AllApi
'---------------------------------------
Public Const VK_H = 72
Public Const VK_E = 69
Public Const VK_L = 76
Public Const VK_O = 79
Public Const VK_P = 80
Public Const VK_F = 70
Const KEYEVENTF_KEYUP = &H2
Const INPUT_MOUSE = 0
Const INPUT_KEYBOARD = 1
Const INPUT_HARDWARE = 2
Private Type MOUSEINPUT
  dx As Long
  dy As Long
  mouseData As Long
  dwFlags As Long
  time As Long
  dwExtraInfo As Long
End Type
Private Type KEYBDINPUT
  wVk As Integer
  wScan As Integer
  dwFlags As Long
  time As Long
  dwExtraInfo As Long
End Type
Private Type HARDWAREINPUT
  uMsg As Long
  wParamL As Integer
  wParamH As Integer
End Type
Private Type GENERALINPUT
  dwType As Long
  xi(0 To 23) As Byte
End Type
Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As GENERALINPUT, ByVal cbSize As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Public Sub Sendkey(bKey As Byte)
    Dim GInput(0 To 1) As GENERALINPUT
    Dim KInput As KEYBDINPUT
    KInput.wVk = bKey
    KInput.dwFlags = 0
    GInput(0).dwType = INPUT_KEYBOARD
    CopyMemory GInput(0).xi(0), KInput, Len(KInput)
    KInput.wVk = bKey
    KInput.dwFlags = KEYEVENTF_KEYUP
    GInput(1).dwType = INPUT_KEYBOARD
    CopyMemory GInput(1).xi(0), KInput, Len(KInput)
    Call SendInput(2, GInput(0), Len(GInput(0)))
End Sub
Knowledge is evolving.
User avatar
x4NG3L
Sir Hacks-A-Lot
 
Posts: 31
Joined: Fri Nov 20, 2009 5:20 am

Return to Knowledge Base

Who is online

Users browsing this forum: No registered users and 0 guests