Mouse synchronization method and device for Chromium browser in MacOS
By setting up a central control service and dynamic link library in the MacOS system, the synchronization operation of multiple Chromium browser instances is solved, and the problems of high invasiveness of browser synchronization methods and poor window positioning synchronization in the existing technology are solved, and accurate mouse synchronization and multi-window life cycle synchronization are achieved.
Patent Information
- Application Number
- CN202411962991.1
- 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
In MacOS systems, the existing Chromium browser synchronization methods have problems such as high invasiveness, large threshold, poor user experience and inability to achieve window positioning synchronization.
By setting up the central control service and dynamic link library, synchronous operations of multiple Chromium browser instances are realized. The specific steps include starting multiple Chromium browser instances, injecting dynamic link library, registering to the central control service, selecting master and slave browser instances, and listening and synchronizing mouse events through the dynamic link library.
It realizes accurate mouse synchronization and multi-window life cycle synchronization of Chromium browser in MacOS, avoids invasive modifications to the browser, and is suitable for synchronization operation scenarios of multi-instance browsers on MacOS.
Smart Images

Figure CN119917303A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a mouse synchronization method and device for a Chromium browser in MacOS. Background Art
[0002] Due to the reasons of the MacOS system itself and the implementation of the Chromium browser, there are very large restrictions on the synchronous operation of applications on MacOS. There are also very large restrictions on activated windows and inactivated windows on the MacOS system.
[0003] There are two existing MacOS synchronizer methods:
[0004] Solution 1: Add synchronization capabilities by directly modifying the Chromium kernel. This method is highly invasive to the browser and has a high threshold. It requires the use of a modified browser. When using it, users are unaware of the internal logic and cannot predict whether the browser itself is secure.
[0005] Solution 2: Use a dynamic link library, with a local central control service and Chromium plug-in support. The installation is cumbersome, with many communication links and a complex overall architecture. At the same time, it is impossible to synchronize window positioning. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide a mouse synchronization method and device for the Chromium browser in MacOS, so as to achieve precise control of mouse synchronization and multi-window life cycle synchronization.
[0007] In a first aspect, the present invention provides a mouse synchronization method for a Chromium browser in MacOS, comprising the following steps:
[0008] Step 1: Set up the central control service, connect the target browser instance that needs to be synchronized through the central control service, and set the port number used;
[0009] Step 2, start multiple Chromium browser instances; pre-set a dynamic link library, inject the dynamic link library into each Chromium browser instance, specify the user data directory running the Chromium browser instance, for isolating data, and each Chromium browser instance is registered to the central control service through the dynamic link library;
[0010] Step 3: Select a Chromium browser instance as the master, and the rest of the Chromium browser instances as slaves. The central control service sends synchronization instructions to all Chromium browser instances.
[0011] Step 4: Each slave control runs the dynamic link library and monitors all mouse events in the window area of the master control; the slave control performs the same operation according to the monitored mouse events to complete the synchronization.
[0012] In a second aspect, the present invention provides a mouse synchronization device for a Chromium browser in MacOS, characterized in that it includes:
[0013] Set up the service module, set up the central control service, connect the target browser instance that needs to be synchronized through the central control service, and set the port number used;
[0014] The browser registration module starts multiple Chromium browser instances; pre-sets a dynamic link library, which is injected into each Chromium browser instance, specifies the user data directory where the Chromium browser instance runs, and is used to isolate data. Each Chromium browser instance is registered with the central control service through the dynamic link library;
[0015] Specify the synchronization module, select one Chromium browser instance as the master, and the rest of the Chromium browser instances as slaves. The central control service sends synchronization instructions to all Chromium browser instances.
[0016] In the synchronization module, each slave control runs a dynamic link library and monitors all mouse events in the window area of the master control; the slave control performs the same operation based on the monitored mouse events to complete the synchronization.
[0017] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:
[0018] The present invention is based on dynamic link dylib and Socket.IO central control service; solves: mouse synchronization and multi-window life cycle synchronization;
[0019] The present invention is non-invasive and does not modify the Chromium browser itself in any way;
[0020] Benfenma is suitable for the synchronous operation scenarios of multiple instance browsers on MacOS, especially for testers and developers who need to synchronize operations on multiple instance browsers on MacOS.
[0021] 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 according to 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 listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.
[0023] Figure 1 is a flow chart of the method in Embodiment 1 of the present invention;
[0024] Figure 2 It is a schematic diagram of the structure of the device in the second embodiment of the present invention. DETAILED DESCRIPTION
[0025] The technical solution in the embodiment of the present application has the following general idea:
[0026] Start the central control service, which is implemented in Python. The central control service includes the Socket.IO+Tornado framework, provides http request calls for the outside, and uses Socket.IO internally to duplex connect the target browser instances that need to be synchronized. The port used is the local port 7887.
[0027] The command line starts multiple Chromium browser instances through the DYLD_INSERT_LIBRARIES environment parameter and the --user-data-dir parameter; the DYLD_INSERT_LIBRARIES environment parameter points to the written and compiled dynamic link library (dynamic link library uses Objective-C and Swift language), and is also passed to the port number running the Chromium Application Center Control Service, which is 7887; --user-data-dir specifies the user data directory where the Chromium instance runs, which is used to isolate data and implement the context of multiple browser instances;
[0028] The command line is:
[0029] DYLD_INSERT_LIBRARIES= / Users / ln / Library / Developer / Xcode / DerivedData / SyncSlaverDylib-awgqrwncbrsxcccttxbinxpthndx / Build / Products / Relea se / libskit.dylib~ / Documents / chrome-mac-125 / Chromium.app / Contents / MacOS / Chromium--user-data-dir="~ / Documents / Users / user_1"--port=7887;
[0030] After the Chromium browser instance is started, it will automatically run the logic in the written dynamic link library, and the code in it will automatically link to the 7887 port of the central control service. The system process pid injection performed by Chromium indicates that the current Chromium is a new synchronization instance, ready for subsequent operations;
[0031] The 7887 port of the central control service receives the start command, which is used to start the synchronization service. After receiving the start command, the central control service lists all currently registered Chromium instances, selects one Chromium instance as the master, and the remaining Chromium instances as slaves. Through the two-way connection of Socket.IO, it sends the start command to the logic in the dynamic link library of the corresponding Chromium instance, and informs the current master is the process (pid) and the slaves are the processes (pid list). After receiving the information, the docking will highlight the Chromium in the master window to facilitate users to quickly find the master.
[0032] After receiving the stop command, the central control service will send a stop command to all connected Chromium instances through Socket.IO to notify them to stop the synchronization behavior;
[0033] Mouse Sync:
[0034] Use the mouse to operate on the master browser page to set the slave control<CoreGraphics / CoreGraphics.h> CGEventTapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionListenOnly, eventMaskValue, eventCallback, NUL) in monitors all mouse events in the main control window area, including:
[0035] Left mouse button pressed, left mouse button released, mouse moved, and mouse dragged;
[0036] The slave controller performs the same operation based on the detected mouse events:
[0037] Identify the specific window information that the mouse is currently acting on: calculate the relative coordinates of the mouse relative to the upper left corner of the window it is acting on; based on the known information of the window that the mouse is currently acting on, deduce the specific window that the current slave control itself corresponds to;
[0038] Based on the derived window NSWindow instance of the slave control, create the corresponding mouse event NSEvent, set the same offset coordinates as the master control mouse position, submit it to the NSResponder of the slave control's own NSWindow instance, trigger the same event, and achieve synchronization of mouse events;
[0039] Keyboard events are pushed by the master control. When the master control monitors keyboard events, the master control executes:
[0040] The master monitors all keyboard events through AppKitAPI: NSEvent.addLocalMonitorForEventsMatchingMask, including:
[0041] NSEventTypeKeyUp: the keyboard pops up;
[0042] NSEventTypeKeyDown: keyboard pressed;
[0043] This API can monitor both simple keyboard presses and shortcut keys;
[0044] The monitored keyboard events are encapsulated into a JSON object describing the event by extracting information, including:
[0045] {
[0046] Type: "" / / Event type, such as keyboard press or pop-up
[0047] Keycode:"" / / The code of the specific key pressed on the keyboard, that is, which specific key is pressed
[0048] ModifierFlags:"" / / Whether the keyboard event trigger contains other function keys, such as ctrl / shift / command, which is often used to detect whether it is a functional shortcut key. For example, command+v is used to paste in MacOS. At this moment, when keycode is v, ModifierFlags will include the corresponding value of Command
[0049] };
[0050] The master controller transmits the JSON object event description data to the central control service through Socket.IO. After receiving the keyboard event, the central control service transfers the content according to the known slave control list and distributes it to all slave controls.
[0051] When the slave receives the master keyboard event sent by the service center in its own Socket.IO client, it will parse and extract the above event information, and create the corresponding NSEvent keyboard event through AppKit's [NSEvent keyEventWithType];
[0052] Find the latest active window NSWindow instance object from the control;
[0053] For this keyboard event, if there is no ModifierFlags, the slave controller will submit the created NSWindow through the [NSApp postEvent] API;
[0054] For keyboard NSEvents containing ModifierFlags, search for all current menu shortcuts through the [NSApp mainMenu] interface, find the corresponding matching shortcut MenuItem menu item, and directly trigger the MenuItem operation through [NSApp sendAction] to achieve shortcut synchronization;
[0055] A multi-strategy window recognition solution based on position, size and class information is proposed, which is mainly used in:
[0056] When the mouse event is synchronized, identify which window the master control acts on and which slave control corresponds to, as follows:
[0057] The main control program listens to the mouse events of its own program. Whenever the mouse moves to a new NSWindow window, it broadcasts the screen coordinates of the new window, the length and width of the window, the relative offset position of the window relative to the base window of the application (that is, the first window after the browser is started), and the current window class name through Socket.IO.
[0058] After the slave monitor listens to the mouse events of the master through the above EventTap API, it makes the following judgments based on the broadcasted master mouse activity window information:
[0059] 1. Get all visible windows in the current application process;
[0060] 2. If there is only one visible window, return and use the visible window as the target window;
[0061] 3. Find a window with the same size as the main active window and the same window class name. If not, proceed to the next step;
[0062] 4. Find a window with the same width as the main active window and the same window class name. If not, proceed to the next step;
[0063] 5. Find a window with similar coordinates of the upper left corner of the main active window and the upper left corner of the basic window. If there is none, proceed to the next step.
[0064] 6. If there is still no result, use the base window as the target window;
[0065] Simulate the corresponding mouse events on the target window.
[0066] The master controller has closed some windows due to some keyboard and mouse operations. The slave controller can automatically recognize it and close the corresponding windows of the slave controller:
[0067] When a window of the master controller is closed, the window closing event is monitored. After the window closing event is monitored, the size, coordinates, offset position, and window class name of the closed window are sent.
[0068] The master control sends the information to the central control service through Socket.IO, which then forwards it to the slave control. After the slave control monitors the master control window closing event through Socket.IO, it combines the size, coordinates, offset position, and window class name of the received closed window to make the following judgments:
[0069] 1. Get all visible windows in the current application process;
[0070] 2. If there is only one visible window, return and use the visible window as the target window;
[0071] 3. Find a window with the same size as the main active window and the same window class name. If not, proceed to the next step;
[0072] 4. Find a window with the same width as the main active window and the same window class name. If not, proceed to the next step;
[0073] 5. Find a window with similar coordinates of the upper left corner of the main active window and the upper left corner of the base window, and the same window class name. If there is none, proceed to the next step;
[0074] 6. If there is still no result, use the base window as the target window;
[0075] The Execution Target window closes.
[0076] Embodiment 1
[0077] like Figure 1 As shown, this embodiment provides a mouse synchronization method for a Chromium browser in MacOS, comprising the following steps:
[0078] Step 1: Set up the central control service, connect the target browser instance that needs to be synchronized through the central control service, and set the port number used;
[0079] Step 2, start multiple Chromium browser instances; pre-set a dynamic link library, inject the dynamic link library into each Chromium browser instance, specify the user data directory running the Chromium browser instance, for isolating data, and each Chromium browser instance is registered to the central control service through the dynamic link library;
[0080] Step 3: Select a Chromium browser instance as the master, and the rest of the Chromium browser instances as slaves. The central control service sends synchronization instructions to all Chromium browser instances.
[0081] Step 4: Each slave control runs the dynamic link library and monitors all mouse events in the window area of the master control; the slave control performs the same operation according to the monitored mouse events to complete the synchronization.
[0082] In this embodiment, preferably, the step 1 is specifically: setting up a central control service, the central control service includes Socket.IO and Tornado framework, which is used to provide http request calls for the outside, use Socket.IO internally, connect the target browser instance that needs to perform synchronization operations through Socket.IO, and set the port number used, which is the local port 7887.
[0083] In this embodiment, preferably, the step 2 is specifically: setting the DYLD_INSERT_LIBRARIES environment parameter and the --user-data-dir parameter to start multiple Chromium browser instances; wherein the DYLD_INSERT_LIBRARIES environment parameter points to a pre-set dynamic link library, the dynamic link library is injected into each Chromium browser instance, the dynamic link library is used to monitor mouse events, execute mouse events, and pass the port number to each Chromium browser instance; --user-data-dir specifies the user data directory in which the Chromium browser instance runs, which is used to isolate data and realize context isolation of each Chromium browser instance, and each Chromium browser instance is registered to the central control service through the dynamic link library.
[0084] In this embodiment, preferably, step 3 is specifically as follows: the central control service selects one Chromium browser instance from all registered Chromium browser instances as the master control, and the remaining Chromium browser instances are slave controls. The central control service sends synchronization instructions to all Chromium browser instances through a two-way connection of Socket.IO, and highlights the master Chromium browser instance for users to find the master Chromium browser instance.
[0085] In this embodiment, preferably, step 4 is specifically as follows: each slave control runs a dynamic link library to monitor all mouse events in the window area of the master control;
[0086] The dynamic link library is implemented by<CoreGraphics / CoreGraphics.h> CGEventTapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionListenOnly, eventMaskValue, eventCallback, NULL) in monitors all mouse events in the window area of the master control;
[0087] Mainly control the first window to which the current mouse event acts, obtain the window information of the first window: calculate the relative coordinates of the mouse relative to the upper left corner of the first window;
[0088] Whenever the mouse moves to a new window, the window information of the new window is obtained, wherein the window information of the new window includes: the length and width of the new window, the relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window, and the class name of the new window;
[0089] When a window closing event is monitored, the window information of the closed window is obtained, wherein the window information of the closed window includes: the length and width of the closed window, the relative offset between the upper left corner coordinates of the closed window and the upper left corner coordinates of the base window, and the class name of the closed window;
[0090] Broadcasting the window information of the new window and / or the window information of the closed window;
[0091] After the slave controller obtains and monitors the mouse event and window closing event of the master controller, the first target window is obtained through the window information of the new window; the second target window is obtained through the window information of the closed window; the obtaining of the first target window is specifically:
[0092] Get all currently visible windows from the control;
[0093] If there is only one visible window, return and use the visible window as the first target window;
[0094] If not, then search for a visible window with the same length and width as the new window and the same class name as the new window. If it exists, it will be used as the first target window;
[0095] If it does not exist, search for a visible window with the same width and class name as the new window. If it exists, use it as the first target window.
[0096] If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the first target window;
[0097] If it does not exist, the base window of the slave control is used as the first target window;
[0098] The obtaining of the second target window is specifically as follows:
[0099] Get all currently visible windows from the control;
[0100] If there is only one visible window, return and use the visible window as the second target window;
[0101] If not, then search for a visible window with the same length and width as the closed window and the same class name as the closed window. If it exists, use it as the second target window;
[0102] If it does not exist, search for a visible window with the same width and class name as the closed window. If it exists, use it as the second target window.
[0103] If it does not exist, then search and close a visible window whose relative offset between the upper left corner coordinates of the window and the upper left corner coordinates of the base window is within the set range. If it exists, then use it as the second target window;
[0104] If it does not exist, the base window of the slave control is used as the second target window.
[0105] The slave controller creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the target window, and closes the target window;
[0106] The slave creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the first target window, triggers similar events, and realizes synchronization of mouse events; according to the window closing event, the second target window is closed.
[0107] There is a situation that when the mouse moves outside the pop-up window of the browser, clicking the right button of the mouse will cause the pop-up window to close. The above method can achieve synchronous closing of the pop-up window.
[0108] Based on the same inventive concept, the present application also provides a device corresponding to the method in Example 1, see Example 2 for details.
[0109] Embodiment 2
[0110] like Figure 2 As shown, in this embodiment, a mouse synchronization device for a Chromium browser in MacOS is provided, including:
[0111] Set up the service module, set up the central control service, connect the target browser instance that needs to be synchronized through the central control service, and set the port number used;
[0112] The browser registration module starts multiple Chromium browser instances; pre-sets a dynamic link library, which is injected into each Chromium browser instance, specifies the user data directory where the Chromium browser instance runs, and is used to isolate data. Each Chromium browser instance is registered with the central control service through the dynamic link library;
[0113] Specify the synchronization module, select one Chromium browser instance as the master, and the rest of the Chromium browser instances as slaves. The central control service sends synchronization instructions to all Chromium browser instances.
[0114] In the synchronization module, each slave control runs a dynamic link library and monitors all mouse events in the window area of the master control; the slave control performs the same operation based on the monitored mouse events to complete the synchronization.
[0115] In this embodiment, preferably, the setting service module is specifically: setting a central control service, the central control service includes Socket.IO and Tornado framework, which is used to provide http request calls for the outside, use Socket.IO internally, connect the target browser instance that needs to perform synchronization operations through Socket.IO, and set the port number used, which is the local port 7887.
[0116] In this embodiment, preferably, the browser registration module is specifically as follows: setting the DYLD_INSERT_LIBRARIES environment parameter and the --user-data-dir parameter to start multiple Chromium browser instances; wherein the DYLD_INSERT_LIBRARIES environment parameter points to a pre-set dynamic link library, the dynamic link library is injected into each Chromium browser instance, the dynamic link library is used to monitor mouse events, execute mouse events, and pass the port number to each Chromium browser instance; --user-data-dir specifies the user data directory in which the Chromium browser instance runs, which is used to isolate data and realize context isolation of each Chromium browser instance, and each Chromium browser instance is registered to the central control service through the dynamic link library.
[0117] In this embodiment, preferably, the designated synchronization module is specifically: the central control service selects a Chromium browser instance from all registered Chromium browser instances as the master control, and the remaining Chromium browser instances are slave controls. The central control service sends synchronization instructions to all Chromium browser instances through a two-way connection of Socket.IO, and highlights the master Chromium browser instance for users to find the master Chromium browser instance.
[0118] In this embodiment, preferably, the synchronization module is specifically: each slave control runs a dynamic link library to monitor all mouse events in the window area of the master control;
[0119] The dynamic link library is implemented by<CoreGraphics / CoreGraphics.h> CGEventTapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionListenOnly, eventMaskValue, eventCallback, NULL) in monitors all mouse events in the window area of the master control;
[0120] Mainly control the first window to which the current mouse event acts, obtain the window information of the first window: calculate the relative coordinates of the mouse relative to the upper left corner of the first window;
[0121] Whenever the mouse moves to a new window, the window information of the new window is obtained, wherein the window information of the new window includes: the length and width of the new window, the relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window, and the class name of the new window;
[0122] When a window closing event is monitored, the window information of the closed window is obtained, wherein the window information of the closed window includes: the length and width of the closed window, the relative offset between the upper left corner coordinates of the closed window and the upper left corner coordinates of the base window, and the class name of the closed window;
[0123] Broadcasting the window information of the new window and / or the window information of the closed window;
[0124] After the slave controller obtains and monitors the mouse event and window closing event of the master controller, the first target window is obtained through the window information of the new window; the second target window is obtained through the window information of the closed window; the obtaining of the first target window is specifically:
[0125] Get all currently visible windows from the control;
[0126] If there is only one visible window, return and use the visible window as the first target window;
[0127] If not, then search for a visible window with the same length and width as the new window and the same class name as the new window. If it exists, it will be used as the first target window;
[0128] If it does not exist, search for a visible window with the same width and class name as the new window. If it exists, use it as the first target window.
[0129] If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the first target window;
[0130] If it does not exist, the base window of the slave control is used as the first target window;
[0131] The obtaining of the second target window is specifically as follows:
[0132] Get all currently visible windows from the control;
[0133] If there is only one visible window, return and use the visible window as the second target window;
[0134] If not, then search for a visible window with the same length and width as the closed window and the same class name as the closed window. If it exists, use it as the second target window;
[0135] If it does not exist, search for a visible window with the same width and class name as the closed window. If it exists, use it as the second target window.
[0136] If it does not exist, then search and close a visible window whose relative offset between the upper left corner coordinates of the window and the upper left corner coordinates of the base window is within the set range. If it exists, then use it as the second target window;
[0137] If it does not exist, the base window of the slave control is used as the second target window.
[0138] The slave controller creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the target window, and closes the target window;
[0139] The slave creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the first target window, triggers similar events, and realizes synchronization of mouse events; according to the window closing event, the second target window is closed.
[0140] Since the device introduced in the second embodiment of the present invention is a device used to implement the method of the first embodiment of the present invention, those skilled in the art can understand the specific structure and deformation of the device based on the method introduced in the first embodiment of the present invention, so it is not described here in detail. All devices used in the method of the first embodiment of the present invention belong to the scope of protection of the present invention.
[0141] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only 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 in the scope of protection of the claims of the present invention.
Claims
1. A mouse synchronization method for a Chromium browser in MacOS, characterized in that: The steps include: Step 1: Set up the central control service, connect the target browser instance that needs to be synchronized through the central control service, and set the port number used; Step 2, start multiple Chromium browser instances; pre-set a dynamic link library, inject the dynamic link library into each Chromium browser instance, specify the user data directory running the Chromium browser instance, for isolating data, and each Chromium browser instance is registered to the central control service through the dynamic link library; Step 3: Select a Chromium browser instance as the master, and the rest of the Chromium browser instances as slaves. The central control service sends synchronization instructions to all Chromium browser instances. Step 4: Each slave control runs the dynamic link library and monitors all mouse events in the window area of the master control; the slave control performs the same operation according to the monitored mouse events to complete the synchronization.
2. The method for synchronizing a mouse of a Chromium browser in MacOS according to claim 1, characterized in that: The step 1 is specifically as follows: setting up a central control service, which includes Socket.IO and Tornado frameworks, for providing http request calls externally and using Socket.IO internally, connecting the target browser instance that needs to be synchronized via Socket.IO, and setting the port number used, which is the local port 7887.
3. The mouse synchronization method of a Chromium browser in MacOS according to claim 1, characterized in that: The step 2 is specifically as follows: setting the DYLD_INSERT_LIBRARIES environment parameter and the --user-data-dir parameter to start multiple Chromium browser instances; wherein the DYLD_INSERT_LIBRARIES environment parameter points to a pre-set dynamic link library, the dynamic link library is injected into each Chromium browser instance, the dynamic link library is used to monitor mouse events, execute mouse events, and pass the port number to each Chromium browser instance; --user-data-dir specifies the user data directory where the Chromium browser instance runs, which is used to isolate data and implement context isolation of each Chromium browser instance, and each Chromium browser instance is registered to the central control service through the dynamic link library.
4. The mouse synchronization method of a Chromium browser in MacOS according to claim 1, characterized in that: The step 3 is specifically as follows: the central control service selects one Chromium browser instance from all registered Chromium browser instances as the master, and the remaining Chromium browser instances are slaves. The central control service sends synchronization instructions to all Chromium browser instances through a two-way connection of Socket.IO, and highlights the master Chromium browser instance for users to find the master Chromium browser instance.
5. The mouse synchronization method of a Chromium browser in MacOS according to claim 1, characterized in that: The step 4 is specifically as follows: each slave control runs a dynamic link library to monitor all mouse events in the window area of the master control; The dynamic link library is implemented by<CoreGraphics / CoreGraphics.h> CGEvent TapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptio nListenOnly, eventMaskValue, eventCallback, NULL) in monitors all mouse events in the window area of the master control; Mainly control the first window to which the current mouse event acts, obtain the window information of the first window: calculate the relative coordinates of the mouse relative to the upper left corner of the first window; Whenever the mouse moves to a new window, the window information of the new window is obtained, wherein the window information of the new window includes: the length and width of the new window, the relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window, and the class name of the new window; When a window closing event is monitored, the window information of the closed window is obtained, wherein the window information of the closed window includes: the length and width of the closed window, the relative offset between the upper left corner coordinates of the closed window and the upper left corner coordinates of the base window, and the class name of the closed window; Broadcasting the window information of the new window and / or the window information of the closed window; After the slave controller obtains and monitors the mouse event and window closing event of the master controller, the first target window is obtained through the window information of the new window; the second target window is obtained through the window information of the closed window; the obtaining of the first target window is specifically: Get all currently visible windows from the control; If there is only one visible window, return and use the visible window as the first target window; If not, then search for a visible window with the same length and width as the new window and the same class name as the new window. If it exists, it will be used as the first target window; If it does not exist, search for a visible window with the same width and class name as the new window. If it exists, use it as the first target window. If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the first target window; If it does not exist, the base window of the slave control is used as the first target window; The obtaining of the second target window is specifically as follows: Get all currently visible windows from the control; If there is only one visible window, return and use the visible window as the second target window; If not, then search for a visible window with the same length and width as the closed window and the same class name as the closed window. If it exists, use it as the second target window; If it does not exist, search for a visible window with the same width and class name as the closed window. If it exists, use it as the second target window. If it does not exist, then search and close a visible window whose relative offset between the upper left corner coordinates of the window and the upper left corner coordinates of the base window is within the set range. If it exists, then use it as the second target window; If it does not exist, the base window of the slave control is used as the second target window. The slave controller creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the target window, and closes the target window; The slave creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the first target window, triggers similar events, and realizes synchronization of mouse events; according to the window closing event, the second target window is closed.
6. A mouse synchronization device for a Chromium browser in MacOS, characterized in that: include: Set up the service module, set up the central control service, connect the target browser instance that needs to be synchronized through the central control service, and set the port number used; The browser registration module starts multiple Chromium browser instances; pre-sets a dynamic link library, which is injected into each Chromium browser instance, specifies the user data directory where the Chromium browser instance runs, and is used to isolate data. Each Chromium browser instance is registered with the central control service through the dynamic link library; Specify the synchronization module, select one Chromium browser instance as the master, and the rest of the Chromium browser instances as slaves. The central control service sends synchronization instructions to all Chromium browser instances. In the synchronization module, each slave control runs a dynamic link library and monitors all mouse events in the window area of the master control; the slave control performs the same operation based on the monitored mouse events to complete the synchronization.
7. The mouse synchronization device for a Chromium browser in MacOS according to claim 6, characterized in that: The service setting module is specifically: setting the central control service, which includes Socket.IO and Tornado framework, which is used to provide http request calls for the outside, use Socket.IO internally, connect the target browser instance that needs to be synchronized through Socket.IO, and set the port number used, which is the local port 7887.
8. The mouse synchronization device for a Chromium browser in MacOS according to claim 6, characterized in that: The browser registration module specifically includes: setting the DYLD_INSERT_LIBRARIES environment parameter and the --user-data-dir parameter to start multiple Chromium browser instances; wherein the DYLD_INSERT_LIBRARIES environment parameter points to a pre-set dynamic link library, the dynamic link library is injected into each Chromium browser instance, the dynamic link library is used to monitor mouse events, execute mouse events, and pass the port number to each Chromium browser instance; --user-data-dir specifies the user data directory where the Chromium browser instance runs, which is used to isolate data and realize context isolation of each Chromium browser instance, and each Chromium browser instance is registered to the central control service through the dynamic link library.
9. The mouse synchronization device for a Chromium browser in MacOS according to claim 6, characterized in that: The designated synchronization module is specifically as follows: the central control service selects one Chromium browser instance from all registered Chromium browser instances as the master, and the remaining Chromium browser instances are slaves. The central control service sends synchronization instructions to all Chromium browser instances through a two-way connection of Socket.IO, and highlights the master Chromium browser instance for users to find the master Chromium browser instance.
10. The mouse synchronization device for a Chromium browser in MacOS according to claim 6, characterized in that: The synchronization module is specifically: each slave control runs a dynamic link library to monitor all mouse events in the window area of the master control; The dynamic link library is implemented by<CoreGraphics / CoreGraphics.h> CGEvent TapCreate(kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptio nListenOnly, eventMaskValue, eventCallback, NULL) in monitors all mouse events in the window area of the master control; Mainly control the first window to which the current mouse event acts, obtain the window information of the first window: calculate the relative coordinates of the mouse relative to the upper left corner of the first window; Whenever the mouse moves to a new window, the window information of the new window is obtained, wherein the window information of the new window includes: the length and width of the new window, the relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window, and the class name of the new window; When a window closing event is monitored, the window information of the closed window is obtained, wherein the window information of the closed window includes: the length and width of the closed window, the relative offset between the upper left corner coordinates of the closed window and the upper left corner coordinates of the base window, and the class name of the closed window; Broadcasting the window information of the new window and / or the window information of the closed window; After the slave controller obtains and monitors the mouse event and window closing event of the master controller, the first target window is obtained through the window information of the new window; the second target window is obtained through the window information of the closed window; the obtaining of the first target window is specifically: Get all currently visible windows from the control; If there is only one visible window, return and use the visible window as the first target window; If not, then search for a visible window with the same length and width as the new window and the same class name as the new window. If it exists, it will be used as the first target window; If it does not exist, search for a visible window with the same width and class name as the new window. If it exists, use it as the first target window. If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the new window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the first target window; If it does not exist, the base window of the slave control is used as the first target window; The obtaining of the second target window is specifically as follows: Get all currently visible windows from the control; If there is only one visible window, return and use the visible window as the second target window; If not, then search for a visible window with the same length and width as the closed window and the same class name as the closed window. If it exists, use it as the second target window; If it does not exist, search for a visible window with the same width and class name as the closed window. If it exists, use it as the second target window. If it does not exist, then search and close a visible window whose relative offset between the upper left corner coordinates of the window and the upper left corner coordinates of the base window is within the set range. If it exists, then use it as the second target window; If it does not exist, the base window of the slave control is used as the second target window. The slave controller creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the target window, and closes the target window; The slave creates a corresponding NSEvent object according to the mouse event, submits the relative coordinates and the NS Event object to the NSResponder of the first target window, triggers similar events, and realizes synchronization of mouse events; according to the window closing event, the second target window is closed.