Jinak měl jste pravdu, stačilo v deklaraci funkce změnit long na integer. Pro úplnost sem přidávám správný kód, třeba se bude někomu hodit. Zde je pohyb myši pomocí API:
Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Long
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.Up
Call SetCursorPos(Control.MousePosition.X, Control.MousePosition.Y - 10)
Case Keys.Down
Call SetCursorPos(Control.MousePosition.X, Control.MousePosition.Y + 10)
Case Keys.Left
Call SetCursorPos(Control.MousePosition.X - 10, Control.MousePosition.Y)
Case Keys.Right
Call SetCursorPos(Control.MousePosition.X + 10, Control.MousePosition.Y)
End Select
End Sub
A zde pomocí Frameworku:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.Up
Cursor.Position = New Point(Cursor.Position.X, Cursor.Position.Y - 10)
Case Keys.Down
Cursor.Position = New Point(Cursor.Position.X, Cursor.Position.Y + 10)
Case Keys.Left
Cursor.Position = New Point(Cursor.Position.X - 10, Cursor.Position.Y)
Case Keys.Right
Cursor.Position = New Point(Cursor.Position.X + 10, Cursor.Position.Y)
End Select
End Sub
|