diff --git a/ace_cursor_movement.dll b/ace_cursor_movement.dll new file mode 100644 index 00000000000..74832041c49 Binary files /dev/null and b/ace_cursor_movement.dll differ diff --git a/ace_cursor_movement_x64.dll b/ace_cursor_movement_x64.dll new file mode 100644 index 00000000000..51985656c32 Binary files /dev/null and b/ace_cursor_movement_x64.dll differ diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 8a33997f57b..f5be99142b4 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -119,6 +119,7 @@ PREP(loadPerson); PREP(loadPersonLocal); PREP(moduleCheckPBOs); PREP(moduleLSDVehicles); +PREP(moveCursor); PREP(muteUnit); PREP(muteUnitHandleInitPost); PREP(muteUnitHandleRespawn); diff --git a/addons/common/functions/fnc_moveCursor.sqf b/addons/common/functions/fnc_moveCursor.sqf new file mode 100644 index 00000000000..20d6c6c6b64 --- /dev/null +++ b/addons/common/functions/fnc_moveCursor.sqf @@ -0,0 +1,30 @@ +/* + * Author: LorenLuke (function), BaerMitUmlaut (Extension) + * + * Simulates mouse input by number of pixels (not consistent/smooth) + * Note- using with open dialogs may cause issues when in loops. + * + * Arguments: + * 0: x direction (+right, -left) + * 1: y direction (+down, -up) + * + * Return Value: + * None + * + * Example: + * [100, 100] call ace_common_fnc_moveCursor + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_x", "_y"]; + +if (!dialog) then { + "ace_cursor_movement" callExtension format ["x%1", _x]; + "ace_cursor_movement" callExtension format ["y%1", _y]; + + TRACE_2("movecursor",_x,_y); +}; + +nil diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 0c6f397ad35..33c0dd95b4a 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -127,6 +127,7 @@ add_subdirectory(clipboard) add_subdirectory(advanced_ballistics) add_subdirectory(medical) add_subdirectory(parse_imagepath) +add_subdirectory(cursor_movement) # Test Extension for dynamically loading/unloading built extensions; does not build in release if (DEVEL) diff --git a/extensions/cursor_movement/CMakeLists.txt b/extensions/cursor_movement/CMakeLists.txt new file mode 100644 index 00000000000..2ffd402db3d --- /dev/null +++ b/extensions/cursor_movement/CMakeLists.txt @@ -0,0 +1,12 @@ +set(ACE_EXTENSION_NAME "ace_cursor_movement") + +file(GLOB SOURCES *.h *.hpp *.c *.cpp) +add_library( ${ACE_EXTENSION_NAME} SHARED ${SOURCES} ${GLOBAL_SOURCES}) +target_link_libraries(${ACE_EXTENSION_NAME} ace_common) +set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "") +set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) + +if(CMAKE_COMPILER_IS_GNUCXX) + set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1) + set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1) +endif() diff --git a/extensions/cursor_movement/cursorMovement.cpp b/extensions/cursor_movement/cursorMovement.cpp new file mode 100644 index 00000000000..9d58d409497 --- /dev/null +++ b/extensions/cursor_movement/cursorMovement.cpp @@ -0,0 +1,32 @@ +#include "stdafx.h" +#include "windows.h" +#include "string.h" +#include + +extern "C" { + __declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function); +} + +void __stdcall RVExtension(char *output, int outputSize, const char *function) { + INPUT ip; + ip.type = INPUT_MOUSE; + ip.mi.mouseData = 0; + ip.mi.dwFlags = MOUSEEVENTF_MOVE; + ip.mi.time = 0; + + int x, y; + if (strncmp(function, "x", 1)) { + ip.mi.dx = atoi(&function[1]); + ip.mi.dy = 0; + } else if (strncmp(function, "y", 1)) { + ip.mi.dy = atoi(&function[1]); + ip.mi.dx = 0; + } else { + strncpy_s(output, outputSize, "error", _TRUNCATE); + return; + } + + SendInput(1, &ip, sizeof(INPUT)); + + strncpy_s(output, outputSize, "ok", _TRUNCATE); +}