MacOS non-intrusive keyboard and mouse synchronization method, device, equipment and medium

Through the message transit center mechanism implemented by the dynamic library, keyboard and mouse events on MacOS are captured and synchronized, solving the problem of synchronous operation between multiple windows on MacOS, realizing non-invasive keyboard and mouse synchronization across application windows, and improving work efficiency.

CN119917305APending Publication Date: 2025-05-02ZIXUN TECHNOLOGY (FUJIAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411963003.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

On MacOS, users cannot implement synchronized key and mouse operations between multiple windows, and cannot meet the user's needs to perform the same input operations or click operations in multiple windows.

Method used

Key and mouse synchronization is realized through dynamic library, set up the main window and slave window dynamic library, capture the keyboard and mouse events of the main window, and send it to the slave window dynamic library through the message transfer center, realizing synchronization operations across application windows.

Benefits of technology

It realizes non-invasive keyboard and mouse synchronization, supports different windows of the same application and across different applications, improves work efficiency in a multi-task environment and reduces the hassle of manual switching and repeated operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917305A_ABST
    Figure CN119917305A_ABST
Patent Text Reader

Abstract

The invention provides a MacOS non-intrusive keyboard and mouse synchronization method, device and equipment and a medium. The method comprises the following steps: setting a master window dynamic library and a slave window dynamic library; injecting the master window dynamic library into a master control window, and injecting the slave window dynamic library into a slave control window; the master window dynamic library starts a message transfer center, and the slave window dynamic libraries are registered to the message transfer center; the main window dynamic library captures a keyboard event and a mouse event of the main control window and stores the keyboard event and the mouse event to a message transfer center, and the main control window executes corresponding operation according to the keyboard event and the mouse event; the message transfer center sends the keyboard event and the mouse event to each slave window dynamic library, and each slave window dynamic library controls a slave control window to execute corresponding operation according to the received keyboard event and mouse event; synchronization is achieved through the dynamic library, a code of a target program or an operating system core does not need to be changed, and stability of an application program and system safety are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to a non-intrusive keyboard and mouse synchronization method, device, equipment and medium for MacOS. Background Art

[0002] On macOS, users often need to seamlessly switch between multiple windows. Currently, macOS allows users to switch windows using shortcut keys and the mouse, but it doesn't offer synchronized keyboard and mouse operations across multiple windows. For example, when testing software, users may want to perform the same input operation in multiple windows or click the same action in multiple application interfaces. Traditional operation methods cannot meet this requirement. Summary of the Invention

[0003] The technical problem to be solved by the present invention is to provide a non-intrusive keyboard and mouse synchronization method, device, equipment and medium for MacOS, which realizes synchronization through dynamic libraries without changing the code of the target program or the operating system core, thereby ensuring the stability of the application and the security of the system.

[0004] In a first aspect, the present invention provides a non-intrusive keyboard and mouse synchronization method for MacOS, comprising the following steps:

[0005] Step 1. Set the main window dynamic library and the slave window dynamic library;

[0006] Step 2. Select the target program to be synchronized, start at least two target programs, set one target program as the master control window, and set the other target programs as slave control windows. Inject the master window dynamic library into the master control window, and inject the slave window dynamic library into the slave control window.

[0007] Step 3: The main window dynamic library starts a message transfer center, and the slave window dynamic libraries are all registered to the message transfer center;

[0008] Step 4: The main window dynamic library captures the keyboard events and mouse events of the main control window and stores them in the message transfer center. The main control window performs corresponding operations according to the keyboard events and mouse events.

[0009] Step 5: The message transfer center sends the keyboard events and mouse events to each slave window dynamic library, and each slave window dynamic library controls the slave window to perform corresponding operations according to the received keyboard events and mouse events.

[0010] In a second aspect, the present invention provides a non-intrusive keyboard and mouse synchronization device for MacOS, comprising:

[0011] Set the module, set the main window dynamic library and the slave window dynamic library;

[0012] The injection module selects the target program to be synchronized, starts at least two target programs, sets one of the target programs as the master control window, and sets the other target programs as slave control windows, injects the master window dynamic library into the master control window, and injects the slave window dynamic library into the slave control window;

[0013] The startup module starts a message transfer center through the main window dynamic library, and the slave window dynamic libraries are all registered with the message transfer center;

[0014] Acquisition event module, the main window dynamic library captures the keyboard events and mouse events of the main control window and stores them in the message transfer center, and the main control window performs corresponding operations according to the keyboard events and mouse events;

[0015] Synchronous event module, the message transfer center sends the keyboard events and mouse events to each slave window dynamic library, and each slave window dynamic library controls the slave window to perform corresponding operations according to the received keyboard events and mouse events.

[0016] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.

[0017] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in the first aspect when the program is executed by a processor.

[0018] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:

[0019] 1. Non-invasive: Synchronization is achieved through dynamic libraries, without changing the target program code or operating system kernel, ensuring application stability and system security.

[0020] 2. Cross-application synchronization: Not only does it support synchronization between different windows of the same application, it also enables synchronization across different applications, helping users switch freely between multi-window tasks, further improving work efficiency in a multi-tasking environment.

[0021] 3. Simplify the operation process: The keyboard input and mouse operations performed by the user in the main window are transmitted to all passive windows in real time, reducing the trouble of manual switching and repeated operations and optimizing the user experience.

[0022] 4. Reduce misoperations: The synchronizer ensures consistent operations across all synchronized windows through precise operation capture and real-time synchronization, avoiding errors that may result from repeated operations across multiple windows.

[0023] 5. Customizable synchronization: Users can freely select the windows to be synchronized and set the specific synchronization content (keyboard, mouse or both) to meet personalized operation needs.

[0024] Through this synchronization mechanism, MacOS users can easily achieve consistent operations across multiple windows, which is suitable for various scenarios such as efficient office, data synchronization, and cross-application operations.

[0025] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0027] Figure 1 This is a flowchart of the method in Example 1 of the present invention;

