Attribute VB_Name = "winio_key"Public Declare Function MapPhysToLin Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysSize As Long, ByRef PhysMemHandle) As LongPublic Declare Function UnmapPhysicalMemory Lib "WinIo.dll" (ByVal PhysMemHandle, ByVal LinAddr) As BooleanPublic Declare Function GetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByRef PhysVal As Long) As BooleanPublic Declare Function SetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysVal As Long) As BooleanPublic Declare Function GetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByRef PortVal As Long, ByVal bSize As Byte) As BooleanPublic Declare Function SetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByVal PortVal As Long, ByVal bSize As Byte) As BooleanPublic Declare Function InitializeWinIo Lib "WinIo.dll" () As BooleanPublic Declare Function ShutdownWinIo Lib "WinIo.dll" () As BooleanPublic Declare Function InstallWinIoDriver Lib "WinIo.dll" (ByVal DriverPath As String, ByVal Mode As Integer) As BooleanPublic Declare Function RemoveWinIoDriver Lib "WinIo.dll" () As BooleanPublic Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As LongPublic Declare Function timeGetTime Lib "winmm.dll" () As LongPublic Const KBC_KEY_CMD = &H64Public Const KBC_KEY_DATA = &H60Public Const VK_LBUTTON = &H1Public Const VK_RBUTTON = &H2Public Const VK_CANCEL = &H3Public Const VK_MBUTTON = &H4Public Const VK_BACK = &H8Public Const VK_TAB = &H9Public Const VK_CLEAR = &HCPublic Const VK_RETURN = &HDPublic Const VK_SHIFT = &H10Public Const VK_CONTROL = &H11Public Const VK_MENU = &H12Public Const VK_PAUSE = &H13Public Const VK_CAPITAL = &H14Public Const VK_ESCAPE = &H1BPublic Const VK_SPACE = &H20Public Const VK_PRIOR = &H21Public Const VK_NEXT = &H22Public Const VK_END = &H23Public Const VK_HOME = &H24Public Const VK_LEFT = &H25Public Const VK_UP = &H26Public Const VK_RIGHT = &H27Public Const VK_DOWN = &H28Public Const VK_Select = &H29Public Const VK_PRINT = &H2APublic Const VK_EXECUTE = &H2BPublic Const VK_SNAPSHOT = &H2CPublic Const VK_Insert = &H2DPublic Const VK_Delete = &H2EPublic Const VK_HELP = &H2FPublic Const VK_0 = &H30Public Const VK_1 = &H31Public Const VK_2 = &H32Public Const VK_3 = &H33Public Const VK_4 = &H34Public Const VK_5 = &H35Public Const VK_6 = &H36Public Const VK_7 = &H37Public Const VK_8 = &H38Public Const VK_9 = &H39Public Const VK_A = &H41Public Const VK_B = &H42Public Const VK_C = &H43Public Const VK_D = &H44Public Const VK_E = &H45Public Const VK_F = &H46Public Const VK_G = &H47Public Const VK_H = &H48Public Const VK_I = &H49Public Const VK_J = &H4APublic Const VK_K = &H4BPublic Const VK_L = &H4CPublic Const VK_M = &H4DPublic Const VK_N = &H4EPublic Const VK_O = &H4FPublic Const VK_P = &H50Public Const VK_Q = &H51Public Const VK_R = &H52Public Const VK_S = &H53Public Const VK_T = &H54Public Const VK_U = &H55Public Const VK_V = &H56Public Const VK_W = &H57Public Const VK_X = &H58Public Const VK_Y = &H59Public Const VK_Z = &H5APublic Const VK_STARTKEY = &H5BPublic Const VK_CONTEXTKEY = &H5DPublic Const VK_NUMPAD0 = &H60Public Const VK_NUMPAD1 = &H61Public Const VK_NUMPAD2 = &H62Public Const VK_NUMPAD3 = &H63Public Const VK_NUMPAD4 = &H64Public Const VK_NUMPAD5 = &H65Public Const VK_NUMPAD6 = &H66Public Const VK_NUMPAD7 = &H67Public Const VK_NUMPAD8 = &H68Public Const VK_NUMPAD9 = &H69Public Const VK_MULTIPLY = &H6APublic Const VK_ADD = &H6BPublic Const VK_SEPARATOR = &H6CPublic Const VK_SUBTRACT = &H6DPublic Const VK_DECIMAL = &H6EPublic Const VK_DIVIDE = &H6FPublic Const VK_F1 = &H70Public Const VK_F2 = &H71Public Const VK_F3 = &H72Public Const VK_F4 = &H73Public Const VK_F5 = &H74Public Const VK_F6 = &H75Public Const VK_F7 = &H76Public Const VK_F8 = &H77Public Const VK_F9 = &H78Public Const VK_F10 = &H79Public Const VK_F11 = &H7APublic Const VK_F12 = &H7BPublic Const VK_F13 = &H7CPublic Const VK_F14 = &H7DPublic Const VK_F15 = &H7EPublic Const VK_F16 = &H7FPublic Const VK_F17 = &H80Public Const VK_F18 = &H81Public Const VK_F19 = &H82Public Const VK_F20 = &H83Public Const VK_F21 = &H84Public Const VK_F22 = &H85Public Const VK_F23 = &H86Public Const VK_F24 = &H87Public Const VK_NUMLOCK = &H90Public Const VK_OEM_SCROLL = &H91Public Const VK_OEM_1 = &HBAPublic Const VK_OEM_PLUS = &HBBPublic Const VK_OEM_COMMA = &HBCPublic Const VK_OEM_MINUS = &HBDPublic Const VK_OEM_PERIOD = &HBEPublic Const VK_OEM_2 = &HBFPublic Const VK_OEM_3 = &HC0Public Const VK_OEM_4 = &HDBPublic Const VK_OEM_5 = &HDCPublic Const VK_OEM_6 = &HDDPublic Const VK_OEM_7 = &HDEPublic Const VK_OEM_8 = &HDFPublic Const VK_ICO_F17 = &HE0Public Const VK_ICO_F18 = &HE1Public Const VK_OEM102 = &HE2Public Const VK_ICO_HELP = &HE3Public Const VK_ICO_00 = &HE4Public Const VK_ICO_CLEAR = &HE6Public Const VK_OEM_RESET = &HE9Public Const VK_OEM_JUMP = &HEAPublic Const VK_OEM_PA1 = &HEBPublic Const VK_OEM_PA2 = &HECPublic Const VK_OEM_PA3 = &HEDPublic Const VK_OEM_WSCTRL = &HEEPublic Const VK_OEM_CUSEL = &HEFPublic Const VK_OEM_ATTN = &HF0Public Const VK_OEM_FINNISH = &HF1Public Const VK_OEM_COPY = &HF2Public Const VK_OEM_AUTO = &HF3Public Const VK_OEM_ENLW = &HF4Public Const VK_OEM_BACKTAB = &HF5Public Const VK_ATTN = &HF6Public Const VK_CRSEL = &HF7Public Const VK_EXSEL = &HF8Public Const VK_EREOF = &HF9Public Const VK_PLAY = &HFAPublic Const VK_ZOOM = &HFBPublic Const VK_NONAME = &HFCPublic Const VK_PA1 = &HFDPublic Const VK_OEM_CLEAR = &HFEPublic Function delay(haomiao As Double) Dim t t = timeGetTime While (timeGetTime - t1) < haomiao DoEvents WendEnd FunctionPublic Sub KBCWait4IBE()Dim dwVal As LongDoGetPortVal &H64, dwVal, 1Loop While (dwVal And &H2)End SubPublic Sub KeyDown(ByVal vkeycoad As Long) '按下 KBCWait4IBE SetPortVal KBC_KEY_CMD, &HD2, 1 KBCWait4IBE SetPortVal KBC_KEY_DATA, MapVirtualKey(vkeycoad, 0), 1End SubPublic Sub KeyUp(ByVal vkeycoad As Long) '释放 KBCWait4IBE SetPortVal KBC_KEY_CMD, &HD2, 1 KBCWait4IBE SetPortVal KBC_KEY_DATA, (MapVirtualKey(vkeycoad, 0) Or &H80), 1End SubPublic Sub KeyPress(ByVal vkeycoad As Long) '按键 KeyDown vkeycoad delay 30 KeyUp vkeycoadEnd Sub
需要使用winio驱动,网上找不到的朋友这里也提供下载~!
posted on 2012-11-09 14:12 阅读( ...) 评论( ...)