Differentiated text typing method based on MATLAB
Through MATLAB programming and Java interface, pixel-level precise positioning and adaptive scaling methods are used to solve the problems of insufficient text typing and insufficient mouse coordinates in the existing technology, and achieve efficient differentiated text input and precise mouse control. , suitable for scenarios that require local differentiated operations.
Patent Information
- Application Number
- CN202210703571.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-06-21
AI Technical Summary
The existing technology cannot realize the rapid typing of a large amount of differentiated text, and the mouse coordinate positioning is not accurate enough, making it unsuitable for scenarios that require text input, especially in loop scenarios that require local differentiated operations.
Through MATLAB programming, the method of pixel-level precise positioning and adaptive scaling is used to obtain screen information. Combined with the Java interface and system input method, it realizes differentiated automatic control of the mouse, avoids coordinate drift, and realizes batch typing and differentiated text input.
It achieves more precise mouse positioning and faster text typing functions, avoids repeated copy and paste operations, improves the accuracy and efficiency of operations, and is suitable for scenarios that require local differentiated operations.
Smart Images

Figure CN115047982B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of mouse positioning and text typing, and in particular to a differentiated text typing method based on MATLAB. Background Art
[0002] Keyboard and mouse simulation software is very common in the market. Its main function is to replace manual use of the mouse and keyboard with recorded script content to perform repetitive programmed operations, such as data migration, file renaming, and repeated clicks.
[0003] However, common technologies currently have a common problem, that is, they cannot realize fast typing of a large amount of differentiated text. None of the common solutions currently available solves the problem of fast text typing and is not suitable for scenarios where text input is required.
[0004] To solve this problem, we need to first identify some of its derivative problems, such as: typing text is cumbersome and requires repeated copying and pasting; mouse coordinate positioning is not accurate enough, and common positioning methods will cause certain coordinate drift depending on the size of the computer monitor and the system zoom ratio. Common recording software can only record actions but cannot display the mouse position coordinates, or can only locate the coordinates to single-digit accuracy; it is difficult to achieve differentiated repetitive operations, and the current common control scheme is only suitable for use scenarios with extremely high repetitiveness, and cannot be applied to application scenarios where local differentiation occurs in the cycle. Summary of the invention
[0005] Purpose of the invention: In view of the problems existing in the prior art, the present invention provides a differentiated text typing method based on MATLAB, which has a more convenient differentiated repeated operation logic, a more accurate mouse positioning method, and a faster text typing function.
[0006] Technical solution: The present invention provides a differentiated text input method based on MATLAB, which realizes differentiated automatic control of keyboard and mouse through simple programming of m files in MATLAB and function writing and combined calling, and mainly includes the following steps:
[0007] Step 1: Position the mouse accurately at the pixel level to obtain the current position matrix information, and place the auxiliary text at the correct preset position; restore the screen information in proportion by drawing the pixel coordinate matrix and the RGB color matrix, and return the current position matrix by clicking the mouse;
[0008] Step 2: According to the number of texts to be processed and the number of operation objects, set the specific number of automatic operation cycles. In each cycle operation, one of the objects can be processed and the differentiated local information can be automatically entered.
[0009] Step 3: In each operation, batch type / modify text and images at the positioned position and execute preset actions to achieve practical functions with different positioning and typing positions, different typing texts, and different preset operations.
[0010] Furthermore, in step 1, the mouse is precisely positioned using pixel positioning, which is specifically divided into the following steps:
[0011] First, use the window acquisition function in the Java interface and the GetScreenSize method to obtain the total number of pixels and the corresponding RGB color matrix information of the current display;
[0012] Then, the obtained resolution horizontal and vertical coordinates, pixel distribution and RGB color matrix are respectively transferred to the preset window layer to reset the image size;
[0013] Use the drawing function Figure to draw the set image window, and finally use the Ginput function to return the coordinate matrix of the mouse in the Figure window by clicking the mouse on the Figure window.
[0014] Furthermore, when the mouse is precisely positioned, the image needs to be adaptively filled in the window and the current display content is displayed in the window to facilitate the user to position by clicking.
[0015] Furthermore, while obtaining the information on the number of pixels in the window, the RGB chromaticity value matrix of all current pixels is saved and passed into the Figure. When drawing, the pixel arrangement and the RGB chromaticity values corresponding to each point are drawn at the same time to obtain a proportionally scaled current display image. The mouse positioning can be achieved by clicking on a specific part of the image and returning the coordinate position matrix.
[0016] Furthermore, in step 2, a specific number of automatic operation cycles is set according to the number of files that actually need to be operated, so as to realize automatic operation on each file. The set number of cycles should be greater than or equal to the number of files that need to be operated.
[0017] Furthermore, in step 2, a Switch / If conditional judgment statement is added to the part where the difference needs to be realized. After setting, the functions of clicking buttons at different positions and inputting different contents are realized in each cycle.
[0018] Furthermore, the specific method of batch typing text in the located position in step 3 is:
[0019] First, call the system input method clipboard function, use the Clipboard-Copy method to write the preset text to be typed and save it;
[0020] Then use the simulated keyboard hot key combination to type the text in the clipboard into the specified location.
[0021] Beneficial effects:
[0022] The present invention uses the method of the system's own input method pasteboard to avoid the tedious operations caused by repeated copying and pasting, realizes local differentiated repetitive operations, uses the pixel positioning method, based on pixel positioning and adaptive scaling, so the positioning accuracy is higher than the traditional method, and also eliminates the occurrence of coordinate offset phenomenon in principle. Compared with the traditional text input method, the present invention can not only perform direct input, but also realize differentiated text input. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is an operation flow chart of the differentiated text input method based on MATLAB of the present invention;
[0024] Figure 2 These are some pictures that need to be renamed in the embodiment of the present invention;
[0025] Figure 3 These are some pictures after being renamed in the embodiment of the present invention;
[0026] Figure 4 To uniformly adjust the image size in the embodiment of the present invention;
[0027] Figure 5 For an embodiment of the present invention, type text at a specified location in the picture;
[0028] Figure 6 It is a schematic cross-sectional diagram of the software operation of the present invention. DETAILED DESCRIPTION
[0029] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0030] The present invention discloses a differentiated text typing method based on MATLAB, which realizes differentiated automatic control of keyboard and mouse through simple programming of m files in MATLAB and function writing and combined calling, and can assist scientific researchers in cross-platform data batch processing or image annotation, text typing and other tasks. It includes the following steps:
[0031] Step 1: Position the mouse accurately at the pixel level to obtain the current position matrix information, which can assist the text to be placed in the correct preset position. The screen information is restored in proportion by drawing the pixel coordinate matrix and the RGB chromaticity matrix, eliminating the coordinate drift phenomenon, and returning the current position matrix by clicking the mouse. Traditional positioning methods mostly use function positioning to directly obtain the position of the mouse on the screen, generate integer coordinates and return the function value. However, due to the different display resolution and system preset magnification, different degrees of offset will occur. The present invention uses a pixel positioning method, which is specifically divided into three steps: first, use the window acquisition function in the Java interface, and use the GetScreenSize method to obtain all the pixel distribution information of the current display and the RGB chromaticity matrix composed of each point. Then, the obtained resolution horizontal and vertical coordinates, pixel distribution, and RGB chromaticity matrix are respectively transferred to the preset window layer to reset the image size. Use the drawing function Figure to draw the set image window, and finally use the Ginput function to return the coordinates of the mouse in the Figure window by clicking the Figure window with the mouse. However, for ease of use, it is also necessary to adaptively fill the window with the image and display the current display content in the window for user clicks. The specific optimization method is to save the RGB color values of all current pixels while obtaining the number of pixels in the window, and pass them into the Figure. When drawing, the image size and the color value of each point can be drawn at the same time. After the above optimization, a proportionally scaled image of the current display can be obtained, and the mouse positioning can be achieved by clicking on a specific part of the image.
[0032] The entire implementation process is based on pixel positioning and adaptive scaling, so the positioning accuracy is higher than traditional methods, and the occurrence of coordinate offset is also eliminated in principle.
[0033] Step 2: According to the number of texts to be processed and the number of objects to be operated, set the specific number of automatic operation cycles. In each cycle, one of the objects can be processed and the differentiated local information can be automatically entered. It is worth noting that the number of operation cycles should be set to be greater than or equal to the number of texts / images to be processed to ensure that each sample can be modified.
[0034] Traditional control methods mostly use recorded script files for operation, which are highly repetitive, but cannot achieve differentiated behavior in a single loop operation. To solve this problem, this method can set the specific number of loops of the For loop according to the number of files that actually need to be operated, so that each file can be automatically operated. In order to achieve localized differential operation, Switch / If conditional judgment statements can be added to the part where the difference needs to be achieved. For example, if different text needs to be typed into the picture in each loop operation, the number of loops can be set as the judgment condition in the Switch statement. When the i-th loop is reached, the preset annotation information is typed into the i-th picture. If some special cases need to be introduced in the loop operation, the If statement can be used as a differentiation mark. For example, in data annotation, some samples do not need to be annotated as a verification set. The mouse click position can be set as a judgment condition in the If statement. When the mouse clicks on the verification set sample, the annotation operation is skipped and the next For loop is directly entered to perform the annotation operation on the normal sample.
[0035] Step 3: In each operation, type / modify text and images in batches at the positioned position and execute the preset action. In addition, in each operation, you can achieve practical functions such as different positioning and typing positions, different typing texts, and different preset operations. The specific method is:
[0036] First, call the input method clipboard and use the Clipboard-Copy method to write the preset text to be typed; then use the simulated keyboard combination hotkey method to type the text in the clipboard into the specified location.
[0037] In order to explain the method proposed in this invention in more detail, an application scenario will be assumed below, and the use process of this method will be introduced in this scenario.
[0038] When processing images, researchers will encounter scenarios where they need to process a large number of training set images. They need to adjust the size ratio of each image to the ratio required by the training model, and rename each image to facilitate the model to read the image content. Assuming there are 100 images in total, the following is the specific process for implementing the operation:
[0039] 1. Position the mouse coordinates to the first picture in the folder, and right-click the mouse - Rename option.
[0040] 2. Enter the name of the picture, such as "Picture 1", to complete the renaming operation. Since there are a total of 100 pictures to be operated, the For statement is set as needed, and its judgment condition is set to 1:100 integers, and the operation is looped 100 times in total. After each picture is completely operated, the loop operation judgment number increases by 1, so that the subsequent picture names can be increased with the number of loops and named "Picture 2", "Picture 3"... and so on.
[0041] 3. Double-click the mouse to open the picture, and enter the length and width to adjust the image to the specified size.
[0042] 4. Save and close the image
[0043] 5. Position the mouse to the second picture and calculate the difference in the mouse coordinates. Set up a For loop as needed to allow the offset to accumulate with the number of loops. In each operation, the mouse positioning matrix increases the difference, so that the next picture can be positioned in each loop operation.
[0044] 6. Set the end condition of the loop operation. Generally, this item can be set to when the difference accumulates to a certain upper limit, or when the maximum number of loop operations is reached. For example, in this case, it can be set to end all operations after reaching 100 loops.
[0045] 7. Finished.
[0046] According to the above operation process, the effect that can be achieved is: the mouse clicks on pictures in different positions in turn according to the number of cycles, and automatically types "Picture 1", "Picture 2", "Picture 3"... to rename the pictures differently. Then open each picture in turn, and automatically type in the preset data to modify the pictures to the same size.
[0047] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the protection scope of the present invention.
Claims
1. A differentiated text input method based on MATLAB, which realizes differentiated automatic control of keyboard and mouse through simple programming of m files and function writing and combined calling in MATLAB, characterized in that: The main steps are as follows: Step 1: Position the mouse accurately at the pixel level to obtain the current position matrix information, and place the auxiliary text at the correct preset position; restore the screen information in proportion by drawing the pixel coordinate matrix and the RGB color matrix, and return the current position matrix by clicking the mouse; Step 2: According to the number of texts to be processed and the number of operation objects, set the specific number of automatic operation cycles. In each cycle operation, one of the objects can be processed and the differentiated local information can be automatically entered. Step 3: In each operation, batch type / modify text and images at the positioned position and execute preset actions to achieve practical functions with different positioning and typing positions, different typing texts, and different preset operations.
2. The differentiated text input method based on MATLAB according to claim 1, characterized in that: In step 1, the mouse is precisely positioned using pixel positioning, which is specifically divided into the following steps: First, use the window acquisition function in the Java interface and the GetScreenSize method to obtain the total number of pixels and the corresponding RGB color matrix information of the current display; Then, the obtained resolution horizontal and vertical coordinates, pixel distribution and RGB color matrix are respectively transferred to the preset window layer to reset the image size; Use the drawing function Figure to draw the set image window, and finally use the Ginput function to return the coordinate matrix of the mouse in the Figure window by clicking the mouse on the Figure window.
3. The differentiated text input method based on MATLAB according to claim 2, characterized in that: When the mouse is precisely positioned, the image also needs to adaptively fill the window and display the current display content in the window to facilitate the user to position by clicking.
4. The differentiated text input method based on MATLAB according to claim 2, characterized in that: While obtaining the information on the number of pixels in the window, the RGB chromaticity value matrix of all current pixels is saved and passed into the Figure. When drawing, the pixel arrangement and the RGB chromaticity value corresponding to each point are drawn at the same time to obtain a proportionally scaled image of the current display. The mouse positioning can be achieved by clicking on a specific part of the image and returning the coordinate position matrix.
5. The differentiated text input method based on MATLAB according to claim 1, characterized in that: In step 2, a specific number of automatic operation cycles is set according to the number of files that actually need to be operated, so as to realize automatic operation on each file. The set number of cycles should be greater than or equal to the number of files that need to be operated.
6. The MATLAB-based differentiated text input method according to claim 5, characterized in that: In step 2, a Switch / If conditional judgment statement is added to the part where the difference needs to be realized. After setting, the functions of clicking buttons at different positions and inputting different contents are realized in each cycle.
7. The MATLAB-based differentiated text input method according to claim 1, characterized in that: The specific method of batch typing text in the located position in step 3 is: First, call the system input method clipboard function, use the Clipboard-Copy method to write the preset text to be typed and save it; Then use the simulated keyboard hot key combination to type the text in the clipboard into the specified location.
Citation Information
Patent Citations
Virtual keyboard of a mobile terminal
CN101889256A
Method for extracting quick response matrix code region in image
CN102831428A
Method of accurately locating displacement of optical mouse
CN103105943A
Human shape posture detection method and device, computer equipment and storage medium
CN111507134A
RPA robot intelligent element positioning and picking method and system
CN112101357A