[0028] Figure 2 This is a schematic diagram of the structure of the device in Example 2 of the present invention. DETAILED DESCRIPTION

[0029] The technical solution in the embodiment of the present application specifically includes the following steps:

[0030] Step 1: Select the target program. The user selects the target program to be synchronized in the synchronizer. The synchronizer will start the target program and automatically inject the dynamic library into it to capture and synchronize input operations within the program.

[0031] Step 2: Inject a dynamic library into the target application when the program is started. When the target program starts, the synchronizer will inject a dynamic library into the program's running environment. This dynamic library is responsible for monitoring the relationship between the main window and the passive window, and capturing the keyboard and mouse operation events of the main window. The injected dynamic library is the core component of the entire synchronization mechanism; the size of the main window and the passive window are the same;

[0032] Step 3: Detect the main window and passive windows. The dynamic library will monitor the window status of the target program in real time, including the switching and focus changes of the main window and all passive windows. The main window is the window directly operated by the user, while the passive windows are other windows that need to be synchronized. The dynamic library identifies the current main window so that synchronization is triggered when input operations occur in the main window.

[0033] Step 4: Capture the keyboard and mouse operations of the main window. The dynamic library captures the user's keyboard input and mouse operations in the main window. The specific captured content includes keyboard keys, input content, mouse movement, clicks, and scrolling operations. These operation data will be recorded in real time and forwarded to all passive windows;

[0034] Step 5: Synchronize the operation to the passive window. The dynamic library transfers the captured keyboard and mouse operation data to the passive window to achieve synchronization. After receiving the operation data, the passive window automatically performs the same operation, so that the user's input in the main window can be seamlessly mapped to other windows. This process is real-time, ensuring the consistency of multiple windows.

[0035] Step 6: Synchronization status feedback: The synchronizer displays a synchronization status icon or animation on the user interface to help users confirm whether the current operation is synchronized successfully. If the synchronization operation is interrupted or abnormal, the system will automatically prompt the user to restart the target program or re-inject the dynamic library.

[0036] Example 1

[0037] like Figure 1 As shown, this embodiment provides a non-intrusive keyboard and mouse synchronization method for MacOS, including the following steps:

[0038] Step 1. Set the main window dynamic library and the slave window dynamic library;

[0039] Step 2. Select the target program to be synchronized, start at least two target programs, set one target program as the master control window, and set the other target programs as slave control windows. Inject the master window dynamic library into the master control window, and inject the slave window dynamic library into the slave control window.

