Difference between revisions of "Lua:mouse event"

From Cheat Engine
Jump to navigation Jump to search
(Created page with "<div> The Windows' API "mouse_event". https://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx </div> <pre> setMousePos(659,573) mouse_event(MOUSEEV...")
 
m (Added CodeBox Template.)
 
Line 1: Line 1:
<div>
+
[[Category:Lua]]
The Windows' API "mouse_event". https://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx
+
{{CodeBox|'''function''' mouse_event(''Flags'', [''dx'', ''dy'', ''Data'', ''ExtraInfo'']) ''':''' void}}
</div>
+
 
 +
Calls the Windows API <code>mouse_event</code> directly for advanced mouse control.
 +
See the [https://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx MSDN documentation] for detailed information about the parameters.
 +
 
 +
===Function Parameters===
 +
{|width="85%" cellpadding="5%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|Flags
 +
|Integer
 +
|Specifies various aspects of mouse motion and button clicks.
 +
|-
 +
|dx
 +
|Integer (optional)
 +
|The absolute x-coordinate or relative motion in pixels.
 +
|-
 +
|dy
 +
|Integer (optional)
 +
|The absolute y-coordinate or relative motion in pixels.
 +
|-
 +
|Data
 +
|Integer (optional)
 +
|Additional data, e.g., amount of wheel movement.
 +
|-
 +
|ExtraInfo
 +
|Integer (optional)
 +
|Application-defined extra information.
 +
|}
 +
 
 +
===Returns===
 +
void — This function does not return a value.
 +
 
 +
===Example===
 
<pre>
 
<pre>
  setMousePos(659,573)
+
setMousePos(659, 573)
  mouse_event(MOUSEEVENTF_LEFTDOWN)
+
mouse_event(MOUSEEVENTF_LEFTDOWN)
  sleep(20)
+
sleep(20)
  mouse_event(MOUSEEVENTF_LEFTUP)
+
mouse_event(MOUSEEVENTF_LEFTUP)
 
</pre>
 
</pre>
 +
 +
{{LuaSeeAlso}}
 +
 +
{{KeyboardMouse}}

Latest revision as of 00:00, 5 December 2025

<> Function

function mouse_event(Flags, [dx, dy, Data, ExtraInfo]) : void

Calls the Windows API mouse_event directly for advanced mouse control. See the MSDN documentation for detailed information about the parameters.

Function Parameters[edit]

Parameter Type Description
Flags Integer Specifies various aspects of mouse motion and button clicks.
dx Integer (optional) The absolute x-coordinate or relative motion in pixels.
dy Integer (optional) The absolute y-coordinate or relative motion in pixels.
Data Integer (optional) Additional data, e.g., amount of wheel movement.
ExtraInfo Integer (optional) Application-defined extra information.

Returns[edit]

void — This function does not return a value.

Example[edit]

setMousePos(659, 573)
mouse_event(MOUSEEVENTF_LEFTDOWN)
sleep(20)
mouse_event(MOUSEEVENTF_LEFTUP)

See also[edit]

Lua
Script Engine

Related Functions[edit]

getMousePos
setMousePos
isKeyPressed
keyDown
keyUp
doKeyPress
mouse_event
setGlobalKeyPollInterval
setGlobalDelayBetweenHotkeyActivation