朋友玩倚天帮忙做个自动按键程序 经不管用 像各位高手请教问题 在游戏里按1-9为快捷键 按键盘管用
我用程序就不管用我用了两种方法都不行1.
SendKeys2.
    keybd_event 49, 0, 0, 0
    keybd_event 49, 0, KEYEVENTF_KEYUP, 0

解决方案 »

  1.   

    请楼下的弟兄给出
    键盘的全部代码
    就是可以在API里被调用的
    我也说不好。
    我是初学者
      

  2.   


    sendkeys里调用
    按键 代码 
    BACKSPACE {BACKSPACE}, {BS}, 或 {BKSP} 
    BREAK {BREAK} 
    CAPS LOCK {CAPSLOCK} 
    DEL or DELETE {DELETE} 或 {DEL} 
    DOWN ARROW {DOWN} 
    END {END} 
    ENTER  {ENTER}或 ~ 
    ESC {ESC} 
    HELP {HELP} 
    HOME {HOME} 
    INS or INSERT {INSERT} 或 {INS} 
    LEFT ARROW {LEFT} 
    NUM LOCK {NUMLOCK} 
    PAGE DOWN {PGDN} 
    PAGE UP {PGUP} 
    PRINT SCREEN {PRTSC} 
    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} 
    为了指定那些与 SHIFT、CTRL 及 ALT 等按键结合的组合键,可在这些按键码的前面放置一个或多个代码,这些代码列举如下:按键 代码 
    SHIFT + 
    CTRL  ^ 
    ALT % 
    为了说明在按下其它按键时应同时按下 SHIFT、CTRL、及 ALT 的任意组合键,请把那些按键的码放在括号当中。例如,为了说明按下 E 与 C 的时候同时按下 SHIFT 键,请使用 "+(EC)"。为了说明在按下 E 的时候同时按下 SHIFT 键,但接着按 C 而不按 SHIFT,则使用 "+EC"。为了指定重复键,使用 {key number} 的形式。必须在 key 与 number 之间放置一个空格。例如,{LEFT 42} 意指 42 次按下 LEFT ARROW 键;{h 10} 则是指 10 次按下 H 键。注意 不能用 SendKeys 将按键消息发送到这样一个应用程序,这个应用程序并没有被设计成在 Microsoft Windows 中运行。Sendkeys 也无法将 PRINT SCREEN 按键 {PRTSC} 发送到任何应用程序。
    api常数
    ' Virtual Keys, Standard Set
    Const VK_LBUTTON = &H1
    Const VK_RBUTTON = &H2
    Const VK_CANCEL = &H3
    Const VK_MBUTTON = &H4             '  NOT contiguous with L RBUTTONConst VK_BACK = &H8
    Const VK_TAB = &H9Const VK_CLEAR = &HC
    Const VK_RETURN = &HDConst VK_SHIFT = &H10
    Const VK_CONTROL = &H11
    Const VK_MENU = &H12
    Const VK_PAUSE = &H13
    Const VK_CAPITAL = &H14Const VK_ESCAPE = &H1BConst VK_SPACE = &H20
    Const VK_PRIOR = &H21
    Const VK_NEXT = &H22
    Const VK_END = &H23
    Const VK_HOME = &H24
    Const VK_LEFT = &H25
    Const VK_UP = &H26
    Const VK_RIGHT = &H27
    Const VK_DOWN = &H28
    Const VK_SELECT = &H29
    Const VK_PRINT = &H2A
    Const VK_EXECUTE = &H2B
    Const VK_SNAPSHOT = &H2C
    Const VK_INSERT = &H2D
    Const VK_DELETE = &H2E
    Const VK_HELP = &H2F' VK_A thru VK_Z are the same as their ASCII equivalents: 'A' thru 'Z'
    ' VK_0 thru VK_9 are the same as their ASCII equivalents: '0' thru '9'Const VK_NUMPAD0 = &H60
    Const VK_NUMPAD1 = &H61
    Const VK_NUMPAD2 = &H62
    Const VK_NUMPAD3 = &H63
    Const VK_NUMPAD4 = &H64
    Const VK_NUMPAD5 = &H65
    Const VK_NUMPAD6 = &H66
    Const VK_NUMPAD7 = &H67
    Const VK_NUMPAD8 = &H68
    Const VK_NUMPAD9 = &H69
    Const VK_MULTIPLY = &H6A
    Const VK_ADD = &H6B
    Const VK_SEPARATOR = &H6C
    Const VK_SUBTRACT = &H6D
    Const VK_DECIMAL = &H6E
    Const VK_DIVIDE = &H6F
    Const VK_F1 = &H70
    Const VK_F2 = &H71
    Const VK_F3 = &H72
    Const VK_F4 = &H73
    Const VK_F5 = &H74
    Const VK_F6 = &H75
    Const VK_F7 = &H76
    Const VK_F8 = &H77
    Const VK_F9 = &H78
    Const VK_F10 = &H79
    Const VK_F11 = &H7A
    Const VK_F12 = &H7B
    Const VK_F13 = &H7C
    Const VK_F14 = &H7D
    Const VK_F15 = &H7E
    Const VK_F16 = &H7F
    Const VK_F17 = &H80
    Const VK_F18 = &H81
    Const VK_F19 = &H82
    Const VK_F20 = &H83
    Const VK_F21 = &H84
    Const VK_F22 = &H85
    Const VK_F23 = &H86
    Const VK_F24 = &H87Const VK_NUMLOCK = &H90
    Const VK_SCROLL = &H91'
    '   VK_L VK_R - left and right Alt, Ctrl and Shift virtual keys.
    '   Used only as parameters to GetAsyncKeyState() and GetKeyState().
    '   No other API or message will distinguish left and right keys in this way.
    '  /
    Const VK_LSHIFT = &HA0
    Const VK_RSHIFT = &HA1
    Const VK_LCONTROL = &HA2
    Const VK_RCONTROL = &HA3
    Const VK_LMENU = &HA4
    Const VK_RMENU = &HA5Const VK_ATTN = &HF6
    Const VK_CRSEL = &HF7
    Const VK_EXSEL = &HF8
    Const VK_EREOF = &HF9
    Const VK_PLAY = &HFA
    Const VK_ZOOM = &HFB
    Const VK_NONAME = &HFC
    Const VK_PA1 = &HFD
    Const VK_OEM_CLEAR = &HFE按键动作常数
    Public Const WM_KEYDOWN = &H100Public Const WM_KEYFIRST = &H100Public Const WM_KEYLAST = &H108Public Const WM_KEYUP = &H101
      

  3.   

    我有一个键盘接收程序,很简单,只要加入text1就行了:注意:1-9和F1-F12显示的值,你去试试Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As IntegerDim read As IntegerPrivate Sub Timer1_Timer()
    Dim addkeyKey = GetAsyncKeyState(1)
    If Key = -32767 Then
        addkey = "(左键)"
        leftkey = leftkey + 1
        GoTo keyfound
    End IfKey = GetAsyncKeyState(9)If Key = -32767 Then
        addkey = "[TAB]"
        GoTo keyfound
    End IfKey = GetAsyncKeyState(13)
    If Key = -32767 Then
        addkey = "[ENTER]"
        GoTo keyfound
    End IfKey = GetAsyncKeyState(8)
    If Key = -32767 Then
        addkey = "[BKSPACE]"
        GoTo keyfound
    End IfKey = GetAsyncKeyState(27)
    If Key = -32767 Then
        addkey = "[ESC]"
        GoTo keyfound
    End IfKey = GetAsyncKeyState(16)
    If Key = -32767 Then
        addkey = "[SHIFT]"
        GoTo keyfound
    End If
    Key = GetAsyncKeyState(17)
    If Key = -32767 Then
        addkey = "[CTRL]"
        GoTo keyfound
    End IfKey = GetAsyncKeyState(18)
    If Key = -32767 Then
        addkey = "[ALT]"
        GoTo keyfound
    End IfKey = GetAsyncKeyState(32)
    If Key = -32767 Then
        addkey = "[SPACE]"
        GoTo keyfound
    End IfKey = GetAsyncKeyState(122)
    If Key = -32767 Then
        App.TaskVisible = True
    Exit Sub
    End Ifkeyloop = 41
    Do Until keyloop = 256
        Key = GetAsyncKeyState(keyloop)
        If Key = -32767 Then Text1.Text = Text1.Text + Chr(keyloop)
        keyloop = keyloop + 1
    Loop
    lastkey = addkey
    Exit Subkeyfound:
    Text1.Text = Text1 & addkey
    End Sub