Private Declare Sub GetKeyboardState Lib "user32" (lpKeyState As Any)
Private Declare Sub SetKeyboardState Lib "user32" (lpKeyState As Any)
声明错了。改成
Private Declare Sub GetKeyboardState Lib "user32" (byref lpKeyState As byte)
Private Declare Sub SetKeyboardState Lib "user32" (byref lpKeyState As byte)