home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / ProjectX1_562922192002.psc / ModulesCode / modCodeX3.bas < prev    next >
Encoding:
BASIC Source File  |  1997-02-19  |  1.7 KB  |  66 lines

  1. Attribute VB_Name = "modCodeX3"
  2.  
  3. Const VK_H = 72
  4. Const VK_E = 69
  5. Const VK_L = 76
  6. Const VK_O = 79
  7. Const KEYEVENTF_KEYUP = &H2
  8. Const INPUT_MOUSE = 0
  9. Const INPUT_KEYBOARD = 1
  10. Const INPUT_HARDWARE = 2
  11. Private Type MOUSEINPUT
  12.   dx As Long
  13.   dy As Long
  14.   mouseData As Long
  15.   dwFlags As Long
  16.   time As Long
  17.   dwExtraInfo As Long
  18. End Type
  19. Private Type KEYBDINPUT
  20.   wVk As Integer
  21.   wScan As Integer
  22.   dwFlags As Long
  23.   time As Long
  24.   dwExtraInfo As Long
  25. End Type
  26. Private Type HARDWAREINPUT
  27.   uMsg As Long
  28.   wParamL As Integer
  29.   wParamH As Integer
  30. End Type
  31. Private Type GENERALINPUT
  32.   dwType As Long
  33.   xi(0 To 23) As Byte
  34. End Type
  35. Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As GENERALINPUT, ByVal cbSize As Long) As Long
  36. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
  37.  
  38. Public Sub TvSendKey(bKey As Byte)
  39. '-----------------------------------
  40. '-    TvSendKey()
  41. '-
  42. '- It'll send a key to current focus(window)
  43. '-
  44. '-     By T-Virus Creations
  45. '- http://www.tvirusonline.be
  46. '- email: tvirus4ever@yahoo.co.uk
  47. '-
  48. '-----------------------------------
  49.  
  50.     Dim GInput(0 To 1) As GENERALINPUT
  51.     Dim KInput As KEYBDINPUT
  52.     KInput.wVk = bKey  'the key we're going to press
  53.     KInput.dwFlags = 0 'press the key
  54.     GInput(0).dwType = INPUT_KEYBOARD   ' keyboard input
  55.     CopyMemory GInput(0).xi(0), KInput, Len(KInput)
  56.     KInput.wVk = bKey  ' the key we're going to realease
  57.     KInput.dwFlags = KEYEVENTF_KEYUP  ' release the key
  58.     GInput(1).dwType = INPUT_KEYBOARD  ' keyboard input
  59.     CopyMemory GInput(1).xi(0), KInput, Len(KInput)
  60.     Call SendInput(2, GInput(0), Len(GInput(0)))
  61. End Sub
  62.  
  63.  
  64.  
  65.  
  66.