Shortcut key synchronization method and device for Chromium browser in MacOS

By setting up the central control service and dynamic link library in the MacOS system, shortcut keys and keyboard event synchronization between multiple instances of the Chromium browser is achieved, which solves the synchronization complexity and accuracy problems in the existing technology, and provides a synchronization solution suitable for multi-instance browser scenarios.

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

Patent Information

Application Number
CN202411962987.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

In MacOS systems, it is difficult for the existing technology to effectively synchronize the shortcut keys and window positioning of the Chromium browser, especially in multi-instance browser scenarios. The overall architecture is complex and accurate keyboard event synchronization cannot be achieved.

Method used

By setting up the central control service and dynamic link library, start multiple Chromium browser instances and make two-way connections through Socket.IO. Select one instance as the master and the other instance as slave. The master monitors and encapsulates keyboard events as JSON objects. Synchronizes to slaves through the central control service to realize synchronization of shortcut keys and keyboard events.

Benefits of technology

It realizes accurate synchronization of Chromium browser shortcut keys and keyboard events in MacOS, without invasive modifications to the browser, and is suitable for synchronization operation scenarios of multi-instance browsers, especially suitable for tests and developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917302A_ABST
    Figure CN119917302A_ABST
Patent Text Reader

Abstract

The invention provides a shortcut key synchronization method and device for a Chromium browser in MacOS, and the method comprises the steps: setting a central control service, enabling a browser instance to be connected through the central control service, and setting a used port number; starting a plurality of browser instances; the dynamic link library is injected into each browser instance, a user data directory operated by the browser instance is specified and used for isolating data, and each browser instance is registered to the central control service through the dynamic link library; one browser instance is selected as a master control, the other browser instances are selected as slave controls, and the central control service sends a synchronization instruction to all the browser instances; the master control monitors all keyboard events through the running dynamic link library, extracts set information and packages the set information into the JSON object, the master control sends the JSON object to each slave control, the slave control completes keyboard synchronization according to the JSON object, and it is guaranteed that shortcut key synchronization is accurate.
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 shortcut key 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 shortcut keys and window positioning. Summary of the invention

[0006] The technical problem to be solved by the present invention is to provide a shortcut key synchronization method and device for the Chromium browser in MacOS, so as to ensure accurate keyboard event synchronization and shortcut key synchronization.

[0007] In a first aspect, the present invention provides a method for synchronizing shortcut keys of 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: The master control monitors all keyboard events through the running dynamic link library, extracts setting information from the monitored keyboard events, and encapsulates it into a JSON object. The master control sends the JSON object to each slave control through the central control service, and the slave control completes keyboard synchronization according to the JSON object.

[0012] In a second aspect, the present invention provides a shortcut key synchronization device for a Chromium browser in MacOS, comprising:

[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] Start the injection module and start multiple Chromium browser instances; pre-set a dynamic link library, which is injected 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;

[0015] Start the synchronization module, 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.

[0016] Synchronous keyboard module, the master control monitors all keyboard events through the running dynamic link library, extracts the setting information from the monitored keyboard events, and encapsulates it as a JSON object. The master control sends the JSON object to each slave control through the central control service, and the slave control completes the keyboard synchronization according to the JSON object.