[0040] Step 3: The main window dynamic library starts a message transfer center, and the slave window dynamic libraries are all registered to the message transfer center;

[0041] Step 4: The main window dynamic library captures the keyboard events and mouse events of the main control window and stores them in the message transfer center. The main control window performs corresponding operations according to the keyboard events and mouse events.

[0042] Step 5: The message transfer center sends the keyboard events and mouse events to each slave window dynamic library, and each slave window dynamic library controls the slave window to perform corresponding operations according to the received keyboard events and mouse events.

[0043] This embodiment preferably further includes step 6, setting a synchronization status chart or animation on the device interface to prompt the user whether the current synchronization operation is successful.

[0044] In this embodiment, preferably, step 1 is specifically as follows:

[0045] Create a main window dynamic library to monitor keyboard and mouse events of MacOS;

[0046] First, register the listener in the static function Load of NSWindow; then, register the system listener through CGEv entTapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionListenOnly, eventMask, eventCallback, NULL), and set the event Mask value to 0x2|0x4|0x8|0x10|0x20|0x40|0x80|0x400|0x800|0x400000|0x8000000; finally, set the callback function eventCallback, which is used to forward keyboard events and / or mouse events to the message transfer center. The mouse event contains the relative position coordinates of the cursor in the master window, which is used for the slave window to perform the same operation at the same position to ensure synchronization.

[0047] kCGSessionEventTap: Specifies the type of event listener. kCGSessionEventTap means listening for session-level events, that is, events related to user interaction with the application.

[0048] kCGTailAppendEventTap: Specifies the position of the event listener in the event stream. kCGTailAppendEventTap means adding the listener to the end of the event stream.

[0049] kCGEventTapOptionListenOnly: Specifies the event listener option. kCGEventTapOptionListenOnly means that the listener can only listen to events and cannot modify or block events.

[0050] eventMask: A bit mask that specifies the event types to monitor. For example, you can monitor multiple types of events by performing a bitwise OR operation on different CGEventType values;

[0051] eventCallback: A callback function that will be called when a specified event is detected. This callback function must conform to the signature of CGEventTapCallBack;

[0052] NULL: This is the context parameter of the callback function. When no additional information is needed to be passed to the callback function, it can be set to NULL.

[0053] Create a slave window dynamic library for receiving the keyboard events and mouse events;

[0054] First, register with the message transfer center; then, receive the mouse events and keyboard events forwarded by the message center; finally, execute the mouse events and keyboard events.

[0055] In this embodiment, preferably, step 2 specifically includes: selecting a target program to be synchronized, starting at least two target programs, setting one of the target programs as a master control window, and setting the other target programs as slave control windows, injecting the master window dynamic library into the master control window through DYLD_INSERT_LIBRARIES, and injecting the slave window dynamic library into the slave control window through DYLD_INSERT_LIBRARIES;

[0056] The specific step 3 is as follows: the main window dynamic library starts a message transfer center, the message transfer center listens to the set port through unixsocks and receives socket messages, the slave window dynamic library sends a registration message to the set port, the message transfer center receives the registration message, and the registration from the slave window dynamic library to the message transfer center is completed.

[0057] Based on the same inventive concept, this application also provides a device corresponding to the method in Example 1, see Example 2 for details.

[0058] Example 2

[0059] like Figure 2 As shown, in this embodiment, a non-intrusive keyboard and mouse synchronization device for MacOS is provided, including:

[0060] Set the module, set the main window dynamic library and the slave window dynamic library;

[0061] The injection module selects the target program to be synchronized, starts at least two target programs, sets one of the target programs as the master control window, and sets the other target programs as slave control windows, injects the master window dynamic library into the master control window, and injects the slave window dynamic library into the slave control window;

[0062] The startup module starts a message transfer center through the main window dynamic library, and the slave window dynamic libraries are all registered with the message transfer center;

[0063] Acquisition event module, the main window dynamic library captures the keyboard events and mouse events of the main control window and stores them in the message transfer center, and the main control window performs corresponding operations according to the keyboard events and mouse events;

