KeybMouse




Type mouse
Pointa As Long
Pointb As Long
End Type

Global Const LEFTT = 37
Global Const RIGHTT = 39
Global Const UPP = 38
Global Const DOWNN = 40

Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202

Declare Function sendmessagebynum& Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long)

Declare Function GetCursorPos Lib "user32" _
(lpPoint As mouse) As Long

Declare Function WindowFromPoint Lib "user32" _
(ByVal xPoint As Long, ByVal yPoint As Long) As Long

Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long

Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long

Sub StayOnTop(frm As Form)
SetWinOnTop = SetWindowPos(frm.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1)
End Sub

Sub click()
Dim zzz As mouse
Dim click%, Click2%
Call GetCursorPos(zzz)
hhh = WindowFromPoint(zzz.Pointa, zzz.Pointb)
click% = sendmessagebynum(hhh, WM_LBUTTONDOWN, &HD, 0)
Click2% = sendmessagebynum(hhh, WM_LBUTTONUP, &HD, 0)
End Sub


'Aggiungere questo codice in un modulo BAS


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1.Caption = "down"
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If Label1.Caption = "down" Then Else Exit Sub
Dim www As mouse
Call GetCursorPos(www)
If KeyAscii = 48 Then Call click
If KeyAscii = 49 Then da = SetCursorPos(www.Pointa - 10, www.Pointb + 10)
If KeyAscii = 50 Then da = SetCursorPos(www.Pointa, www.Pointb + 10)
If KeyAscii = 51 Then da = SetCursorPos(www.Pointa + 10, www.Pointb + 10)
If KeyAscii = 52 Then da = SetCursorPos(www.Pointa - 10, www.Pointb)

If KeyAscii = 53 Then
MsgBox "Esci"
End
End If

If KeyAscii = 54 Then da = SetCursorPos(www.Pointa + 10, www.Pointb)
If KeyAscii = 55 Then da = SetCursorPos(www.Pointa - 10, www.Pointb - 10)
If KeyAscii = 56 Then da = SetCursorPos(www.Pointa, www.Pointb - 10)
If KeyAscii = 57 Then da = SetCursorPos(www.Pointa + 10, www.Pointb - 10)
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1.Caption = ""
End Sub

Private Sub Form_Load()
StayOnTop Me
MsgBox "Premere 1,2,3,4,6,7,8,9 per muovere " & _
" 0 per il click e 5 per chiudere"
End Sub
Creare un Form settare la proprieta keypreview a true e la
proprieta visible a false

inserire una Label ed una TextBox










( keybmouse.html )- by Paolo Puglisi - Modifica del 17/12/2023