[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; it solves: keyboard synchronization, shortcut key 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 running the Chromium instance, 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: keyboard pops up;

[0042] NSEventTypeKeyDown: keyboard pressed;

[0043] The 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 shortcut key 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: The master control monitors all keyboard events through the running dynamic link library, extracts setting information from the monitored keyboard events, and encapsulates it into a JSON object. The master control sends the JSON object to each slave control through the central control service, and the slave control completes keyboard synchronization according to the JSON object.

[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 keyboard events, execute keyboard 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:

[0086] The main control runs a dynamic link library, which monitors all keyboard events through NSEvent.addLocalMonitorForEventsMatchingMask; extracts setting information from the monitored keyboard events and encapsulates it into a JSON object, which includes: Type, Keycode and ModifierFlags;

[0087] The master control sends the JSON object to the central control service through Socket.IO. After receiving the JSON object, the central control service distributes it to each slave control.

[0088] The main control obtains the window information of the currently activated window, wherein the window information of the currently activated window includes: the length and width of the currently activated window, the relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window, and the class name of the currently activated window; and broadcasts the window information of the currently activated window;

[0089] After the slave controller obtains the keyboard event monitored by the master controller, it obtains the target window in combination with the window information of the currently activated window;

[0090] Get all currently visible windows from the control;

[0091] If there is only one visible window, return and use the visible window as the target window;

[0092] If not, then search for a visible window with the same length and width as the currently active window and the same class name as the currently active window. If it exists, it will be used as the target window;

[0093] If it does not exist, search for a visible window with the same width and class name as the currently active window. If it exists, use it as the target window.

[0094] If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the target window;

[0095] If it does not exist, the base window of the slave control is used as the target window, and the base window of the slave control is the first window of the Chromium browser instance;

[0096] If the JSON object does not contain ModifierFlags, the slave controller obtains the NSWindow instance object of the target window; the slave controller creates a corresponding NSEvent keyboard event from the JSON object through AppKit's [NSEvent keyEventWithType], and the slave controller submits the created NSEvent keyboard event through [NSApp postEvent] to complete keyboard synchronization;

[0097] If the JSON object contains ModifierFlags, all current menu shortcuts are searched through the [NSApp mainMenu] interface, the corresponding matching shortcut MenuItem menu item is found, and the MenuItem operation is directly triggered through [NSApp sendAction] to complete the synchronization of shortcuts.

[0098] 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.

[0099] Embodiment 2

[0100] like Figure 2 As shown, in this embodiment, a shortcut key synchronization device for a Chromium browser in MacOS is provided, including:

[0101] 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;

[0102] Start the injection module and start multiple Chromium browser instances; pre-set a dynamic link library, which is injected 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;

[0103] Start the synchronization module, 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.

[0104] Synchronous keyboard module, the master control monitors all keyboard events through the running dynamic link library, extracts the setting information from the monitored keyboard events, and encapsulates it as a JSON object. The master control sends the JSON object to each slave control through the central control service, and the slave control completes the keyboard synchronization according to the JSON object.

[0105] 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.

[0106] In this embodiment, preferably, the startup injection 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 keyboard events, execute keyboard 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.

[0107] In this embodiment, preferably, the startup synchronization module is specifically as follows: 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.

[0108] In this embodiment, preferably, the synchronous keyboard module is specifically:

[0109] The main control runs a dynamic link library, which monitors all keyboard events through NSEvent.addLocalMonitorForEventsMatchingMask; extracts setting information from the monitored keyboard events and encapsulates it into a JSON object, which includes: Type, Keycode and ModifierFlags;

[0110] The master control sends the JSON object to the central control service through Socket.IO. After receiving the JSON object, the central control service distributes it to each slave control.

[0111] The main control obtains the window information of the currently activated window, wherein the window information of the currently activated window includes: the length and width of the currently activated window, the relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window, and the class name of the currently activated window; and broadcasts the window information of the currently activated window;

[0112] After the slave controller obtains the keyboard event monitored by the master controller, it obtains the target window in combination with the window information of the currently activated window;

[0113] Get all currently visible windows from the control; if there is only one visible window, return and use the visible window as the target window;

[0114] If not, then search for a visible window with the same length and width as the currently active window and the same class name as the currently active window. If it exists, it will be used as the target window;

[0115] If it does not exist, search for a visible window with the same width and class name as the currently active window. If it exists, use it as the target window.

[0116] If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the target window;

[0117] If it does not exist, the base window of the slave control is used as the target window, and the base window of the slave control is the first window of the Chromium browser instance;

[0118] If the JSON object does not contain ModifierFlags, the slave controller obtains the NSWindow instance object of the target window; the slave controller creates a corresponding NSEvent keyboard event from the JSON object through AppKit's [NSEvent keyEventWithType], and the slave controller submits the created NSEvent keyboard event through [NSApp postEvent] to complete keyboard synchronization;

[0119] If the JSON object contains ModifierFlags, all current menu shortcuts are searched through the [NSApp mainMenu] interface, the corresponding matching shortcut MenuItem menu item is found, and the MenuItem operation is directly triggered through [NSApp sendAction] to complete the synchronization of shortcuts.

[0120] 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.

[0121] 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 shortcut key 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: The master control monitors all keyboard events through the running dynamic link library, extracts setting information from the monitored keyboard events, and encapsulates it into a JSON object. The master control sends the JSON object to each slave control through the central control service, and the slave control completes keyboard synchronization according to the JSON object.

2. According to claim 1, a shortcut key synchronization method for a Chromium browser in MacOS is 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 method for synchronizing shortcut keys 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 keyboard events, execute keyboard 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 method for synchronizing shortcut keys 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 method for synchronizing shortcut keys of a Chromium browser in MacOS according to claim 1, characterized in that: The step 4 is specifically as follows: The main control runs the dynamic link library, and the running dynamic link library monitors all keyboard events through NSEvent.addLocalMonitorForEventsMatchingMask; Extract setting information from the monitored keyboard events and encapsulate it into a JSON object, wherein the JSON object includes: Type, Keycode and ModifierFlags; The master control sends the JSON object to the central control service through Socket.IO. After receiving the JSON object, the central control service distributes it to each slave control. The main control obtains the window information of the currently activated window, wherein the window information of the currently activated window includes: the length and width of the currently activated window, the relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window, and the class name of the currently activated window; and broadcasts the window information of the currently activated window; After the slave controller obtains the keyboard event monitored by the master controller, it obtains the target window in combination with the window information of the currently activated window; Get all currently visible windows from the control; If there is only one visible window, return and use the visible window as the target window; If not, then search for a visible window with the same length and width as the currently active window and the same class name as the currently active window. If it exists, it will be used as the target window; If it does not exist, search for a visible window with the same width and class name as the currently active window. If it exists, use it as the target window. If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the target window; If it does not exist, the base window of the slave control is used as the target window, and the base window of the slave control is the first window of the Chromium browser instance; If the JSON object does not contain ModifierFlags, the slave controller obtains the NSWindow instance object of the target window; the slave controller creates a corresponding NSEvent keyboard event from the JSON object through AppKit's [NSEvent keyEventWithType], and the slave controller submits the created NSEvent keyboard event through [NSApp postEvent] to complete keyboard synchronization; If the JSON object contains ModifierFlags, all current menu shortcuts are searched through the [NSApp mainMenu] interface, the corresponding matching shortcut MenuItem menu item is found, and the MenuItem operation is directly triggered through [NSApp sendAction] to complete the synchronization of shortcuts.

6. A shortcut key 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; Start the injection module and start multiple Chromium browser instances; pre-set a dynamic link library, which is injected 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; Start the synchronization module, 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. Synchronous keyboard module, the master control monitors all keyboard events through the running dynamic link library, extracts the setting information from the monitored keyboard events, and encapsulates it as a JSON object. The master control sends the JSON object to each slave control through the central control service, and the slave control completes the keyboard synchronization according to the JSON object.

7. The device for synchronizing shortcut keys of 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 shortcut key synchronization device for Chromium browser in MacOS according to claim 6, characterized in that: The startup injection 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 keyboard events, execute keyboard 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 device for synchronizing shortcut keys of a Chromium browser in MacOS according to claim 6, characterized in that: The starting 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 shortcut key synchronization device for Chromium browser in MacOS according to claim 6, characterized in that: The synchronous keyboard module is specifically: The main control runs the dynamic link library, and the running dynamic link library monitors all keyboard events through NSEvent.addLocalMonitorForEventsMatchingMask; Extract setting information from the monitored keyboard events and encapsulate it into a JSON object, wherein the JSON object includes: Type, Keycode and ModifierFlags; The master control sends the JSON object to the central control service through Socket.IO. After receiving the JSON object, the central control service distributes it to each slave control. The main control obtains the window information of the currently activated window, wherein the window information of the currently activated window includes: the length and width of the currently activated window, the relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window, and the class name of the currently activated window; and broadcasts the window information of the currently activated window; After the slave controller obtains the keyboard event monitored by the master controller, it obtains the target window in combination with the window information of the currently activated window; Get all currently visible windows from the control; if there is only one visible window, return and use the visible window as the target window; If not, then search for a visible window with the same length and width as the currently active window and the same class name as the currently active window. If it exists, it will be used as the target window; If it does not exist, search for a visible window with the same width and class name as the currently active window. If it exists, use it as the target window. If it does not exist, search for a visible window whose relative offset between the upper left corner coordinates of the currently activated window and the upper left corner coordinates of the base window is within the set range. If it exists, use it as the target window; If it does not exist, the base window of the slave control is used as the target window, and the base window of the slave control is the first window of the Chromium browser instance; If the JSON object does not contain ModifierFlags, the slave controller obtains the NSWindow instance object of the target window; the slave controller creates a corresponding NSEvent keyboard event from the JSON object through AppKit's [NSEvent keyEventWithType], and the slave controller submits the created NSEvent keyboard event through [NSApp postEvent] to complete keyboard synchronization; If the JSON object contains ModifierFlags, all current menu shortcuts are searched through the [NSApp mainMenu] interface, the corresponding matching shortcut MenuItem menu item is found, and the MenuItem operation is directly triggered through [NSApp sendAction] to complete the synchronization of shortcuts.