[0064] Synchronous event module, the message transfer center sends the keyboard events and mouse events to each slave window dynamic library, and each slave window dynamic library controls the slave window to perform corresponding operations according to the received keyboard events and mouse events.

[0065] In this embodiment, preferably, a prompt module is further included to set a synchronization status chart or animation on the device interface to prompt the user whether the current synchronization operation is successful.

[0066] In this embodiment, preferably, the setting module is specifically:

[0067] Create a main window dynamic library to monitor keyboard and mouse events of MacOS;

[0068] First, register the listener in the static function Load of NSWindow; then, register the system listener through CGEv entTapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionListenOnly, eventMask, eventCallback, NULL), and set the event Mask value to 0x2|0x4|0x8|0x10|0x20|0x40|0x80|0x400|0x800|0x400000|0x8000000; finally, set the callback function eventCallback, which is used to forward keyboard events and / or mouse events to the message transfer center;

[0069] Create a slave window dynamic library for receiving the keyboard events and mouse events;

[0070] First, register with the message transfer center; then, receive the mouse events and keyboard events forwarded by the message center; finally, execute the mouse events and keyboard events.

[0071] In this embodiment, preferably, the injection module specifically includes: selecting a target program to be synchronized, starting at least two target programs, setting one of the target programs as a master control window, and setting the other target programs as slave control windows, injecting the master window dynamic library into the master control window through DYLD_INSERT_LIBRARIES, and injecting the slave window dynamic library into the slave control window through DYLD_INSERT_LIBRARIES;

[0072] The startup module is specifically as follows: the main window dynamic library starts a message transfer center, the message transfer center listens to the set port through unixsocks and receives socket messages, the slave window dynamic library sends a registration message to the set port, the message transfer center receives the registration message, and completes the registration from the slave window dynamic library to the message transfer center.

[0073] Since the device described in the second embodiment of the present invention is used to implement the method of the first embodiment of the present invention, those skilled in the art will be able to understand the specific structure and variations of the device based on the method described in the first embodiment of the present invention, and therefore will not be described in detail here. All devices used in the method of the first embodiment of the present invention fall within the scope of protection of the present invention.

[0074] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to the first embodiment, see the third embodiment for details.

[0075] Example 3

[0076] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any implementation method in the first embodiment can be implemented.

[0077] Since the electronic device described in this embodiment is the device used to implement the method in Example 1 of this application, based on the method described in Example 1 of this application, those skilled in the art will be able to understand the specific implementation of the electronic device of this embodiment and its various variations. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. As long as the device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection to be provided by this application.

[0078] Based on the same inventive concept, this application provides a storage medium corresponding to Example 1, see Example 4 for details.

[0079] Example 4

[0080] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any implementation method in the first embodiment can be implemented.

[0081] The technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:

[0082] This embodiment synchronizes keyboard and mouse input across different windows, allowing users to efficiently perform operations in multiple windows simultaneously. Users can input in one place, and multiple windows respond in real time, greatly improving operational efficiency. This is suitable for scenarios where the same operation needs to be performed in multiple interfaces.

[0083] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0084] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0085] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0086] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0087] Although the specific embodiments of the present invention are described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A non-intrusive keyboard and mouse synchronization method for MacOS, characterized by: The steps include: Step 1, set the main window dynamic library and the slave window dynamic library; Step 2, select the target program to be synchronized, start at least two target programs, set one of the target programs as the master control window, set the other target programs as slave control windows, inject the main window dynamic library into the master control window, and inject the slave window dynamic library into the slave control window; Step 3, the main window dynamic library starts a message transfer center, and the slave window dynamic libraries are all registered to the message transfer center; Step 4, the main window dynamic library captures the keyboard events and mouse events of the main control window, and stores them in the message transfer center, and the main control window performs corresponding operations according to the keyboard events and mouse events; Step 5: The message transfer center sends the keyboard events and mouse events to each slave window dynamic library, and each slave window dynamic library controls the slave window to perform corresponding operations according to the received keyboard events and mouse events.

2. A MacOS non-intrusive keyboard and mouse synchronization method according to claim 1, characterized in that: The method also includes step 6, setting a synchronization status chart or animation on the device interface to prompt the user whether the current synchronization operation is successful.

