Window recognition method, device, equipment and computer readable storage medium
By traversing and judging the subviews of the target display page and identifying the window type based on the attribute information of the subview, the problem of high markup management costs is solved, and more efficient window identification and application performance improvement are achieved.
Patent Information
- Application Number
- CN202210897875.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-28
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-07-28
AI Technical Summary
When identifying multiple specific windows, the existing technology has high tag bit management costs and is prone to confusion, resulting in inaccurate window identification and low application performance.
By obtaining the root view of the target display page, traversing each subview in turn, it is determined whether the target point is in the display area of the current subview, and determining whether it belongs to the target window type based on the attribute information of the subview, avoiding the use of mark bits to mark the appearance and disappearance of windows.
This improves the accuracy of window recognition, reduces the management cost of marker bits, and improves application performance.
Smart Images

Figure CN115357155B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a window recognition method, device, equipment and computer-readable storage medium. Background Art
[0002] With the rapid development of computer and terminal technologies, the variety of applications that can be installed and used on terminals has gradually increased. When running on a terminal, applications sometimes need to identify specific windows. By identifying specific windows, they can determine whether a specific window is covering the page, and then make different logical judgments. For example, if a specific window is a pop-up window, the pop-up window can be identified. If a pop-up window is currently popping up, other pop-ups must be controlled not to be displayed. If no pop-up window is currently popping up, other pop-ups can be displayed according to predetermined logic.
[0003] At present, most of the windows are marked with a flag to indicate their appearance and disappearance, and specific windows can be identified by the state of the flag. Taking pop-up windows as an example, when each pop-up window pops up, the flag of the corresponding pop-up window will be set to the pop-up state, and when each pop-up window disappears, the flag of the corresponding pop-up window will also be set to the disappeared state. When the application wants to display each pop-up window, it needs to use the flags of all other pop-up windows to determine whether all other pop-up windows are popping up. In other words, with this existing method, when there are many specific windows to be identified, the number of flags will also increase accordingly, the management cost will be high, confusion will easily occur, and it will lead to inaccurate window identification and low application performance. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a window recognition method, apparatus, device, and computer-readable storage medium to improve the accuracy of window recognition and enhance application performance. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present invention provides a window recognition method, comprising:
[0006] Get the root view of the target display page;
[0007] Traversing each subview of the root view in sequence, and for each traversed subview, determining whether a target point is within the display area of the current subview, the target point being the estimated location of a window of the target window type on the terminal screen;
[0008] If the target point is in the display area of the current sub-view and the current sub-view belongs to the target window type, it is determined that a window of the target window type exists on the target display page.
[0009] In a specific embodiment of the present invention, whether the current subview belongs to the target window type is determined by the following steps:
[0010] Obtaining attribute information of the current subview by reading the class field of the current subview;
[0011] Determine whether the current subview belongs to the target window type according to the attribute information of the current subview.
[0012] In a specific embodiment of the present invention, traversing each subview of the root view in sequence includes:
[0013] Based on the subview array corresponding to the root view, traverse each subview of the root view in turn.
[0014] In a specific embodiment of the present invention, determining whether the target point is in the display area of the current subview includes:
[0015] Determining the view coordinates of the current subview in a screen coordinate system and the view size of the current subview, wherein the screen coordinate system has the upper left corner of the terminal screen as its origin, the horizontal axis increases to the right, and the vertical axis increases downward, the view coordinates include the horizontal coordinate and the vertical coordinate of the upper left corner of the current subview, and the view size includes the width and height;
[0016] If the following conditions are met, it is determined that the target point is in the display area of the current subview:
[0017] The horizontal coordinate of the current subview is smaller than the horizontal coordinate of the target point;
[0018] The vertical coordinate of the current subview is smaller than the vertical coordinate of the target point;
[0019] The sum of the horizontal coordinate of the current subview and the width of the current subview is greater than the horizontal coordinate of the target point;
[0020] The vertical coordinate of the current subview plus the height of the current subview is greater than the vertical coordinate of the target point.
[0021] In a specific embodiment of the present invention, traversing each subview of the root view in sequence includes:
[0022] Traverse each first subview of the next level of the root view in turn;
[0023] Accordingly, for each traversed subview, determine whether the target point is in the display area of the current subview, including:
[0024] For each first subview traversed, determine whether the target point is in the display area of the current first subview;
[0025] Correspondingly, if the target point is in the display area of the current subview and the current subview belongs to the target window type, determining whether a window of the target window type exists on the target display page includes:
[0026] If the target point is in the display area of the current first sub-view, and the current first sub-view belongs to the target window type, it is determined that a window of the target window type exists on the target display page.
[0027] In a specific embodiment of the present invention, when the target point is in the display area of the current first sub-view, the method further includes:
[0028] If the current first subview does not belong to the target window type, then let i = 1, and traverse each (i+1)th subview in the next level below the current (i)th subview in sequence. For each (i+1)th subview traversed, determine whether the current (i+1)th subview belongs to the target window type, where i is a positive integer.
[0029] If the current (i+1)th sub-view belongs to the target window type, it is determined that a window of the target window type exists on the target presentation page.
[0030] In a specific embodiment of the present invention, it also includes:
[0031] If each i+1th sub-view of the next level of the current i-th sub-view does not belong to the target window type, then for each i+1th sub-view of the next level of the current i-th sub-view, if the current i+1th sub-view has a sub-view of the next level, let i=i+1, and repeat the step of traversing each i+1th sub-view of the next level of the current i-th sub-view in sequence, and for each i+1th sub-view traversed, determine whether the current i+1th sub-view belongs to the target window type; if the current i+1th sub-view belongs to the target window type, determine whether there is a window of the target window type on the target display page.
[0032] In a specific embodiment of the present invention, it also includes:
[0033] If the target point is not in the display area of each subview of the root view, or none of the subviews whose display areas include the target point belong to the target window type, it is determined that no window of the target window type exists on the target display page.
[0034] In a second aspect, an embodiment of the present invention provides a window recognition device, including:
[0035] Get the module, which is used to obtain the root view of the target display page;
[0036] A traversal module, configured to sequentially traverse each subview of the root view and, for each traversed subview, determine whether a target point is within a display area of the current subview, where the target point is an estimated location where a window of the target window type will appear on the terminal screen;
[0037] An identification module is configured to determine whether a window of the target window type exists on the target display page when the target point is in the display area of the current subview and the current subview belongs to the target window type.
[0038] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0039] Memory for storing computer programs;
[0040] The processor is configured to implement the steps of the window recognition method described in the first aspect when executing the program stored in the memory.
[0041] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the steps of the window recognition method as described in the first aspect.
[0042] By applying the technical solution provided by the embodiment of the present invention, after obtaining the root view of the target display page, each subview of the root view is traversed in turn. For each traversed subview, it can be determined whether the target point is in the display area of the current subview. The target point is the estimated position point where a window of the target window type appears on the screen. If the target point is in the display area of the current subview and the current subview belongs to the target window type, it can be determined that a window of the target window type exists on the target display page. By using the positional relationship between the subview and the target point and the window type of the subview, it is possible to accurately identify whether a corresponding window exists. There is no need to mark the appearance and disappearance of the window through a mark bit, which reduces the management cost of the mark bit, avoids the confusion caused by too many mark bits, improves the accuracy of window recognition, and improves application performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for describing the embodiments or the prior art.
[0044] Figure 1 Figure 1 is an implementation flowchart of a window recognition method according to an embodiment of the present application;
[0045] Figure 2 Figure 2 is a view relationship diagram according to an embodiment of the present application;
[0046] Figure 3 Figure 3 is a structural diagram of a window recognition device according to an embodiment of the present application;
[0047] Figure 4 Figure 4 is a structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0048] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
[0049] The core of the present application is to provide a window recognition method, which can be applied to any application scenario for window recognition. When an application runs on a terminal, sometimes it needs to identify a specific window, and through the identification of the specific window, it can be determined whether the target display page is covered by the specific window, and then different logical judgments can be made. The target display page can be any page currently displayed by the application. For example, the specific window is a pop-up window, and the pop-up window is identified. If the target display page has a pop-up window being popped up, the application needs to control other pop-up windows to be unshowable, and if the target display page does not have any pop-up window being popped up, other pop-up windows can be displayed according to the predetermined logic. For example, the target display page has a pop-up window being popped up, and the pop-up window content is to prompt the user to log in. When the application does not receive the user's operation information and the pop-up window has not disappeared, the application needs to control other pop-up windows to be unshowable.
[0050] After obtaining the root view of the target display page, the embodiment of the present application traverses each child view of the root view in turn. For each child view traversed, it can be determined whether the target point is in the display area of the current child view. The target point is the estimated position point of the window of the target window type appearing on the screen. If the target point is in the display area of the current child view and the current child view belongs to the target window type, it can be determined that the target display page has a window of the target window type. Through the positional relationship between the child view and the target point and the window type of the child view, it can be accurately determined whether the corresponding window exists, without the need to mark the appearance and disappearance of the window by using the mark bit, thereby reducing the management cost of the mark bit, avoiding confusion caused by too many mark bits, improving the accuracy of window recognition, and improving the application performance.
[0051] Referring to Figure 1 Figure 1 is an implementation flowchart of a window recognition method according to an embodiment of the present application, which can include the following steps:
[0052] S110: Obtain the root view of the target display page.
[0053] When the application is running, it displays various pages to the user through the terminal screen. It can be considered that each displayed page is composed of a root view and multiple subviews. If the root view and subviews are represented by a tree structure, the root view is the top-level view, and there can be multiple levels of subviews under it. The subviews of each level can serve as the parent view of the subviews of the next level. In the displayed page, the root view is the bottom-level view, and there can be multiple levels of subviews above it. Figure 2 As shown, the display page W consists of a root view V and sub-views V1, V2, V3, and V4, wherein V1, V2, and V3 are sub-views of the next level of the root view V, V4 is a sub-view of the next level of the sub-view V3, and sub-view V3 is the parent view of sub-view V4.
[0054] The root view is created first. After each subview is created, it is added to the parent view's subview array. When the application needs to identify a specific window, if there are other specific windows to display, it can obtain the root view of the target display page based on the relationship between the subview arrays.
[0055] S120: Traverse each subview of the root view in sequence, and for each traversed subview, determine whether the target point is in the display area of the current subview.
[0056] The target point is the estimated position where the window of the target window type appears on the terminal screen.
[0057] In an embodiment of the present invention, the target window type is the window type of the window to be identified, and the target window type can be a pop-up window type, a card type, etc. The estimated position point where the window of the target window type appears on the terminal screen, i.e., guessPoint, can be determined first, and the estimated position point can be used as the target point. Specifically, the estimated position point where the window of the target window type appears on the terminal screen can be determined based on information such as application configuration. Taking the target window type as a pop-up window type, for example, to identify an ordinary pop-up window in the center of the screen, the estimated position point, i.e., the target point, is the center point of the terminal screen, such as Figure 2 The "*" shown indicates the target point.
[0058] After obtaining the root view of the target display page, you can sequentially traverse each subview of the root view. Specifically, based on the subview array corresponding to the root view, you can sequentially traverse each subview of the root view to improve traversal accuracy. The subview array corresponding to the root view can include an array of subviews with the root view as the parent view and an array of subviews with each subview as the parent view.
[0059] For each subview traversed, it can be determined whether the target point is in the display area of the current subview. Specifically, it can be determined whether the target point is in the display area of the current subview based on the positional relationship between the current subview and the target point on the terminal screen.
[0060] S130: If the target point is in the display area of the current subview and the current subview belongs to the target window type, determine whether a window of the target window type exists on the target display page.
[0061] Each subview has a different window type, such as pop-up window type, card type, etc. According to the attribute information of the subview, the window type to which the subview belongs can be determined.
[0062] It's understandable that views on a page, including the root view and its subviews, are created by code. These views have their attribute information explicitly specified when they are created. For example, an image view is specified as an image type, and a popup view is specified as a popup type. The corresponding attribute information can be stored in the view's class field.
[0063] Therefore, you can determine whether the current subview belongs to the target window type by following the steps below:
[0064] Get the attribute information of the current subview by reading the class field of the current subview;
[0065] Determine whether the current subview belongs to the target window type based on the attribute information of the current subview.
[0066] In other words, for each traversed subview, the current subview's attribute information can be obtained by reading its class field. Based on this attribute information, the current subview's window type can be determined, and further, based on this window type, whether the current subview belongs to the target window type. This improves the accuracy of the judgment. The current subview refers to the subview targeted by the current operation.
[0067] Obtain the root view of the target display page, traverse each subview of the root view, and for each traversed subview, determine whether the target point is within the display area of the current subview. If the target point is within the display area of the current subview and the current subview belongs to the target window type, it can be determined that a window of the target window type exists on the target display page. If other windows of the target window type are to be displayed, they can be controlled not to be displayed first.
[0068] In the process of traversing each subview of the root view in sequence, for each traversed subview, if it is determined that the target point is in the display area of the current subview and the current subview is of the target window type, it can be determined that there is a window of the target window type on the target display page, and it is no longer necessary to determine whether the subsequent target point is in the display area of the subview. For each traversed subview, if the target point is not in the display area of the current subview, or the current subview is not of the target window type, it is possible to continue to determine whether the subsequent target point is in the display area of the subview until all subviews of the root view are traversed.
[0069] By applying the method provided by the embodiment of the present invention, after obtaining the root view of the target display page, each subview of the root view is traversed in sequence. For each traversed subview, it can be determined whether the target point is in the display area of the current subview. The target point is the estimated position point where a window of the target window type appears on the screen. If the target point is in the display area of the current subview and the current subview belongs to the target window type, it can be determined that a window of the target window type exists on the target display page. By using the positional relationship between the subview and the target point and the window type of the subview, it is possible to accurately identify whether a corresponding window exists. There is no need to mark the appearance and disappearance of the window through a mark bit, which reduces the management cost of the mark bit, avoids the confusion caused by too many mark bits, improves the accuracy of window recognition, and improves application performance.
[0070] In one embodiment of the present invention, the method may further include the following steps:
[0071] If the target point is not in the display area of each subview of the root view, or none of the subviews whose display areas include the target point belong to the target window type, it is determined that no window of the target window type exists on the target display page.
[0072] In an embodiment of the present invention, the root view of the target display page is obtained, each subview of the root view is traversed in turn, and for each traversed subview, it is determined whether the target point is in the display area of the current subview. If the target point is not in the display area of each subview of the root view, it can be determined that there is no window of the target window type on the target display page. If there is a subview whose display area contains the target point, but none of the subviews whose display area contains the target point belongs to the target window type, it can be determined that there is no window of the target window type on the target display page. Accurately judging whether there is a window of the target window type on the target display page helps to correctly perform subsequent operations, such as judging whether to display other windows of the target window type.
[0073] In an embodiment of the present application, the step of determining whether the target point is in the display area of the current sub-view can comprise the following steps:
[0074] determining the view coordinates of the current sub-view in the screen coordinate system, and the view size of the current sub-view, the screen coordinate system taking the top-left corner of the terminal screen as the origin, the right direction as the increasing direction of the horizontal axis, and the downward direction as the increasing direction of the vertical axis, the view coordinates comprising the horizontal coordinate and the vertical coordinate of the top-left corner of the current sub-view, and the view size comprising the width size and the height size;
[0075] if the following conditions are met simultaneously, it is determined that the target point is in the display area of the current sub-view:
[0076] the horizontal coordinate of the current sub-view is less than the horizontal coordinate of the target point;
[0077] the vertical coordinate of the current sub-view is less than the vertical coordinate of the target point;
[0078] the horizontal coordinate of the current sub-view plus the width size of the current sub-view is greater than the horizontal coordinate of the target point;
[0079] the vertical coordinate of the current sub-view plus the height size of the current sub-view is greater than the vertical coordinate of the target point.
[0080] For the convenience of description, the above steps are combined for description.
[0081] In an embodiment of the present application, whether the target point is in the display area of the sub-view can be determined by the positional relationship between the sub-view and the target point. A screen coordinate system can be established in advance, which can take the top-left corner of the terminal screen as the origin, the right direction as the increasing direction of the horizontal axis, and the downward direction as the increasing direction of the vertical axis.
[0082] After obtaining the root view of the target display page, each sub-view of the root view is traversed in turn, and for each sub-view traversed, the view coordinates of the current sub-view in the screen coordinate system and the view size of the current sub-view can be determined. The view coordinates comprise the horizontal coordinate and the vertical coordinate of the top-left corner of the current sub-view, and the view size comprises the width size and the height size.
[0083] The target point also has corresponding horizontal coordinates and vertical coordinates in the screen coordinate system.
[0084] According to the view coordinates and the view size of the current sub-view, and the coordinates of the target point, it can be determined:
[0085] whether the horizontal coordinate of the current sub-view is less than the horizontal coordinate of the target point;
[0086] whether the vertical coordinate of the current sub-view is less than the vertical coordinate of the target point;
[0087] Whether the horizontal coordinate of the current subview plus the width of the current subview is greater than the horizontal coordinate of the target point;
[0088] Whether the vertical coordinate of the current subview plus the height of the current subview is greater than the vertical coordinate of the target point.
[0089] If the horizontal coordinate of the current subview is smaller than the horizontal coordinate of the target point, the vertical coordinate of the current subview is smaller than the vertical coordinate of the target point, the horizontal coordinate of the current subview plus the width of the current subview is greater than the horizontal coordinate of the target point, and the vertical coordinate of the current subview plus the height of the current subview is greater than the vertical coordinate of the target point, then it can be considered that the position of the current subview on the terminal screen can cover the position of the target point on the terminal screen, and it can be determined that the target point is in the display area of the current subview.
[0090] For example, the coordinates of the target point in the screen coordinate system are (p_x, p_y), the view coordinates of the current subview are (v_x, v_y), and the view size includes a width size of v_width and a height size of v_height.
[0091] If the following conditions are met at the same time, it can be determined that the target point is in the display area of the current subview:
[0092] 1)v_x <p_x;
[0093] 2)v_y <p_y;
[0094] 3)v_x+v_width>p_x;
[0095] 4)v_y+v_height>p_y.
[0096] Based on the view coordinates and view size of the subview, as well as the coordinates of the target point, the positional relationship between the subview and the target point can be accurately determined, thereby accurately determining whether the display area of the subview contains the target point, providing a basis for further window identification.
[0097] It should be noted that the screen coordinate system can be set according to actual conditions. Accordingly, the view coordinates and the coordinates of the target point need to be transformed according to the screen coordinate system, and the judgment condition for whether the display area of the subview contains the target point also needs to be transformed accordingly. The embodiments of the present invention will not be described in detail.
[0098] In one embodiment of the present invention, traversing each subview of the root view in sequence may include the following steps:
[0099] Traverse each subview of each level of the root view in turn.
[0100] In the embodiment of the present invention, if the root view and each subview are represented by a tree structure, the root view is the top-level view, and there may be multiple levels of subviews under it. After obtaining the root view of the target display page, when traversing each subview of the root view in sequence, each subview of each level of the root view may be traversed in sequence. For example, Figure 2 In the example, V1, V2, and V3 are subviews of the next level of the root view V, and V4 is a subview of the next level of the subview V3. The subviews V1, V2, V3, and V4 of each level of the root view can be traversed in sequence. This traversal is more comprehensive and can improve the accuracy of window recognition.
[0101] In one embodiment of the present invention, traversing each subview of the root view in sequence may include the following steps:
[0102] Traverse each first subview of the next level of the root view in turn;
[0103] Accordingly, for each traversed subview, determining whether the target point is in the display area of the current subview may include the following steps:
[0104] For each first subview traversed, determine whether the target point is in the display area of the current first subview;
[0105] Correspondingly, if the target point is in the display area of the current subview and the current subview belongs to the target window type, determining whether a window of the target window type exists on the target display page may include the following steps:
[0106] If the target point is in the display area of the current first sub-view, and the current first sub-view belongs to the target window type, it is determined that there is a window of the target window type on the target display page.
[0107] In the embodiment of the present invention, if the root view and each subview are represented by a tree structure, the root view is the top-level view, and there may be multiple levels of subviews under it. After obtaining the root view of the target display page, when traversing each subview of the root view in sequence, each first subview of the next level of the root view may be traversed in sequence. There may be multiple first subviews of the next level of the root view. For example, Figure 2 In the figure, the first subviews of the next level of the root view V include V1, V2, and V3, and each first subview V1, V2, and V3 of the next level of the root view can be traversed in sequence.
[0108] In the process of sequentially traversing each first subview in the next level of the root view, for each traversed first subview, it is possible to determine whether the target point is in the display area of the current first subview. If the target point is in the display area of the current first subview and the current first subview belongs to the target window type, it can be determined that a window of the target window type exists on the target display page. The current first subview is the first subview targeted by the current operation.
[0109] Because the first sub-views of the next level of the root view occupy a larger area on the terminal screen and are fewer in number, by traversing each first sub-view of the next level of the root view, it is possible to quickly determine whether the target point is in the display area of a certain first sub-view, and quickly determine whether there is a window of the target window type on the target display page, thereby improving window recognition efficiency.
[0110] After a window of each window type is generated, it will exist as a subview. For any subview, by judging whether the target point is in the display area of the subview and the window type of the subview, it can be determined whether there is a window of the target window type on the target display page.
[0111] In one embodiment of the present invention, when the target point is in the display area of the current first sub-view, the method may further include the following steps:
[0112] Step 1: If the current first subview does not belong to the target window type, set i = 1, and traverse each (i+1)th subview in the next level below the current (i)th subview in turn. For each (i+1)th subview traversed, determine whether the current (i+1)th subview belongs to the target window type, where i is a positive integer.
[0113] Step 2: If the current (i+1)th sub-view belongs to the target window type, it is determined that there is a window of the target window type on the target display page.
[0114] For the convenience of description, the above two steps are combined for explanation.
[0115] In an embodiment of the present invention, after obtaining the root view of the target display page, each first subview of the next level of the root view is traversed in sequence. For each traversed first subview, it is determined whether the target point is in the display area of the current first subview. If the target point is in the display area of the current first subview and the current first subview belongs to the target window type, it can be determined that there is a window of the target window type on the target display page. In the case where the target point is in the display area of the current first subview, if the current first subview does not belong to the target window type, it can be considered that the current first subview is not a window of the target window type to be identified, and further determination is required as to whether there is a window of the target window type on the target display page. In this case, i=1 can be set, and each i+1th subview of the next level of the current i-th subview can be traversed in sequence, that is, each second subview of the next level of the current first subview can be traversed in sequence. Before traversing each second subview of the next level of the current first subview in sequence, it can be determined whether there is a subview of the next level of the current first subview. If so, each second subview of the next level of the current first subview can be traversed in sequence to avoid unnecessary resource consumption.
[0116] For each traversed (i+1) subview, determine whether the current (i+1) subview belongs to the target window type. The current (i+1) subview is the (i+1) subview targeted by the current operation. If the current (i+1) subview belongs to the target window type, then it can be determined that a window of the target window type exists on the target display page. That is, when i=1, for each traversed (second) subview, determine whether the current (second) subview belongs to the target window type. If the second subview belongs to the target window type, then it can be determined that a window of the target window type exists on the target display page.
[0117] If each i+1th sub-view of the next level of the current i-th sub-view does not belong to the target window type, then for each i+1th sub-view of the next level of the current i-th sub-view, if the current i+1th sub-view has a sub-view of the next level, let i=i+1, and repeat the step of traversing each i+1th sub-view of the next level of the current i-th sub-view in sequence, and for each i+1th sub-view traversed, determine whether the current i+1th sub-view belongs to the target window type; if the current i+1th sub-view belongs to the target window type, determine whether there is a window of the target window type on the target display page.
[0118] for example, Figure 2In the embodiment, the first sub-view of the next level of the root view V includes V1, V2, and V3, the second sub-view of the next level of the first sub-view V3 includes V4, and "*" represents the target point. After the root view of the target display page is obtained, each first sub-view V1, V2, and V3 of the next level of the root view can be sequentially traversed. The target point is not in the display area of the first sub-views V1 and V2 and is in the display area of the first sub-view V3. If the first sub-view V3 does not belong to the target window type, each second sub-view of the next level of the first sub-view V3 can be sequentially traversed. Here, the second sub-view of the next level of the first sub-view V3 is V4. Whether the second sub-view V4 belongs to the target window type can be determined. If the second sub-view V4 belongs to the target window type, it is determined that the window of the target window type exists on the target display page. If the second sub-view V4 does not belong to the target window type and no other sub-view can be traversed, it is determined that the window of the target window type does not exist on the target display page.
[0119] That is, after the root view of the target display page is obtained, each first sub-view of the next level of the root view is sequentially traversed. For each first sub-view of the next level of the root view, if the target point is in the display area of the current first sub-view, subsequent determination of whether the target point is in the display area of other first sub-views is not performed. It is considered that the target point is also in the display area of each second sub-view of the next level of the current first sub-view.
[0120] In the case where the current first sub-view does not belong to the target window type, each second sub-view of the next level of the current first sub-view is sequentially traversed. For each second sub-view traversed, whether the current second sub-view belongs to the target window type is determined. If the current second sub-view belongs to the target window type, subsequent determination of whether other second sub-views belong to the target window type is not performed, and it is directly determined that the window of the target window type exists on the target display page.
[0121] If each second sub-view of the next level of the current first sub-view does not belong to the target window type, for each second sub-view of the next level of the current first sub-view, if the current second sub-view has a sub-view of the next level, each third sub-view of the next level of the current second sub-view is sequentially traversed. For each third sub-view traversed, whether the current third sub-view belongs to the target window type is determined. If the current third sub-view belongs to the target window type, subsequent determination of whether other third sub-views belong to the target window type is not performed, and it is directly determined that the window of the target window type exists on the target display page.
[0122] The judgment is performed recursively in this way, and the range of views to be judged is gradually narrowed. In many cases, there is no need to traverse all subviews. After determining that the subview whose display area contains the target point, there is no need to judge whether the target point is in the display area of other subviews, which improves the window recognition efficiency and improves the application performance.
[0123] Corresponding to the above method embodiment, an embodiment of the present invention further provides a window recognition device. The window recognition device described below and the window recognition method described above can refer to each other.
[0124] See also Figure 3 As shown, the device may include the following modules:
[0125] An acquisition module 310 is used to obtain the root view of the target display page;
[0126] A traversal module 320 is configured to sequentially traverse each subview of the root view and, for each traversed subview, determine whether a target point is within the display area of the current subview. The target point is the estimated location of a window of the target window type on the terminal screen.
[0127] The identification module 330 is configured to determine whether a window of the target window type exists on the target display page when the target point is in the display area of the current subview and the current subview belongs to the target window type.
[0128] By applying the device provided by the embodiment of the present invention, after obtaining the root view of the target display page, each subview of the root view is traversed in sequence. For each traversed subview, it can be determined whether the target point is in the display area of the current subview. The target point is the estimated position point where a window of the target window type appears on the screen. If the target point is in the display area of the current subview and the current subview belongs to the target window type, it can be determined that a window of the target window type exists on the target display page. By using the positional relationship between the subview and the target point and the window type of the subview, it is possible to accurately identify whether a corresponding window exists. There is no need to mark the appearance and disappearance of the window through a mark bit, which reduces the management cost of the mark bit, avoids the confusion caused by too many mark bits, improves the accuracy of window recognition, and improves application performance.
[0129] In a specific implementation method of the present invention, a judgment module may be further included, configured to judge whether the current subview belongs to the target window type by performing the following steps:
[0130] Get the attribute information of the current subview by reading the class field of the current subview;
[0131] Determine whether the current subview belongs to the target window type based on the attribute information of the current subview.
[0132] In a specific implementation method of the present invention, the traversal module 320 is used to:
[0133] Based on the subview array corresponding to the root view, traverse each subview of the root view in turn.
[0134] In a specific embodiment of the present invention, the traversal module 320 is configured to:
[0135] Traverse each subview of each level of the root view in turn.
[0136] In a specific embodiment of the present invention, the traversal module 320 is configured to:
[0137] Traverse each first subview of the next level of the root view in turn;
[0138] For each first subview traversed, determine whether the target point is in the display area of the current first subview;
[0139] The identification module 330 is configured to:
[0140] When the target point is in the display area of the current first subview and the current first subview belongs to the target window type, it is determined that a window of the target window type exists on the target display page.
[0141] In a specific embodiment of the present invention, the identification module 330 is further configured to:
[0142] When the target point is in the display area of the current first subview, if the current first subview does not belong to the target window type, then let i = 1, traverse each (i+1)th subview of the next level below the current (i)th subview in sequence, and for each (i+1)th subview traversed, determine whether the current (i+1)th subview belongs to the target window type, where i is a positive integer;
[0143] If the current (i+1)th sub-view belongs to the target window type, it is determined that a window of the target window type exists on the target presentation page.
[0144] In a specific embodiment of the present invention, the identification module 330 is further configured to:
[0145] If each i+1th sub-view of the next level of the current i-th sub-view does not belong to the target window type, then for each i+1th sub-view of the next level of the current i-th sub-view, if the current i+1th sub-view has a sub-view of the next level, let i=i+1, and repeat the step of traversing each i+1th sub-view of the next level of the current i-th sub-view in sequence, and for each i+1th sub-view traversed, determine whether the current i+1th sub-view belongs to the target window type; if the current i+1th sub-view belongs to the target window type, determine whether there is a window of the target window type on the target display page.
[0146] In a specific embodiment of the present invention, the traversal module 320 is configured to:
[0147] Determine the view coordinates of the current subview in the screen coordinate system, as well as the view size of the current subview. The screen coordinate system takes the upper left corner of the terminal screen as its origin, with the horizontal axis increasing to the right and the vertical axis increasing downward. The view coordinates include the horizontal and vertical coordinates of the upper left corner of the current subview, and the view size includes the width and height.
[0148] If the following conditions are met, the target point is determined to be in the display area of the current subview:
[0149] The horizontal coordinate of the current subview is smaller than the horizontal coordinate of the target point;
[0150] The vertical coordinate of the current subview is smaller than the vertical coordinate of the target point;
[0151] The horizontal coordinate of the current subview plus the width of the current subview is greater than the horizontal coordinate of the target point;
[0152] The vertical coordinate of the current subview plus the height of the current subview is greater than the vertical coordinate of the target point.
[0153] In a specific embodiment of the present invention, the identification module 330 is further configured to:
[0154] If the target point is not in the display area of each subview of the root view, or none of the subviews whose display areas include the target point belong to the target window type, it is determined that no window of the target window type exists on the target display page.
[0155] The embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.
[0156] Memory 403, used for storing computer programs;
[0157] The processor 401 is configured to execute the program stored in the memory 403 by performing the following steps:
[0158] Get the root view of the target display page;
[0159] Traverse each subview of the root view in turn, and for each traversed subview, determine whether the target point is in the display area of the current subview. The target point is the estimated position where the window of the target window type will appear on the terminal screen;
[0160] If the target point is in the display area of the current subview and the current subview belongs to the target window type, it is determined that there is a window of the target window type on the target display page.
[0161] The communication bus 404 mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 404 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the figure shows only one thick line, but this does not mean that there is only one bus or only one type of bus.
[0162] The communication interface 402 is used for communication between the terminal and other devices.
[0163] The memory 403 may include a random access memory (RAM) or a non-volatile memory, such as at least one disk storage. Alternatively, the memory 403 may be at least one storage device located away from the processor.
[0164] The above-mentioned processor 401 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0165] In yet another embodiment provided by the present application, a computer readable storage medium is provided, which stores instructions, when executed on a computer, cause the computer to perform the steps of the window identification method of any of the above embodiments.
[0166] In yet another embodiment provided by the present application, a computer program product is provided, which contains instructions, when executed on a computer, cause the computer to perform the steps of the window identification method of any of the above embodiments.
[0167] In the above embodiments, the implementation can be wholly or partially in software, hardware, firmware, or any combination thereof. When implemented in software, the implementation can be in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, the computer program instructions cause the computer to perform the processes or functions in accordance with the embodiments of the present application. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, from a website site, a computer, a server, or a data center to another website site, a computer, a server, or a data center through a wired (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) manner. The computer readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media sets. The available media can be a magnetic medium (for example, floppy disk, hard disk, magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, solid state disk (SSD)), etc.
[0168] It should be noted that, in this document, the terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.
[0169] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0170] The above are only preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A window recognition method, characterized in that: include: Get the root view of the target display page; Traversing each subview of the root view in sequence, and for each traversed subview, determining whether a target point is within a display area of the current subview, including: traversing each first subview of a layer below the root view in sequence; for each traversed first subview, determining whether a target point is within a display area of the current first subview; the target point being an estimated location of a window of the target window type on the terminal screen; If the target point is in the display area of the current sub-view and the current sub-view belongs to the target window type, then determining that a window of the target window type exists on the target display page includes: if the target point is in the display area of the current first sub-view and the current first sub-view belongs to the target window type, then determining that a window of the target window type exists on the target display page.
2. The window recognition method according to claim 1, characterized in that: Determine whether the current subview belongs to the target window type by the following steps: Obtaining attribute information of the current subview by reading the class field of the current subview; Determine whether the current subview belongs to the target window type according to the attribute information of the current subview.
3. The window recognition method according to claim 1, characterized in that: The step of traversing each subview of the root view in sequence includes: Based on the subview array corresponding to the root view, traverse each subview of the root view in turn.
4. The window recognition method according to claim 1, characterized in that: The determining whether the target point is in the display area of the current subview includes: Determining the view coordinates of the current subview in a screen coordinate system and the view size of the current subview, wherein the screen coordinate system has the upper left corner of the terminal screen as its origin, the horizontal axis increases to the right, and the vertical axis increases downward, the view coordinates include the horizontal coordinate and the vertical coordinate of the upper left corner of the current subview, and the view size includes the width and height; If the following conditions are met, it is determined that the target point is in the display area of the current subview: The horizontal coordinate of the current subview is smaller than the horizontal coordinate of the target point; The vertical coordinate of the current subview is smaller than the vertical coordinate of the target point; The sum of the horizontal coordinate of the current subview and the width of the current subview is greater than the horizontal coordinate of the target point; The vertical coordinate of the current subview plus the height of the current subview is greater than the vertical coordinate of the target point.
5. The window recognition method according to claim 1, characterized in that: In a case where the target point is in the display area of the current first sub-view, the method further includes: If the current first subview does not belong to the target window type, then let i = 1, and traverse each (i+1)th subview in the next level below the current (i)th subview in sequence. For each (i+1)th subview traversed, determine whether the current (i+1)th subview belongs to the target window type, where i is a positive integer. If the current (i+1)th sub-view belongs to the target window type, it is determined that a window of the target window type exists on the target presentation page.
6. The window recognition method according to claim 5, characterized in that: Also includes: If each i+1th sub-view of the next level of the current i-th sub-view does not belong to the target window type, then for each i+1th sub-view of the next level of the current i-th sub-view, if the current i+1th sub-view has a sub-view of the next level, let i=i+1, and repeat the step of traversing each i+1th sub-view of the next level of the current i-th sub-view in sequence, and for each i+1th sub-view traversed, determine whether the current i+1th sub-view belongs to the target window type; if the current i+1th sub-view belongs to the target window type, determine whether there is a window of the target window type on the target display page.
7. The window recognition method according to any one of claims 1 to 6, characterized in that: Also includes: If the target point is not in the display area of each subview of the root view, or none of the subviews whose display areas include the target point belong to the target window type, it is determined that no window of the target window type exists on the target display page.
8. A window recognition device, characterized in that: include: Get the module, which is used to obtain the root view of the target display page; a traversal module, configured to sequentially traverse each subview of the root view and, for each traversed subview, determine whether a target point is within a display area of the current subview, including: sequentially traversing each first subview of a lower level of the root view; and, for each traversed first subview, determining whether a target point is within a display area of the current first subview; the target point being an estimated location of a window of the target window type on the terminal screen; An identification module is used to determine whether a window of the target window type exists on the target display page when the target point is in the display area of the current sub-view and the current sub-view belongs to the target window type, including: when the target point is in the display area of the current first sub-view and the current first sub-view belongs to the target window type, determining whether a window of the target window type exists on the target display page.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory for storing computer programs; The processor is configured to implement the steps of the window recognition method according to any one of claims 1 to 7 when executing the program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the window recognition method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Conference all-in-one machine, screen segmentation display method and storage device
CN114296848A