A desktop chat window capturing method
By employing a dual-channel screenshot mechanism, the stability and interference issues of desktop chat window screenshots are resolved, achieving an efficient and low-interference chat window capture method, thereby improving the system's robustness and recognition accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
- Filing Date
- 2026-04-27
- Publication Date
- 2026-07-21
AI Technical Summary
Existing technologies for capturing desktop chat windows suffer from problems such as insufficient stability of the window capture channel, forced foreground capture interfering with user operation, invalid screenshots leading to downstream processing errors, and lack of automatic recovery capabilities, making it difficult to capture chat window content stably and efficiently in diverse desktop environments.
A dual-channel screenshot mechanism is adopted. First, the first candidate screenshot is obtained without switching the window handle in the foreground. The size consistency and image color dispersion are judged. If it is invalid, the second candidate screenshot is executed in the foreground to ensure high-quality screenshot output.
It effectively reduces user interference from screenshots, automatically identifies invalid images, enhances system robustness, improves recognition accuracy and processing stability, and improves user experience and system usability.
Smart Images

Figure CN122431780A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and computer vision technology, and in particular to a method for capturing desktop chat windows. Background Technology
[0002] In desktop chat assistance systems, screenshots are the initial input step in the entire processing chain. The system first captures an image of the target chat window via screenshot, then sequentially performs subsequent processing such as OCR text recognition, chat structure parsing, extraction of the latest user questions, and generation of reply content. Therefore, the quality of the screenshot directly determines whether the entire processing chain can function properly: if the screenshot itself is invalid, even the most powerful subsequent OCR and natural language processing models cannot recover the true chat content from the invalid image.
[0003] Unlike ordinary static image processing, screenshotting chat windows in a desktop environment faces multiple challenges in practical engineering, including complex window rendering mechanisms, variable operating system states, and different implementation methods across various applications. Existing technologies typically have the following shortcomings and drawbacks when dealing with such problems:
[0004] First, the stability of the single-window screenshot channel is insufficient. Existing solutions use only one window screenshot interface, assuming its output is always available. However, in actual operation, this type of interface often fails to return true and valid window content. Specifically, this manifests as: abnormal image size (e.g., expected 906×758 pixels, but only a small 199×34 pixel image is returned), partial missing image content, or even a solid color or blank image with almost no texture information. Because these interfaces typically do not explicitly report errors, the system cannot directly determine whether the screenshot is usable from the return value.
[0005] Secondly, forcing foreground screenshots interferes with normal user operations. To ensure a high success rate for screenshots, the target chat window is forcibly switched to the foreground before each screenshot is taken. While this method can reliably capture the window content, it significantly interrupts other desktop operations the user is performing, resulting in a decreased user experience when using auxiliary tools and severely impacting the usability and practicality of the tools.
[0006] Third, invalid screenshots often only reveal problems in downstream processing stages. Existing systems lack quality assessment mechanisms at the screenshot level, allowing invalid images to directly enter the OCR and model recognition stages. The consequence is a chain of system failures such as "empty recognition result," "invalid chat structure," and "failure to extract the latest question." These failures are unrelated to the screenshot itself, making problem localization difficult, and developers and users struggle to trace the error back to its source.
[0007] Fourth, there is a lack of automatic recovery capabilities for window screenshot failure scenarios. When the preferred window screenshot channel fails, existing solutions can usually only report the error to the user or ask the user to retry manually. They lack the ability to automatically switch to another available capture channel and re-execute the screenshot, which makes the system less robust and difficult to adapt to diverse desktop environments in engineering deployments.
[0008] Chinese patent CN101079843A discloses a screenshot method for instant messaging (IM). This method eliminates the obstruction of the screenshot area by actively hiding the chat window, allowing users to take screenshots without manually moving the window. However, in practical applications, forcibly hiding the window interrupts the user's real-time perception of the chat content. The hiding and restoring process relies on window feature recognition, which carries the risk of recognition failure. After hiding, waiting for the window to refresh via a timer increases screenshot latency. Each screenshot requires executing the complete "hide, screenshot, restore" process, making it unsuitable for continuous screenshot scenarios. The solution is limited to IM scenarios and lacks a mechanism for judging and ensuring the quality of the screenshot itself.
[0009] Therefore, how to provide a desktop chat window capture method that can prioritize preserving low-interference screenshot paths and automatically identify and recapture invalid screenshots has become an urgent technical problem to be solved. Summary of the Invention
[0010] In view of this, in order to overcome the shortcomings of the prior art, the present invention aims to provide a method for capturing desktop chat windows.
[0011] This invention provides a method for capturing a desktop chat window, the method comprising:
[0012] Step S1: Obtain the boundary information of the target chat window and calculate the expected screenshot size based on the boundary information;
[0013] Step S2: Without switching the target chat window to the foreground, perform a first-channel window-level screenshot based on the handle of the target chat window to obtain the first candidate screenshot;
[0014] Step S3: Perform validity determination on the first candidate screenshot, including size consistency judgment and image color dispersion judgment;
[0015] Step S4: When the first candidate screenshot is determined to be invalid, the target chat window is activated to the foreground, and the second channel area is captured based on the boundary information to obtain the second candidate screenshot. The first or second candidate screenshot is then selected as the final output screenshot.
[0016] Optionally, in the desktop chat window capture method of the present invention, step S1, the expected screenshot size is calculated as follows:
[0017] Based on the operating system handle of the target chat window, read the coordinates of the left, top, right, and bottom boundaries of the target chat window in the screen coordinate system;
[0018] Calculate the expected screenshot width based on the difference between the left and right boundaries, and calculate the expected screenshot height based on the difference between the top and bottom boundaries;
[0019] If the calculated expected screenshot width or height is less than or equal to zero, the window size is deemed invalid and the subsequent screenshot process is terminated.
[0020] Optionally, in the desktop chat window capture method of the present invention, the first candidate screenshot is specifically implemented as follows: based on the operating system handle of the target chat window, the window drawing content capture interface provided by the operating system is called, and the current drawing image content of the target window is directly obtained as the first candidate screenshot without changing the current desktop window focus state, without switching the target window to the foreground, and without interrupting the user's current desktop operation.
[0021] Optionally, in the desktop chat window capture method of the present invention, step S3 involves performing a size consistency judgment on the first candidate screenshot in the following manner:
[0022] Read the actual width and actual height of the first candidate screenshot, compare the actual width with the expected screenshot width, and compare the actual height with the expected screenshot height;
[0023] When the difference between the actual width and the expected screenshot width exceeds the preset size tolerance range, or the difference between the actual height and the expected screenshot height exceeds the preset size tolerance range, the first candidate screenshot is determined to be invalid in terms of size. The preset size tolerance range is used to adapt to minor size deviations caused by window borders, system shadows, or display scaling.
[0024] Optionally, in the desktop chat window capture method of the present invention, in step S3, the preset size tolerance range is specifically set to no more than 2 pixels. When the deviation between the actual width of the first candidate screenshot and the expected screenshot width is greater than 2 pixels, or the deviation between the actual height and the expected screenshot height is greater than 2 pixels, the size consistency judgment is determined to be unsuccessful.
[0025] Optionally, in the desktop chat window capture method of the present invention, step S3 involves performing image color dispersion discrimination on the first candidate screenshot in the following manner:
[0026] Convert the first candidate screenshot to RGB color space representation, and calculate the minimum and maximum values of all pixel values in the red, green and blue channels respectively;
[0027] Calculate the difference between the maximum and minimum values of each channel to obtain the color range value of each channel;
[0028] When the color range values of the red, green, and blue channels are all lower than the preset color dispersion threshold, the first candidate screenshot is determined to be invalid in the image content dimension.
[0029] Optionally, in the desktop chat window capture method of the present invention, in step S3, the preset color dispersion threshold is specifically set to no more than 8. When the difference between the maximum and minimum values of the red channel, the difference between the maximum and minimum values of the green channel, and the difference between the maximum and minimum values of the blue channel are all less than or equal to 8, the image color dispersion judgment is deemed to fail, and the first candidate screenshot is considered invalid.
[0030] Optionally, in the desktop chat window capture method of the present invention, in step S3, a size consistency judgment is first performed. If the size consistency judgment is passed, the image color dispersion judgment is then performed. Only when both the size consistency judgment and the image color dispersion judgment are passed is the first candidate screenshot deemed valid and directly used as the final output screenshot. If the size consistency judgment is not passed, the first candidate screenshot is deemed invalid.
[0031] Optionally, in the desktop chat window capture method of the present invention, the specific implementation of the second candidate screenshot in step S4 is as follows:
[0032] Call the operating system window management interface to set the target chat window as the foreground active window. After the window switching is completed, wait for a preset window content refresh stability delay.
[0033] After the delay ends, based on the target chat window boundary information obtained in step S1, the rectangular area for capturing images on the screen is determined, and the area capture operation is performed to capture the screen image within the rectangular area as the second candidate screenshot.
[0034] Optionally, in the desktop chat window capture method of the present invention, after selecting the final output screenshot in step S4, the method further includes outputting boundary information in the following manner: saving the final output screenshot to a specified screenshot directory, and outputting the window boundary coordinate information corresponding to the final output screenshot to the downstream module in the form of structured data for reuse in the same coordinate system.
[0035] The desktop chat window capture method of the present invention has the following beneficial technical effects:
[0036] 1. Prioritize retaining low-interference screenshot paths to improve user experience.
[0037] It effectively reduces the interference of the screenshot process on the user's normal work, and significantly improves the usability and user acceptance of desktop auxiliary tools.
[0038] 2. Automatically identify invalid images in the cropping layer to block the spread of errors at the source.
[0039] It can intercept images with abnormal size and near-blank images at the forefront, preventing invalid images from flowing into the downstream OCR and model recognition stages, and fundamentally reducing the chain of recognition errors caused by screenshot distortion.
[0040] Third, it has automatic rollback and recovery capabilities, enhancing system robustness.
[0041] It can reliably obtain the real interface content when the first channel is limited by the window rendering mechanism, and can complete the screenshot task under various abnormal scenarios, significantly improving the engineering stability of the screenshot module.
[0042] IV. Provide high-quality input for subsequent recognition processes and improve overall recognition accuracy.
[0043] This effectively reduces recognition failures caused by screenshot quality issues, thereby improving the recognition accuracy and processing stability of the entire chat assistance system.
[0044] 5. Synchronously output window boundary coordinate information to facilitate reuse by downstream modules.
[0045] There is no need to repeatedly obtain the window position or recalculate the boundary, thereby improving the efficiency of the overall processing flow and the collaboration between modules. Attached Figure Description
[0046] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1 This is a flowchart illustrating a desktop chat window capture method according to an exemplary embodiment 1 of the present invention;
[0048] Figure 2 A flowchart illustrating the process of calculating the expected screenshot size for a desktop chat window capture method according to an exemplary embodiment 1 of the present invention;
[0049] Figure 3 A schematic diagram illustrating the process of performing size consistency determination in the desktop chat window capture method according to exemplary embodiment 1 of the present invention;
[0050] Figure 4 A schematic diagram illustrating the process of performing image color dispersion determination in the desktop chat window capture method according to exemplary embodiment 1 of the present invention;
[0051] Figure 5This is a flowchart illustrating the process of performing validity determination on a first candidate screenshot according to the desktop chat window capture method of exemplary embodiment 1 of the present invention. Detailed Implementation
[0052] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0053] It should be noted that, in the absence of conflict, the following embodiments and features can be combined with each other; and, based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0054] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.
[0055] Example 1
[0056] Exemplary embodiment 1 of the present invention provides a method for capturing a desktop chat window. Figure 1 This is a flowchart illustrating a desktop chat window capture method according to an exemplary embodiment 1 of the present invention, as shown below. Figure 1 As shown, in this embodiment, the method of the present invention is implemented in the following manner:
[0057] Step S1: Obtain the boundary information of the target chat window and calculate the expected screenshot size based on the boundary information.
[0058] Figure 2 A schematic flowchart illustrating the calculation of the expected screenshot size using the desktop chat window capture method according to Exemplary Embodiment 1 of the present invention is shown below. Figure 2 As shown, in this embodiment, the expected screenshot size is calculated as follows: based on the operating system handle of the target chat window, the coordinates of the left, top, right, and bottom boundaries of the target chat window in the screen coordinate system are read; the expected screenshot width is calculated based on the difference between the left and right boundaries, and the expected screenshot height is calculated based on the difference between the top and bottom boundaries; if the calculated expected screenshot width or expected screenshot height is less than or equal to zero, the window size is determined to be invalid and the subsequent screenshot process is terminated.
[0059] Step S2: Without switching the target chat window to the foreground, perform a first-channel window-level screenshot based on the handle of the target chat window to obtain the first candidate screenshot.
[0060] In this embodiment, the first candidate screenshot is implemented as follows: based on the operating system handle of the target chat window, the window drawing content capture interface provided by the operating system is called, and the current drawing image content of the target window is directly obtained as the first candidate screenshot without changing the current desktop window focus state, switching the target window to the foreground, or interrupting the user's current desktop operation.
[0061] Step S3: Perform validity determination on the first candidate screenshot, including size consistency judgment and image color dispersion judgment.
[0062] Figure 3 A schematic diagram illustrating the process of performing size consistency determination in the desktop chat window capture method according to exemplary embodiment 1 of the present invention is shown below. Figure 3 As shown, in this embodiment, the size consistency judgment of the first candidate screenshot is performed in the following manner:
[0063] Read the actual width and actual height of the first candidate screenshot, compare the actual width with the expected screenshot width, and compare the actual height with the expected screenshot height;
[0064] When the difference between the actual width and the expected screenshot width exceeds the preset size tolerance range, or the difference between the actual height and the expected screenshot height exceeds the preset size tolerance range, the first candidate screenshot is determined to be invalid in terms of size. The preset size tolerance range is used to adapt to minor size deviations caused by window borders, system shadows, or display scaling.
[0065] For example, in practical applications, the preset size tolerance range is specifically set to no more than 2 pixels. When the actual width of the first candidate screenshot deviates from the expected screenshot width by more than 2 pixels, or the actual height deviates from the expected screenshot height by more than 2 pixels, the size consistency judgment fails.
[0066] Figure 4 This is a schematic diagram illustrating the process of image color dispersion discrimination in the desktop chat window capture method according to Exemplary Embodiment 1 of the present invention, as follows: Figure 4 As shown, in this embodiment, the image color dispersion is determined for the first candidate screenshot in the following manner:
[0067] The first candidate screenshot is converted into an RGB color space representation. The minimum and maximum values of all pixel values in the red, green, and blue channels are calculated respectively. The difference between the maximum and minimum values of each channel is calculated to obtain the color range value of each channel. When the color range values of the red, green, and blue channels are all lower than the preset color dispersion threshold, the first candidate screenshot is determined to be invalid in the image content dimension.
[0068] For example, in practical applications, the preset color dispersion threshold is specifically set to no more than 8. When the difference between the maximum and minimum values of the red channel, the green channel, and the blue channel is all less than or equal to 8, the image color dispersion judgment fails, and the first candidate screenshot is considered invalid.
[0069] Figure 5 This is a flowchart illustrating the process of determining the validity of a first candidate screenshot using the desktop chat window capture method according to an exemplary embodiment 1 of the present invention. Figure 5 As shown, in this embodiment, size consistency judgment is performed first. If the size consistency judgment is passed, image color dispersion judgment is performed. Only when both size consistency judgment and image color dispersion judgment are passed is the first candidate screenshot deemed valid and directly used as the final output screenshot. If the size consistency judgment is not passed, the first candidate screenshot is deemed invalid.
[0070] Step S4: When the first candidate screenshot is determined to be invalid, the target chat window is activated to the foreground, and the second channel area is captured based on the boundary information to obtain the second candidate screenshot. The first or second candidate screenshot is then selected as the final output screenshot.
[0071] In this embodiment, the second candidate screenshot is implemented as follows:
[0072] Call the operating system window management interface to set the target chat window as the foreground active window. After the window switching is completed, wait for a preset window content refresh stabilization delay. After the delay ends, determine the screenshot rectangle area on the screen based on the target chat window boundary information obtained in step S1, perform the area screenshot operation, and capture the screen image within the rectangle area as the second candidate screenshot.
[0073] In practical applications, after selecting the final output screenshot, the method according to this embodiment also includes outputting boundary information in the following manner: saving the final output screenshot to a specified screenshot directory, and outputting the window boundary coordinate information corresponding to the final output screenshot to the downstream module in the form of structured data for reuse in the same coordinate system.
[0074] Example 2
[0075] Exemplary Example 2 of the present invention provides a desktop chat window capture method. In this embodiment, a first-channel window-level screenshot that does not rely on the user's active foreground switching is preferred. After obtaining the first candidate screenshot, its validity is judged from two dimensions: size consistency and image color dispersion. If it is determined to be invalid, the method automatically switches to the second channel, that is, the target window is first activated to the foreground, and then the area is captured according to the window rectangle boundary. Finally, a chat window screenshot that can be stably used for downstream recognition is output.
[0076] Specifically, in this embodiment, the method of the present invention is implemented in the following manner:
[0077] Step 1: Read the target window boundary information
[0078] Obtain the window rectangle boundary based on the target chat window handle; calculate the expected screenshot width and expected screenshot height as the basis for subsequent size determination.
[0079] Step 2: Take a screenshot of the first channel window.
[0080] Without requiring the user to switch to the foreground first, the first channel screenshot is performed based on the target window handle; the first channel prioritizes obtaining the complete drawing content of the target window, minimizing interference with the user's current desktop focus.
[0081] Step 3: Perform screenshot validity check
[0082] Perform size consistency judgment on the first candidate screenshot, comparing the actual width and actual height of the first candidate screenshot with the expected screenshot width and expected screenshot height; perform image color dispersion judgment on the first candidate screenshot, determining whether the pixel range of each color channel of the image meets the minimum interface content requirements; when the size of the first candidate screenshot exceeds the preset tolerance range, or the color distribution of the image is approximately a monochromatic plane, the first candidate screenshot is determined to be invalid.
[0083] Step 4: Perform a second-channel rollback to capture the image.
[0084] When the first candidate screenshot is deemed invalid, the target chat window is switched to the foreground active window; the second channel area is captured based on the window's rectangular boundary to obtain the second candidate screenshot; this is the remedial path when the second channel fails as the first choice.
[0085] Step 5: Output the final screenshot result
[0086] If the first candidate screenshot is valid, it is directly output as the final screenshot; if the first candidate screenshot is invalid, the second candidate screenshot is output, and the window boundary coordinate information corresponding to the screenshot is output simultaneously; the final screenshot is saved to the screenshot directory for subsequent use by the OCR (Optical Character Recognition) and chat structure recognition modules.
[0087] Through the above steps, this embodiment moves the screenshot quality control forward to the image acquisition layer, realizing a dual-channel acquisition mechanism of "first low-interference attempt, then automatic discrimination, and finally conditional fallback", thereby reducing the probability of invalid screenshots entering the downstream recognition link.
[0088] Example 3
[0089] Exemplary embodiment 3 of the present invention provides a method for capturing a desktop chat window. In this embodiment, the method of the present invention is implemented in the following manner:
[0090] Step 1: Reading window boundaries and calculating expected size
[0091] Given the handle of the target chat window, first read the coordinates of the window's left, top, right, and bottom boundaries, and calculate the window's expected width and height. This expected size serves as the criterion for determining the reliability of the subsequent first candidate screenshot.
[0092] If the window width or height is less than or equal to zero, it indicates that the window may be minimized or the window information is abnormal. An invalid window size error can be reported directly to prevent subsequent screenshots from being taken and the process from continuing.
[0093] Step 2: Screenshot the first channel window.
[0094] The first channel is prioritized for window-level screenshotting to capture the target chat window without interrupting the user's current desktop operations. This channel can attempt to obtain the rendering result of the target window directly when the window is not manually brought to the foreground, thus minimizing user interference. However, in engineering practice, the first channel does not always return usable window content; sometimes it returns an abnormally sized small image, and sometimes, although the size appears correct, the image is almost entirely a single background color. Therefore, this embodiment does not directly regard the output of the first channel as the final result, but instead forces the user to proceed to the next step of validity determination.
[0095] Step 3: Dimensional Consistency Judgment
[0096] After the first candidate screenshot is generated, its actual width and height are compared with the expected width and height calculated from the window boundaries. For example, if the theoretical size corresponding to the window boundaries is 906×758, but the first channel only returns a 199×34 image, the screenshot is clearly distorted and can be directly determined as invalid. A small pixel tolerance is allowed in the size comparison to accommodate slight deviations caused by window borders, shadows, or scaling. In practical applications, the tolerance can be set to 2 pixels.
[0097] Step 4: Image color dispersion determination
[0098] If the size of the first candidate screenshot is roughly as expected, the system continues to check whether its image content actually contains the chat interface. Specifically, the screenshot is converted to an RGB image, and the maximum and minimum values of each color channel are read, along with the color range for each channel. If the variation range of all three color channels is extremely small, it indicates that although the image size is correct, the content is approximately a solid color plane or a blank screen, lacking any real interface information for subsequent identification. For example, if the upper limit of the color dispersion range does not exceed 8, the first candidate screenshot is deemed invalid. This step is used to identify hidden faults such as "the size looks correct, but the content is actually empty."
[0099] Step 5: Second channel rollback screenshot
[0100] When the first candidate screenshot is deemed invalid after size or color dispersion testing, the system automatically switches to the second channel to perform a fallback screenshot. The second channel first brings the target chat window to the foreground, then directly performs a region capture based on the known window boundaries to obtain the second candidate screenshot. For example, after bringing the window to the foreground, a short wait is made before performing the region capture to ensure the window content is fully refreshed and visible. In this way, even when the first channel is limited by the window rendering mechanism, foreground region capture can reliably obtain the true interface content.
[0101] Step Six: Final Screenshot Saving and Boundary Output
[0102] If the first candidate screenshot passes the validity check, the first candidate screenshot is saved directly and delivered to the downstream module as the final screenshot; if the first candidate screenshot fails the check, the second candidate screenshot is saved and used as the final output.
[0103] While outputting the screenshot, the module also simultaneously returns the coordinates of the corresponding window boundaries, allowing subsequent OCR, local focus cropping, and chat structure recognition modules to reuse the same set of interface coordinates. This method of outputting both the image and boundaries transforms the screenshot module from a simple file saver into a stable input provider for the downstream recognition process.
[0104] The desktop chat window capture method of this invention has the following beneficial technical effects:
[0105] 1. Prioritize retaining low-interference screenshot paths to improve user experience.
[0106] Prioritize capturing the target chat window at the first-channel level, attempting to obtain an image of the window without bringing it to the foreground or interrupting the user's current desktop operations. When the first channel capture is successful, there's no need to forcibly seize foreground focus, effectively reducing interference with the user's normal work and significantly improving the usability and user acceptance of desktop tools.
[0107] 2. Automatically identify invalid images in the cropping layer to block the spread of errors at the source.
[0108] A dual validity discrimination mechanism is introduced in the cropping layer: size consistency discrimination is used to detect whether the cropping has size abnormalities, and image color dispersion discrimination is used to detect whether the cropping is a fake image that is close to a solid color or blank. This can intercept images with abnormal size and images that are close to blank at the front end, preventing invalid images from flowing into the downstream OCR and model recognition stages, and fundamentally reducing the chain recognition errors caused by cropping distortion.
[0109] Third, it has automatic rollback and recovery capabilities, enhancing system robustness.
[0110] When the first-channel window-level screenshot is deemed invalid, the system automatically switches to the second-channel area capture without requiring manual intervention or retry. The second channel activates the target window to the foreground and performs area capture by boundary, ensuring stable acquisition of the true interface content even when the first channel is limited by window rendering mechanisms. This allows for successful screenshotting in various abnormal scenarios, significantly improving the overall stability of the screenshot module.
[0111] IV. Provide high-quality input for subsequent recognition processes and improve overall recognition accuracy.
[0112] By moving screenshot quality control forward to the image acquisition layer, we ensure that the final output screenshot has the correct size and accurate interface content. High-quality raw image input provides a reliable foundation for subsequent modules such as OCR text recognition, chat structure analysis, and extraction of the latest user questions, effectively reducing recognition failures caused by screenshot quality issues, thereby improving the recognition accuracy and processing stability of the entire chat assistance system.
[0113] 5. Synchronously output window boundary coordinate information to facilitate reuse by downstream modules.
[0114] While outputting the final screenshot, the system also simultaneously outputs the coordinates of the corresponding window boundary. Downstream modules such as OCR region focusing, local cropping, and chat structure recognition can continue processing within the same coordinate system without repeatedly obtaining window positions or recalculating boundaries, thereby improving the efficiency of the overall processing workflow and the inter-module collaboration.
[0115] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0116] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for capturing a desktop chat window, characterized in that, The method includes: Step S1: Obtain the boundary information of the target chat window and calculate the expected screenshot size based on the boundary information; Step S2: Without switching the target chat window to the foreground, perform a first-channel window-level screenshot based on the handle of the target chat window to obtain the first candidate screenshot; Step S3: Perform validity determination on the first candidate screenshot, including size consistency judgment and image color dispersion judgment; Step S4: When the first candidate screenshot is determined to be invalid, the target chat window is activated to the foreground, and the second channel area is captured based on the boundary information to obtain the second candidate screenshot. The first or second candidate screenshot is then selected as the final output screenshot.
2. The desktop chat window capture method according to claim 1, characterized in that, In step S1, the expected screenshot size is calculated as follows: Based on the operating system handle of the target chat window, read the coordinates of the left, top, right, and bottom boundaries of the target chat window in the screen coordinate system; Calculate the expected screenshot width based on the difference between the left and right boundaries, and calculate the expected screenshot height based on the difference between the top and bottom boundaries; If the calculated expected screenshot width or height is less than or equal to zero, the window size is deemed invalid and the subsequent screenshot process is terminated.
3. The desktop chat window capture method according to claim 1, characterized in that, In step S2, the first candidate screenshot is implemented as follows: based on the operating system handle of the target chat window, the window drawing content capture interface provided by the operating system is called. Without changing the current desktop window focus state, without switching the target window to the foreground, and without interrupting the user's current desktop operation, the current drawing image content of the target window is directly obtained as the first candidate screenshot.
4. The desktop chat window capture method according to claim 1, characterized in that, In step S3, the size consistency of the first candidate screenshot is determined as follows: Read the actual width and actual height of the first candidate screenshot, compare the actual width with the expected screenshot width, and compare the actual height with the expected screenshot height; When the difference between the actual width and the expected screenshot width exceeds the preset size tolerance range, or the difference between the actual height and the expected screenshot height exceeds the preset size tolerance range, the first candidate screenshot is determined to be invalid in terms of size. The preset size tolerance range is used to adapt to minor size deviations caused by window borders, system shadows, or display scaling.
5. The desktop chat window capture method according to claim 4, characterized in that, In step S3, the preset size tolerance range is specifically set to no more than 2 pixels. When the deviation between the actual width and the expected width of the first candidate screenshot is greater than 2 pixels, or the deviation between the actual height and the expected height of the screenshot is greater than 2 pixels, the size consistency judgment fails.
6. The desktop chat window capture method according to claim 1, characterized in that, In step S3, the image color dispersion is determined for the first candidate screenshot in the following manner: Convert the first candidate screenshot to RGB color space representation, and calculate the minimum and maximum values of all pixel values in the red, green and blue channels respectively; Calculate the difference between the maximum and minimum values of each channel to obtain the color range value of each channel; When the color range values of the red, green, and blue channels are all lower than the preset color dispersion threshold, the first candidate screenshot is determined to be invalid in the image content dimension.
7. The desktop chat window capture method according to claim 6, characterized in that, In step S3, the preset color dispersion threshold is specifically set to no more than 8. When the difference between the maximum and minimum values of the red channel, the green channel, and the blue channel is all less than or equal to 8, the image color dispersion judgment fails and the first candidate screenshot is considered invalid.
8. The desktop chat window capture method according to claim 1, characterized in that, In step S3, size consistency judgment is performed first. If the size consistency judgment is passed, the image color dispersion judgment is performed. Only when both the size consistency judgment and the image color dispersion judgment are passed is the first candidate screenshot deemed valid and directly used as the final output screenshot. If the size consistency check fails, the first candidate screenshot is deemed invalid.
9. The desktop chat window capture method according to claim 1, characterized in that, In step S4, the specific implementation method of the second candidate screenshot is as follows: Call the operating system window management interface to set the target chat window as the foreground active window. After the window switching is completed, wait for a preset window content refresh stability delay. After the delay ends, based on the target chat window boundary information obtained in step S1, the rectangular area for capturing images on the screen is determined, and the area capture operation is performed to capture the screen image within the rectangular area as the second candidate screenshot.
10. The desktop chat window capture method according to claim 1, characterized in that, In step S4, after selecting the final output screenshot, the boundary information is also output in the following way: the final output screenshot is saved to the specified screenshot directory, and the window boundary coordinate information corresponding to the final output screenshot is output to the downstream module in the form of structured data for reuse in the same coordinate system.