3. The non-intrusive keyboard and mouse synchronization method for MacOS according to claim 1, characterized in that: The step 1 is specifically as follows: Create a main window dynamic library to monitor keyboard and mouse events of MacOS; First, register the listener in the static function Load of NSWindow; then, register the system listener through CGEv entTapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionListenOnly, eventMask, eventCallback, NULL), and set the event Mask value to 0x2|0x4|0x8|0x10|0x20|0x40|0x80|0x400|0x800|0x400000|0x8000000; finally, set the callback function eventCallback, which is used to forward keyboard events and / or mouse events to the message transfer center; Create a slave window dynamic library for receiving the keyboard events and mouse events; First, register with the message transfer center; then, receive the mouse events and keyboard events forwarded by the message center; Finally, mouse events and keyboard events are executed.

4. The non-intrusive keyboard and mouse synchronization method for MacOS according to claim 1, characterized in that: The step 2 specifically includes: selecting a target program to be synchronized, starting at least two target programs, setting one of the target programs as a master control window, and setting the other target programs as slave control windows, injecting the main window dynamic library into the master control window through DYLD_INSERT_LIBRARIES, and injecting the slave window dynamic library into the slave control window through DYLD_INSERT_LIBRARIES; The step 3 is specifically as follows: the main window dynamic library starts a message transfer center, the message transfer center listens to the set port through unixsocks and receives socket messages, the slave window dynamic library sends a registration message to the set port, the message transfer center receives the registration message, and the registration from the slave window dynamic library to the message transfer center is completed.

5. A non-intrusive keyboard and mouse synchronization device for MacOS, characterized in that: include: Set the module, set the main window dynamic library and the slave window dynamic library; The injection module selects the target program to be synchronized, starts at least two target programs, sets one of the target programs as the master control window, sets the other target programs as slave control windows, injects the main window dynamic library into the master control window, and injects the slave window dynamic library into the slave control window; The start module, the main window dynamic library starts a message transfer center, and the slave window dynamic library is registered to the message transfer center; Acquisition event module, the main window dynamic library captures the keyboard events and mouse events of the main control window, and stores them in the message transfer center, and the main control window performs corresponding operations according to the keyboard events and mouse events; Synchronous event module, the message transfer center sends the keyboard events and mouse events to each slave window dynamic library, and each slave window dynamic library controls the slave control window to perform corresponding operations according to the received keyboard events and mouse events.

6. The non-intrusive keyboard and mouse synchronization device for MacOS according to claim 5, characterized in that: It also includes a prompt module, which sets a synchronization status chart or animation on the device interface to prompt the user whether the current synchronization operation is successful.

7. The non-intrusive keyboard and mouse synchronization device for MacOS according to claim 5, characterized in that: The setting module is specifically: Create a main window dynamic library to monitor keyboard and mouse events of MacOS; First, register the listener in the static function Load of NSWindow; then, register the system listener through CGEv entTapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionListenOnly, eventMask, eventCallback, NULL), and set the event Mask value to 0x2|0x4|0x8|0x10|0x20|0x40|0x80|0x400|0x800|0x400000|0x8000000; finally, set the callback function eventCallback, which is used to forward keyboard events and / or mouse events to the message transfer center; Create a slave window dynamic library for receiving the keyboard events and mouse events; First, register with the message transfer center; then, receive the mouse events and keyboard events forwarded by the message center; Finally, mouse events and keyboard events are executed.

8. The non-intrusive keyboard and mouse synchronization device for MacOS according to claim 5, characterized in that: The injection module specifically includes: selecting a target program to be synchronized, starting at least two target programs, setting one of the target programs as a master control window, setting the other target programs as slave control windows, injecting the main window dynamic library into the master control window through DYLD_INSERT_LIBRARIES, and injecting the slave window dynamic library into the slave control window through DYLD_INSERT_LIBRARIES; The startup module is specifically as follows: the main window dynamic library starts a message transfer center, the message transfer center listens to the set port through unixsocks and receives socket messages, the slave window dynamic library sends a registration message to the set port, the message transfer center receives the registration message, and the registration from the slave window dynamic library to the message transfer center is completed.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 4 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.