能不能用vb写一个小程序,把鼠标的移动映射到键盘按键?
另外,要求在全局状态下实现,也就是把窗体最小化之后,仍然有效。
例如:
鼠标向上移动,映射到键盘上的↑键
鼠标向下移动,映射到键盘上的↓键
鼠标向左移动,映射到键盘上的←键
鼠标向右移动,映射到键盘上的→键 展开
'在窗口添加个 Timer 控件 ,
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim Tx As Long, Ty As Long, P As POINTAPI
Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
GetCursorPos P
Tx = P.x
Ty = P.y
End Sub
Private Sub Timer1_Timer()
Dim ttx, tty
GetCursorPos P
ttx = Tx - P.x
tty = Ty - P.y
If ttx > 0 Then
SendKeys "{LEFT}"
ElseIf ttx < 0 Then
SendKeys "{RIGHT}"
End If
If tty > 0 Then
SendKeys "{UP}"
ElseIf tty < 0 Then
SendKeys "{down}"
End If
Tx = P.x
Ty = P.y
End Sub