The story behind being praised by millions of people is the support of beauty or the improvement of technology?

Keywords: Linker Java Windows

Do you guys have a live class? Do you like your lovely teacher? Is it over a million?

At least we do.

There's no doubt that it can't be broken by hand. It's just over 30 people. This paper introduces the principle of the mouse connector.

1, Mouse event

The key to the implementation of the linker is the mouse event function, but there is a difference between this function and other functions, that is, the naming format. Generally, this style rarely appears in Win API. I don't know why. It's like Hashtable in Java, but it doesn't affect our use.

Mouse event indicates that it has been replaced by SendInput in MSDN, but SendInput does not know much about it. Let's introduce mouse event.

dwFlags: this parameter indicates that the key is pressed. The values are as follows.

MOUSEEVENTF_ABSOLUTE dX and dY parameters contain normalized absolute coordinates
MOUSEEVENTF_LEFTDOWN Left button pressed
MOUSEEVENTF_LEFTUP Left button up
MOUSEEVENTF_MIDDLEDOWN Middle button pressed
MOUSEEVENTF_MIDDLEUP Middle button up
MOUSEEVENTF_MOVE move
MOUSEEVENTF_RIGHTDOWN Right button pressed
MOUSEEVENTF_RIGHTUP Right button up
MOUSEEVENTF_WHEEL pulley

...
dx: Specifies the absolute position of the mouse along the x axis or the number of mouse movements since the last mouse event, depending on the mouseeventf ﹣ absolute setting.

dy: Specifies the absolute position of the mouse along the y axis or the number of mouse movements since the last mouse event, depending on the setting of mouseeventf? Absolute.

dwData: if dwFlags is mouseeventf? Wheel, dwData specifies the number of mouse wheel moves. A positive value indicates that the mouse wheel rotates forward, and a negative value indicates that the mouse wheel rotates backward, that is, toward the user.

dwExtralnfo: Specifies the additional 32-bit value associated with the mouse event.

So finally, a left key press and lift operation is completed, that is, a line.

mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0.

It's not enough to know how to simulate, because there is still a hotkey to start the pause.

2, Registerhhotkey

This is used to register hotkeys, such as our QQ screenshot shortcut key Ctrl+Alt+A or wechat screenshot shortcut key Ctlr+A.

hWnd: handle to the window.
id: hotkey identifier.
fsModifiers: take the following values, that is, you can indicate whether the hotkey has Ctrl, Alt and other keys.

MOD_ALT Alt key
MOD_SHIFT Shift key
MOD_WIN Windows key
MOD_NOREPEAT Change hotkey behavior so that automatic keyboard repetition does not result in multiple hotkey notifications
MOD_CONTROL Ctrl key

vk: indicates the virtual key code. For example, if the hotkey is A, it is 65.

This function specifically deals with the WM? Hotkey message that the window function will receive when the hotkey is triggered in the window function. wParam is the hot key identifier passed in above. The lower part of lParam represents the value of fsModifiers and the higher part represents the value of vk.

There is no better way to develop small programs like VB, but VB encapsulates window functions, so we need GetWindowLong and SetWindowLong to modify the default window functions.

WndFunchw = GetWindowLong(Me.hwnd, GWL_WNDPROC)
Call SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf Proc)

In order to prevent the mouse from being moved by mistake after the start of simulation click, so it is necessary to keep the mouse from moving to other positions after the start. GetCursorPos and SetCursorPos are the easiest to use.

GetCursorPos gets the mouse position at the beginning and saves it. SetCursorPos is to set the mouse position.

3, Full code

Module

Public Declare Function RegisterHotKey Lib "user32.dll" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Public Declare Function UnregisterHotKey Lib "user32.dll" (ByVal hwnd As Long, ByVal id As Long) As Long
Public Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Type POINTAPI
X As Long
Y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Declare Function SetCursorPos Lib "user32.dll" (ByVal X As Long, ByVal Y As Long) As Long

Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC As Long = -4

Public Const WM_HOTKEY As Long = &H312


Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Public Const MOUSEEVENTF_MOVE = &H1
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_ABSOLUTE = &H8000
Public Const HOTLEFT As Integer = 1
Public Const HOTUP As Integer = 2
Public Const HOTRIGHT As Integer = 3
Public Const HOTDOWN As Integer = 4
Public Const HOT_KEY_ID As Integer = 5
Public Const MOD_ALT As Long = &H1
Public Const MOD_CONTROL As Long = &H2

Public hWndFunc As Long
Public isPlay As Boolean
Public mCruuentPoint As POINTAPI

Public Function Proc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Select Case Msg
Case WM_HOTKEY
    If wParam = HOT_KEY_ID Then
        If isPlay = False Then
            Call GetCursorPos(mCruuentPoint)
        End If
        isPlay = Not isPlay
        Form1.Timer1.Enabled = isPlay
    End If

End Select

Proc = CallWindowProc(hWndFunc, hwnd, Msg, wParam, lParam)
End Function

forms

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1

hWndFunc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
Call SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf Proc)
Dim r As Long
r = RegisterHotKey(Me.hwnd, HOT_KEY_ID, MOD_CONTROL, Asc("B"))
 If r = 0 Then
    MsgBox "Hotkey registration failed, please turn off using direction key as ALT+S Procedure"
   rk = False
 End If
Label2.Caption = "Move the mouse to like button,security Ctrl+B Key start\suspend"

End Sub

Private Sub Label2_Click()
	Static count As Long
	count = count + 1
	Me.Caption = count
End Sub

Private Sub Timer1_Timer()
	SetCursorPos mCruuentPoint.X, mCruuentPoint.Y
	Label1.Caption = "Start crazy output"
	mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

Published 45 original articles, won praise 7, visited 8120
Private letter follow

Posted by RobNewYork on Mon, 09 Mar 2020 01:25:58 -0700