[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN106155886B - A kind of method and apparatus of key mouse script processing - Google Patents

A kind of method and apparatus of key mouse script processing Download PDF

Info

Publication number
CN106155886B
CN106155886B CN201510150010.8A CN201510150010A CN106155886B CN 106155886 B CN106155886 B CN 106155886B CN 201510150010 A CN201510150010 A CN 201510150010A CN 106155886 B CN106155886 B CN 106155886B
Authority
CN
China
Prior art keywords
event
keyboard
mouse
events
script
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201510150010.8A
Other languages
Chinese (zh)
Other versions
CN106155886A (en
Inventor
葛山
于晓峰
王雪
田杰
陈佃晓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201510150010.8A priority Critical patent/CN106155886B/en
Publication of CN106155886A publication Critical patent/CN106155886A/en
Application granted granted Critical
Publication of CN106155886B publication Critical patent/CN106155886B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • User Interface Of Digital Computer (AREA)
  • Input From Keyboards Or The Like (AREA)
  • Position Input By Displaying (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a kind of method and apparatus of key mouse script processing, are related to Internet technical field, redundancy event can be removed, the necessary event that supplement lacks, so that key mouse script be made to be advanced optimized.Method of the invention, comprising: obtain pending key mouse script;It detects with the presence or absence of redundancy event in the key mouse script, the redundancy event is the event not having an impact to the playback state of the key mouse script;If the redundancy event is deleted there are the redundancy event in the key mouse script;It detects and whether lacks necessary event in the key mouse script, necessity event is the event that should be recorded in the key mouse script;If lacking the necessary event in the key mouse script, the necessary event is added;Save treated key mouse script.During the present invention is suitable for key mouse script recording under Windows environment and plays back.

Description

Keyboard and mouse script processing method and device
Technical Field
The invention relates to the technical field of internet, in particular to a keyboard and mouse script processing method and device.
Background
The keyboard and the mouse are input devices of the user device, and when a user plays a game or performs window operations such as editing a document, it is often necessary to repeatedly perform a certain operation process, for example, repeatedly click a left button of the mouse, or repeatedly click different direction keys in the keyboard in a certain sequence. In order to simplify the repetitive operations of the user, the prior art proposes a way of simulating the user's operation of the keyboard and mouse. In this way, the user equipment can record the keyboard and mouse operation of the user when the user executes the keyboard and mouse operation for the first time, obtain the keyboard and mouse script, and play back the keyboard and mouse script in the subsequent process, so as to realize the automatic execution of the same operation.
In the prior art, scripts are recorded in units of events, and besides mouse movement and mouse wheel scrolling, operations of any key on a keyboard or a mouse include two actions of pressing and releasing. When the script is recorded, the user equipment records an action as an event, and correspondingly, one operation on a certain key comprises two events of pressing and releasing. Therefore, the events involved in the keyboard include a press event and a release event for each key; the events related to the mouse comprise a left button, a right button, a pressing event and a releasing event of the mouse wheel, a rolling event of the mouse wheel and a mouse moving event. During the process of recording the keyboard and mouse script, the user often triggers some operations that do not affect the game state, for example, the user moves the mouse at will without clicking any key on the keyboard or mouse. Such a simple mouse movement does not result in a change in the game state and is therefore generally meaningless. Although the above operation has no influence on the game state, the computer records the operation in the form of an event in the keyboard and mouse script, thereby increasing the data amount of the keyboard and mouse script and complicating the playback of the keyboard and mouse script. In practice, such events are often referred to as redundant events. In addition, due to the defects of the Windows system mechanism, in the process of recording the mouse script, an event loss phenomenon often occurs, for example, a user clicks a left mouse button, but only records the left mouse button pressing event but loses the left mouse button releasing event. Therefore, when the release event is lost, the simulated operation is continuously in a pressed state due to lack of the release event after the playback of the keyboard and mouse script is finished, so that the target window or other Windows are jammed, the user cannot open, close, drag and the like the target window or other Windows, and further Windows are abnormal.
Disclosure of Invention
In view of this, the method and the device for processing the keyboard and mouse script provided by the invention can remove redundant events and supplement missing necessary events, thereby further optimizing the keyboard and mouse script.
According to one aspect of the present invention, a method for keyboard and mouse script processing is provided, the method comprising:
acquiring a keyboard and mouse script to be executed;
detecting whether a redundant event exists in the keyboard and mouse script, wherein the redundant event is an event which does not influence the playback state of the keyboard and mouse script;
if the redundant event exists in the keyboard and mouse script, deleting the redundant event;
detecting whether an essential event is absent in the keyboard and mouse script, wherein the essential event is an event which should be recorded in the keyboard and mouse script;
adding the necessary event if the necessary event is absent from the keyboard and mouse script;
and (5) storing the treated kangaroo script.
According to another aspect of the present invention, there is also provided an apparatus for keyboard and mouse script processing, the apparatus comprising:
the acquisition unit is used for acquiring a keyboard and mouse script to be executed;
the detection unit is used for detecting whether a redundant event exists in the keyboard and mouse script acquired by the acquisition unit, wherein the redundant event is an event which does not influence the playback state of the keyboard and mouse script;
the deleting unit is used for deleting the redundant events when the detecting unit detects that the redundant events exist in the keyboard and mouse script;
the detecting unit is further used for detecting whether an essential event is absent in the keyboard and mouse script, wherein the essential event is an event which should be recorded in the keyboard and mouse script;
an adding unit configured to add the necessary event when the detecting unit detects that the necessary event is absent from the keyboard and mouse script;
and the storage unit is used for storing the processed keyboard and mouse script.
By means of the technical scheme, the method and the device for processing the keyboard and mouse script can detect whether redundant events exist in the keyboard and mouse script and whether necessary events are lacked or not after the keyboard and mouse script to be executed is obtained, when the redundant events exist, the redundant events are deleted, and when the necessary events are lacked, the necessary events are added, so that the processed keyboard and mouse script is obtained. Compared with the keyboard and mouse script which is directly recorded in the prior art, the method and the device can not only reduce the data volume of the keyboard and mouse script, but also avoid the Windows abnormal phenomenon caused by the lack of necessary events.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 shows a flow diagram of a method of mousetrap script processing;
FIG. 2 shows a flow diagram of another method of mousetrap script processing;
FIG. 3 shows a block diagram of the components of a keyboard and mouse script processing apparatus;
fig. 4 shows a block diagram of another apparatus for keyboard and mouse script processing.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
The embodiment of the invention provides a method for treating a keyboard and mouse script, which comprises the following steps of:
101. and acquiring a keyboard and mouse script to be executed.
The keyboard and mouse script records each operation of a user on a keyboard or a mouse in the form of events in sequence, and records the time interval between adjacent events to form an aggregate in which the events and the time interval are stored.
Illustratively, a key mouse script records a key A pressing event, 100ms, a key A releasing event, 5s, a key B pressing event, 80ms, a key B releasing event, 8s, a mouse moving event, 50ms, a mouse moving event, 1s, a left mouse button pressing event, 90ms, a left mouse button releasing event, 8s and a key return pressing event in sequence, which indicates that a user firstly operates the key A in the whole operation process, operates the key B after 5s, moves the mouse after 8s, operates the left mouse button after 1s, and operates the key return after 8 s. The above-mentioned time values represent time intervals between adjacent events, and the values involved in this step and the following schemes are only examples and are not specific limitations for practical applications.
It should be noted that each event recorded in the keyboard and mouse script is stored in the terminal in the form of a string of bytes, that is, each event occupies one or more storage spaces of consecutive bytes. The information carried by each string of bytes includes: event type, coordinates of the operational focus. Wherein the event types include: a keyboard key press event, a keyboard key release event, a mouse movement event, a mouse wheel scroll event, a mouse key press event, and a mouse key release event. For example, if an event is a key a press event, the event type of the event is a key a press event of a keyboard key, the coordinate of the operation focus is (400, 500), and it is known that the user presses the key a at the terminal coordinate of (400, 500).
102. And detecting whether redundant events exist in the keyboard and mouse script.
Since the events in the keyboard and mouse script are recorded according to the time sequence, when the keyboard and mouse script is detected, the events in the keyboard and mouse script need to be detected according to the sequence, and whether redundant events exist in the keyboard and mouse script is detected. The redundant events are events which do not affect the playback state of the keyboard and mouse script, and the playback state refers to the running state of a game and the like in the process of playing back the keyboard and mouse script. For example, during the process of recording the operation of a game keyboard and a mouse, a user moves the mouse at will without clicking the mouse or the keyboard, and the running state of the game is not changed. For another example, the game provides that the user can perform operations of up, down, left and right only by using the direction keys on the keyboard to complete the task in the game, and in the recording of the game keyboard and mouse, the user performs operations on other keys, such as the key a, the key B, the key Shift, and the like, and the operations on the other keys do not change the running state of the game. Although the above operations do not affect the playback state, the operations are recorded in the form of events during the recording process of the keyboard and mouse script, and the operations are repeated once during the playback process of the keyboard and mouse script, so that the events which do not affect the playback state of the keyboard and mouse script are called as redundant events.
103. And if the keyboard and mouse script has redundant events, deleting the redundant events.
Because the redundant event has no influence on the running state of the game and the like, when the terminal detects that the redundant event exists in the keyboard and mouse script, the redundant event can be deleted to reduce the data volume of the keyboard and mouse script, and meanwhile, because the deleted redundant event does not influence the playback state, the deletion of the redundant event does not change the playback result of the keyboard and mouse script.
In addition, because the terminal detects each event in the keyboard and mouse script in sequence, after the terminal deletes the currently detected redundant event, the terminal continues to detect the events after the redundant event one by one according to the sequence of the events.
104. Detecting whether the keyboard and mouse script lacks necessary events.
The necessary events are events that should be recorded in the keyboard and mouse script, and include a press event, a release event, a mouse movement event, and the like that affect the playback state. In this step, when the terminal detects whether there is a lack of a necessary event in the keyboard and mouse script, the terminal may detect whether each pressing event of the keyboard and mouse script is finally released, i.e., whether there is a corresponding release event. The reason is that when the keyboard and mouse script lacks a release event, after the playback of the keyboard and mouse script is finished, the simulated operation is continuously in a pressed state due to the lack of the release event, so that a target window or other Windows are blocked, and the Windows abnormity occurs.
105. If the requisite event is absent from the keyboard and mouse script, the requisite event is added.
When the necessary events are absent in the keyboard and mouse script, the playback of the keyboard and mouse script is affected, and even the normal operation of a Windows system is affected, so that the absent necessary events need to be added in the keyboard and mouse script. For example, a keystroke T pressing event is recorded in the keystroke script, but a keystroke T release event is not detected after the event, which indicates that the necessary event keystroke T release event is absent in the keystroke script. Therefore, a key T release event needs to be added after the key T presses the event, so as to ensure normal playback of the keyboard and mouse script and normal operation of the Windows system.
The above steps include detection and processing of a terminal for missing essential events in the keyboard and mouse script, and detection and processing of redundant events in the keyboard and mouse script. However, the operation sequence of the two cases is not limited by the embodiment of the present invention. After the terminal acquires the keyboard and mouse script to be executed, the existence of redundant events can be detected for the whole keyboard and mouse script, all the redundant events are deleted, the missing of necessary events is detected for the keyboard and mouse script after the redundant events are deleted, and the adding processing is carried out when the missing is detected; or detecting whether the whole keyboard and mouse script has the loss of the necessary event or not, adding the missing necessary event, detecting whether the redundant event exists or not by the terminal for the keyboard and mouse script after the missing necessary event is added, and deleting the redundant event when the redundant event exists.
106. And (5) storing the treated kangaroo script.
After the steps of detecting and processing the redundant events and detecting and processing the missing of the necessary events for the obtained keyboard and mouse script to be executed, the terminal stores the processed keyboard and mouse script so as to execute the keyboard and mouse script in the subsequent playback.
The method for processing the keyboard and mouse script provided by the embodiment of the invention can detect whether redundant events exist in the keyboard and mouse script and whether necessary events are lacked or not after the keyboard and mouse script to be executed is obtained, delete the redundant events when the redundant events exist, and add the necessary events when the necessary events are lacked, thereby obtaining the processed keyboard and mouse script. Compared with the keyboard and mouse script which is directly recorded in the prior art, the method and the device can not only reduce the data volume of the keyboard and mouse script, but also avoid the Windows abnormal phenomenon caused by the lack of necessary events.
Further, as an extension and refinement of the above embodiment, an embodiment of the present invention further provides another method for processing a mouse script, as shown in fig. 2, the method includes:
201. and acquiring a keyboard and mouse script to be executed.
202. And judging whether an event set matched with a preset optimization condition exists in the keyboard and mouse script.
The preset optimization condition is a strategy which is preset by the terminal and used for judging whether the preset optimization condition is a redundant event. By judging whether an event set matched with the preset optimization condition exists in the keyboard and mouse script or not, the event set matched with the preset optimization condition can be obtained, so that the event in the event set is determined to be a redundant event, the redundant event is deleted, and the data volume of the keyboard and mouse script is reduced.
And judging the events or event sets under different conditions so as to process the redundant events in the keyboard and mouse script:
in the first case: whether a plurality of continuous mouse moving events exist in the keyboard and mouse script is detected. And if a plurality of continuous mouse moving events exist in the keyboard and mouse script, determining that the plurality of continuous mouse moving events are matched with the preset optimization conditions.
In practical applications, when a user is playing a game and recording a mouse, the user often moves the mouse for a non-operation purpose without performing additional operations (e.g., pressing the left button of the mouse to move the mouse, pressing the button on the keyboard to move the mouse, etc.), such as accidentally touching the mouse, or simply moving the mouse due to personal habits. For such an operation of only performing mouse movement, only the coordinates of the operation focus of the mouse are changed, and the state of the game is not affected, so that the events of mouse movement can be classified as redundant events, and therefore, the preset optimization condition includes a plurality of continuous mouse movement events. Therefore, when the terminal detects that a plurality of continuous mouse movement events exist in the keyboard and mouse script, the plurality of continuous mouse movement events are determined to be matched with the preset optimization conditions.
It should be noted that, for the mouse movement operation, although it appears to the user as a continuous movement process, for the terminal, a mouse movement process is an approximately continuous movement operation composed of hundreds of discrete points. Therefore, when the keyboard and mouse script is recorded, the terminal can record hundreds of events (each event records the event type of mouse movement and the coordinate information of a corresponding discrete point), so that the mouse movement operation occupies a large amount of keyboard and mouse script data, if the mouse movement is judged while other operations (such as pressing the left mouse button to move the mouse, pressing the key on the keyboard to move the mouse, and the like) are not added, and the mouse movement is only carried out independently, the terminal deletes a plurality of continuous mouse movement events corresponding to the mouse movement operation, and the data amount of the keyboard and mouse script can be reduced on the premise of not influencing the playback state of the keyboard and mouse script.
For example, if the events in the keyboard and mouse script are a key Q press event, a key Q release event, a mouse movement event, a key enter press event, and a key enter release event in sequence, the terminal may detect that there are 3 consecutive mouse movement events in the keyboard and mouse script. Therefore, the terminal can determine that the continuous 3 mouse movement events are matched with the preset optimization condition, so that the 3 mouse movement events are determined as redundant events and are deleted.
Further, when all of the plurality of consecutive mouse movement events in the keyboard and mouse script are deleted, during the playback of the keyboard and mouse script, the operation focus instantaneously shifts from one point to another point far away, and there is no focus track of the user in the process of recording the mouse slowly moving. However, the user often performs a mouse movement to change the coordinates of the operation focus, so as to further click a key on the mouse or the keyboard, thereby changing the game state. Therefore, in order to keep the normal mouse moving operation of the user, it is necessary to improve the first situation to prevent the normal mouse moving operation from being deleted by mistake while "rejecting" the useless mouse moving operation, specifically, the improvement scheme is as follows:
it is detected whether a time interval after a last event of a plurality of consecutive mouse movement events is greater than a first preset time threshold. And if the time interval after the last event in the plurality of continuous mouse movement events is greater than a first preset time threshold, determining that the plurality of continuous mouse movement events are matched with a preset optimization condition.
The first preset time threshold may be a maximum time threshold of application operations of background statistics.
In practical application, when a user moves a mouse unintentionally or moves the mouse randomly, the purpose and the intention of the next operation are not always available, and the time interval between the last mouse movement event and the next operation event is far larger than the time interval between normal operation events, so that useless mouse movement operation and normal mouse movement operation can be distinguished through the characteristic. For example, since the user does not perform a mouse click operation or a key operation on the keyboard immediately after triggering a mouse movement operation, which indicates that the user does not perform a mouse movement operation for performing a next click, the mouse movement events recorded in the mouse script due to the user's unintended movement of the mouse may be classified as redundant events. Therefore, the preset optimization condition includes a case where no other type of event occurs for a long time after a plurality of consecutive mouse movement events. Therefore, when the terminal detects that the time interval after the last event in the plurality of continuous mouse movement events is greater than the first preset time threshold, it can be determined that the plurality of continuous mouse movement events are matched with the preset optimization condition, and the plurality of continuous mouse movement events are classified as redundant events, so that the redundant events are deleted, and the data volume of the keyboard and mouse script is reduced.
Illustratively, the events and the event intervals in the keyboard and mouse script are, in order, a key C press event, 100ms, a key C release event, 5s, a mouse movement event, 50ms, a mouse movement event, 5min, a keyboard key right key press event, 40ms, a keyboard key right key press event, 90ms, and a keyboard key right key release event. If the first preset time threshold is 4min, the terminal can detect that the time interval after the fourth mouse movement event in 4 continuous mouse movement events is larger than 4min, so that the 4 continuous mouse movement events can be determined to be matched with the preset optimization conditions and determined as redundant events, and the redundant events are deleted, so that the keyboard and mouse script is further optimized.
Furthermore, during the process of recording the mouse script, the user often presses the keyboard carelessly to keep the keys on the keyboard in the pressed state, and the pressing of the keys does not cause the problem of changing the playback state. Although the keys are pressed for a long time without changing the playback state, the pressing and releasing operations are recorded in the keyboard and mouse script, and the keyboard and mouse script can repeat the operations in the playback process. Therefore, the events corresponding to these long press operations that do not affect the playback state can be classified as redundant events. As a result, the preset optimization condition includes a case of a long press operation that does not affect the playback state. The specific detection method is as follows in the second case:
in the second case: it is detected whether the sum of the time intervals between adjacent events of a plurality of consecutive identical press-down events is greater than a second preset time threshold. If the sum of the time intervals is greater than a second preset time threshold, determining that a plurality of consecutive same pressing events match a preset optimization condition.
The second preset time threshold may be a maximum time threshold of application operation provided by an application developer, or may be a maximum time threshold of application operation counted by a background.
It should be noted that, similarly to the mouse movement, the long-press operation feels to the user that it is one operation, but actually, the long-press operation records a plurality of consecutive same press events in the terminal. Therefore, when calculating the time length of the long press operation, the time intervals between adjacent events in the plurality of consecutive identical press-down events need to be added to obtain the total time length for generating the plurality of consecutive identical press-down events.
When the time for pressing the key exceeds the maximum time threshold of the application operation provided by the application developer or the maximum time threshold of the application operation counted in the background, it may be determined that the long-press operation is performed abnormally. Therefore, when the terminal detects that the sum of the time intervals between adjacent events in the plurality of continuous same pressing events is greater than the second preset time threshold, it may be determined that the plurality of continuous same pressing events match the preset optimization condition and are classified as redundant events, so that the plurality of continuous same pressing events are deleted to reduce the data volume of the keyboard and mouse script.
Illustratively, there are 1001 continuous key a pressing events in the keyboard and mouse script, and the time interval between adjacent events is 100 ms. When the second preset time threshold is 60s, the sum of the time intervals of the events of pressing 1001 consecutive keys a is 1000 × 100 — 100000ms — 100s, which is greater than 60s, so that the events of pressing 1001 consecutive keys a are the set of events matching the preset optimization condition. Therefore, the 1001 continuous key a pressing events can be classified as redundant events and deleted.
In practical application, the maximum long press time of the key involved in the game design can be used as the second preset time threshold, and the maximum long press time can be provided by a game developer or obtained by background statistics of a game service provider and written into a configuration file (for example, an x.
It should be noted that the long-press key according to the above-mentioned embodiment is based on the fact that the long-press key does not affect the playback state, and therefore, before deleting a plurality of consecutive same pressed events corresponding to the long-press key, it is necessary to determine whether or not the pressed events are events triggered by the key that does not affect the playback state. The pressed event can be deleted only when it is an event triggered by a key that has no effect on the playback status. The specific implementation manner of the event triggered by the key for judging whether the key has no influence on the playback state is the following third case:
in the third case: and detecting whether events triggered by keys except for the preset keys exist in the keyboard and mouse script. And if the key mouse script has the events triggered by the keys except the preset keys, determining that the events triggered by the keys except the preset keys are matched with the preset optimization conditions.
The preset keys can be keys provided by an application developer and used for triggering application operation, and can also be keys used for triggering application operation counted in a background. In practical applications, the preset key information may be written into a configuration file of the terminal in advance.
When a game developer develops a game, the game developer often sets a plurality of fixed keys (including keys on a keyboard or a mouse) to perform editing operation of the game, and other keys do not work. In the process of recording the mouse script of the game key, a user often intentionally or unintentionally presses keys except for some preset keys, and although the operation on the keys does not change the game state, the keys are still recorded in the mouse script, so that events triggered by the keys except for the preset keys can be classified as redundant events. Therefore, the preset optimization condition comprises the condition of triggering events of keys except the preset key.
Specifically, the terminal may mark the preset key for an event triggered by each preset key. When the terminal detects that the current event does not carry the preset key mark, the current event can be determined to be an event triggered by keys except the preset key, and the event can be determined to be matched with the preset optimization condition; when the terminal detects that the current event carries the preset key mark, the terminal can determine that the current event is the event triggered by the preset key, and then continue to detect the next event.
It should be noted that, in the above third scenario, not only the determination of multiple same pressing events in the second scenario but also the determination of any other event in the keyboard and mouse script can be implemented, so that events triggered by all keys other than the preset keys in the keyboard and mouse script are detected and further processed.
Further, when the user records the keyboard and mouse script on the game window, other windows may be operated, however, since the terminal only records the operations triggered by the keyboard or the mouse in the keyboard and mouse recording process, and does not distinguish the windows, the operations of the user on the other windows may also be recorded, and the operations may also be played back in the keyboard and mouse script playback.
For example, during a mouse-and-click script recording of a game, at some point in time, the user clicks on the icon of the chat software and finds a friend called Zhang, sending him a message "go out with weekend to play a bar! ". Therefore, under the condition that the icon position of the chat software is not changed, at the same time in the keyboard and mouse script, the mouse clicks the icon of the chat software as in the recording process, and the same message is sent to Zhang III. This situation often affects the user, and therefore, the events corresponding to these operations on other windows can be classified as redundant events. Therefore, the preset optimization condition includes the condition of operating other windows. The specific implementation manner of judging whether the events corresponding to other windows exist is as the following fourth case:
in a fourth case: and reading the coordinates of the operation focus from the event, and judging whether the coordinates are positioned in the target window. And if the coordinates are not located in the target window, determining that the event corresponding to the coordinates which are not located in the target window is matched with the preset optimization condition.
As described in step 101 above, each event in the keyboard and mouse script carries information about the coordinates of the operation focus point, so the coordinate range of the target window can be obtained first, and then the coordinates of the operation focus point can be read from each event in the keyboard and mouse script. And judging whether the coordinates of the operation focus of the read event are positioned in the target window or not by matching the coordinates of the operation focus of the read event with the coordinate range of the target window. And when the coordinates of the operation focus of the read event are not in the coordinate range of the target window, the terminal determines that the event corresponding to the coordinates which are not in the target window is matched with the preset optimization condition.
203. And if the event set matched with the preset optimization condition exists in the keyboard and mouse script, determining the event in the event set matched with the preset optimization condition as a redundant event, and deleting the redundant event.
Since the preset optimization condition is mentioned as a policy preset by the terminal for determining whether the event is a redundant event in step 202, the event matching the preset optimization condition is a redundant event. When the fact that the event set matched with the preset optimization condition exists in the keyboard and mouse script is detected, the events in the event set matched with the preset optimization condition are determined as redundant events, and all the redundant events are deleted to reduce the data volume of the keyboard and mouse script.
Further, since the time intervals between adjacent events are recorded in the keyboard and mouse script in addition to the recording of each event, a plurality of consecutive time intervals may occur when all redundant events are deleted. And when the terminal executes the keyboard and mouse script, the terminal only pauses according to the duration of the time interval recorded in the keyboard and mouse script, and executes a plurality of continuous time intervals in sequence, wherein the effect of directly executing the time interval with the duration equal to the sum of the durations of all the time intervals is the same, namely the length of the paused time is the same. However, each time interval occupies a certain storage space, so in order to reduce the data amount of the keyboard and mouse script, a plurality of continuous time intervals can be combined into one time interval.
Illustratively, after the redundant event is deleted, there are 10 consecutive time intervals in the keyboard and mouse script, whose values are 100ms, 1s, 100ms, 10s, 50ms, 2s, 40ms, and 60ms, respectively, so that the value obtained by setting the 10 values to 1 value is 13.5 s. If the 10 time intervals respectively occupy the storage space of one byte, the storage space of 10 bytes is occupied totally, however, after the 10 time intervals are integrated into 1 time interval, the occupied storage space is only one byte, so that the data volume of the keyboard and mouse script is reduced, and the storage space of the keyboard and mouse script in the terminal is saved.
204. It is detected whether a release event corresponding to the current event is absent after the current event.
In the above embodiment, it is mentioned that the lack of a release event affects the playback state of the keyboard and mouse script, and even affects the normal operation of the system, so it is necessary to ensure that each release event is followed by a corresponding release event, and thus it is necessary to detect whether a release event corresponding to the current event is lacked after the current event.
It should be noted that, in practical applications, the current event may be a press event, a release event, a mouse movement event, and a mouse wheel scroll event. And when the current event is a mouse moving event or a mouse wheel rolling event, directly continuing to detect the next event. When the current event is a press event, a release event corresponding to the current event is an event opposite to the current event operation; and when the current event is a release event, the release event corresponding to the current event is the current event itself. For example, if the current event is a key M pressing event, the release event corresponding to the current event is a key M release event; and if the current event is a key M release event, the release event corresponding to the current event is a key M release event.
In practical application, the terminal can complete the simulation operation of the key once when executing one pressing event and the corresponding releasing event, and when the same releasing event is repeatedly added after the releasing event, the simulation operation of the key is not influenced. Therefore, when adding a release event, the event type of the current event does not need to be judged.
Further, in order to avoid that when the current event is a release event, the subsequent event is also detected, and the detection speed of the keyboard and mouse script is reduced, the scheme is improved as follows:
whether the current event is a pressing event is detected before whether a releasing event corresponding to the current event is absent after the current event is detected. If the current event is a press-down event, continuing to detect whether a release event is lacked after the current event; if the current event is a releasing event, the event after the current event is not detected any more, but the next event adjacent to the current event is directly detected by a pressing event, whether the releasing event needs to be detected or not is judged, and then corresponding follow-up operation is carried out.
It should be noted that, regardless of whether the event needs to be pressed, when detecting an event subsequent to the current event, the detection range may be only detected for a next event adjacent to the current event, may be detected in several events adjacent to the current event, or may be detected in all events subsequent to the current event. The following two detection methods are described below:
the first method is as follows: it is detected whether there is a lack of a release event in all events following the current event.
And the terminal traverses all events after the current event and detects whether a release event corresponding to the current event is lacked. The mode of traversing and detecting all events after the current event can prevent the occurrence of event detection omission.
In practical application, except that a certain key is pressed for a long time, the user often presses and releases the keyboard or the mouse instantly when clicking, so that the clicking operation of the keyboard or the mouse recorded in the keyboard and mouse script often records one key pressing event and the releasing event of the key adjacently, and therefore in order to reduce the detection time, the following mode two can be adopted for detection.
The second method comprises the following steps: it is detected whether a next event adjacent to the current event is a release event.
If the next event adjacent to the current event is a release event corresponding to the current event, the terminal continuously detects whether the next event of the next event adjacent to the current event has a corresponding release event; and if the next event adjacent to the current event is not the release event corresponding to the current event, adding the release event after the current event.
205. And if the release event corresponding to the current event is lacked after the current event, adding the release event after the current event.
If there is no release event corresponding to the current event after the current event, the playback of the keyboard and mouse script may be affected, and even Windows may be abnormal, so the corresponding release event should be added after the current event to ensure the normal operation of the terminal.
No matter which position the release event corresponding to the current event is located, as long as the release event is located after the current event, no influence is generated on the playback result or the system, so a specific implementation manner of adding the release event after the current event may be to add the release event between the current event and the next event, may be to add the release event between any two events in all events after the current event, and may also be to add the release event after all events after the current event, and the specific addition position of the release event is not limited in this embodiment. The following describes different addition modes:
the first mode is as follows: a release event is added after the current event and before the next event adjacent to the current event.
Generally, since each event and its corresponding release event are often recorded adjacently, in order to coincide with the order of events in the keystroke script recording process, the release event may be added after the current event and before the next event adjacent to the current event.
In practical applications, a user often presses a long key on a keyboard or a mouse, and in the case of long key pressing, the terminal records a plurality of consecutive identical pressing events in a keyboard and mouse script, for example, when the user presses a key for x seconds for a long time, the computer records y consecutive identical key space pressing events. Therefore, in order to avoid that the terminal detects a plurality of continuous same events one by one and adds the same release event for a plurality of times to cause slow playback of the keyboard and mouse script, the release event can be added in the following way:
the second mode is as follows: it is detected whether at least one consecutive event adjacent to the current event is all the same as the current event. If at least one continuous event adjacent to the current event is the same as the current event, adding a release event after the last event in the at least one continuous event; if the next event adjacent to the current event is different from the current event, a release event is added after the current event.
Illustratively, the events recorded in the keyboard and mouse script are a button W pressing event, a button W releasing event, a button Y pressing event, a mouse moving event, a button U pressing event, and a button U releasing event in sequence. If the current event is the event that the first key Y is pressed down, after the current event is detected and the corresponding release event is lacked, the terminal continuously detects whether at least one continuous event adjacent to the current event is the same as the current event. And the detection result is that two continuous events adjacent to the current event are the same as the current event, so the terminal adds a key Y release event after the second event of the two continuous events adjacent to the current event.
The third mode is as follows: a release event is added after all events.
Since the playback result of the keymouse script is not affected as long as there is a corresponding release event after each press event, in order to distinguish the existing events in the keymouse script from the added release events, release events can be added after all events in the keymouse script, so that the last event in the keymouse script is preceded by the existing and unadditized events, and the last event in the keymouse script is followed by the added event.
In the mode that the added events are all positioned behind the existing events in the keyboard and mouse script, when corresponding releasing events do not exist in a plurality of adjacent or nonadjacent identical events, as long as the corresponding releasing event is added to the first event in the plurality of identical events, corresponding releasing events exist behind other events, and therefore the situation that the releasing events are repeatedly added is avoided.
Further, in practical applications, a user often needs to use some combination keys to complete necessary operations, for example, the user does not release the key Ctrl after pressing the key Ctrl, then presses the key X to complete a cutting operation, and this cutting operation records a key Ctrl pressing event and a key X pressing event in the computer in sequence, and records a key Ctrl releasing event and a key X releasing event only after the key X pressing event, therefore, when no key Ctrl releasing event exists after detecting the key Ctrl pressing event, a key Ctrl releasing event is added between the key Ctrl pressing event and the key X pressing event, and a cutting function is disabled, so as to further optimize a keyboard and mouse script, and ensure that the playback result of the keyboard and mouse script is unchanged on the basis of avoiding Windows abnormality, the following fourth method may be used to perform operations:
the fourth mode is that: whether the current event is an event in the event combination is detected. If the current event is the event in the event combination, adding a release event corresponding to the current event after the last event in the event combination; and if the current event is not the event in the event combination, adding a release event corresponding to the current event after the current event.
The event combination comprises a plurality of events generated by triggering a combination key, and the event combination comprises a key Ctrl event, a key Alt event, a key Shift event and a key Fn event. The combination key is composed of special keys such as a key Ctrl, a key Alt, a key Shift, and a key Fn, and general keys such as other letters on the keyboard, so that the event combination also includes corresponding events of other keys such as letter keys.
When the current event is detected to be the event in the event combination, the release event corresponding to the current event is added after the last event in the event combination, so that the special function of the combination key triggered by the event combination can be ensured not to be damaged.
Illustratively, the events recorded in the keyboard and mouse script are a key O press event, a key O release event, a key Ctrl press event, a key C release event, a key M press event, a mouse movement event, a key enter press event, and a key enter release event in this order. If the current event is a key Ctrl pressing event, it may be detected that a key Ctrl releasing event is absent after the key Ctrl pressing event, and the key Ctrl and the key C are combined keys, and the events in the event combination include a key Ctrl pressing event, a key C pressing event, and a key C releasing event, so that in order to avoid destroying the copy function generated by combining the key Ctrl and the key C, the terminal adds the key Ctrl releasing event after the last event in the event combination (i.e., the key C releasing event); if the current event is a key M pressing event, it can be detected that a key M releasing event is lacked after the key M pressing event, and the key M pressing event is not an event in the event combination, so that a key M releasing event is added after the key M pressing event.
Optionally, in practical applications, when the user uses the combination key, the user often releases the key pressed later first, and releases the key pressed first later, for example, when the user uses the key Ctrl and the key C to implement the copy function, the user often presses the key Ctrl first, and then presses the key C in the process of pressing the key Ctrl; when the key is released, the key C is usually released first, and then the key Ctrl is released. Therefore, in order to conform to the order in which the user uses the keys, the fourth mode is modified as follows:
if the current event is the event in the event combination, after the release event is detected to be absent after the current event, whether the corresponding release event is absent after the event in the event combination after the current event is detected to be absent or not is continuously detected. If the corresponding release events are lacked, adding the release events in the reverse direction according to the sequence of the events in the event combination after the last event in the event combination; if the corresponding release event is not absent, then the release event corresponding to the current event is added after the last event in the event group.
Illustratively, the events recorded in the keyboard and mouse script are a button J press event, a button J release event, a button Ctrl press event, a button C press event, a button X release event, a mouse movement event, a left mouse button press event, and a left mouse button release event. If the current event is the key Ctrl pressing event, after the key Ctrl pressing event is detected and then the key Ctrl releasing event is absent, the key C releasing event is continuously detected and then the key C pressing event is absent. Therefore, after the key C presses the event, the release events are added in the reverse order of the events, namely the key C release event and the key Ctrl release event are added in sequence, so that the sequence of the events in the keyboard and mouse script is consistent with the operation sequence of the user.
It should be noted that, for the different ways of adding a release event, after adding a release event corresponding to the current event, the terminal marks the added release event to distinguish an event in the existing keymouse script from the added event. The flag may occupy one byte, or multiple bytes of storage space, as well as the storage form of the event type, the coordinate of the operation focus, and other information. When detecting that the current event has the added mark, the terminal directly detects the next event and events after the next event, and does not detect the events after the current event any more.
206. And (5) storing the treated kangaroo script.
This step is identical to the content of the keyboard and mouse script after the storage processing in step 106, and is not described herein again.
Further, as an implementation of the foregoing embodiments, an embodiment of the present invention further provides a device for processing a mouse script, as shown in fig. 3, where the device includes: an acquisition unit 31, a detection unit 32, a deletion unit 33, an addition unit 34, and a saving unit 35. Wherein,
an acquiring unit 31 configured to acquire a keyboard and mouse script to be executed;
a detecting unit 32, configured to detect whether a redundant event exists in the keyboard and mouse script acquired by the acquiring unit 31, where the redundant event is an event that does not affect the playback state of the keyboard and mouse script;
a deleting unit 33 configured to delete the redundant event when the detecting unit 32 detects that the redundant event exists in the keyboard and mouse script;
the detection unit 32 is further configured to detect whether an essential event is absent in the keyboard and mouse script, where the essential event is an event that should be recorded in the keyboard and mouse script;
an adding unit 34 for adding a necessary event when the detecting unit 32 detects that the necessary event is absent in the keyboard and mouse script;
and the storage unit 35 is used for storing the processed keyboard and mouse script.
Further, the detecting unit 32 is configured to determine whether an event set matching a preset optimization condition exists in the keyboard and mouse script acquired by the acquiring unit 31;
and a deleting unit 33, configured to determine, when the detecting unit 32 detects that an event set matching the preset optimization condition exists in the keyboard and mouse script, that an event in the event set matching the preset optimization condition is a redundant event, and delete the redundant event.
Further, as shown in fig. 4, the detecting unit 32 includes:
the first detecting module 321 is configured to detect whether a plurality of continuous mouse moving events exist in the keyboard and mouse script;
the first determining module 322 is configured to determine that a plurality of consecutive mouse movement events match a preset optimization condition when the first detecting module 321 detects that the plurality of consecutive mouse movement events exist in the keyboard and mouse script.
The first detecting module 321 is further configured to detect whether a time interval after a last event in the multiple consecutive mouse movement events is greater than a first preset time threshold before determining that the multiple consecutive mouse movement events are matched with a preset optimization condition;
the first determining module 322 is further configured to determine that the plurality of consecutive mouse movement events match the preset optimization condition when the first detecting module 321 detects that a time interval after a last event in the plurality of consecutive mouse movement events is greater than a first preset time threshold.
A second detecting module 323, configured to detect whether a sum of time intervals between adjacent events in a plurality of consecutive same pressing events is greater than a second preset time threshold;
a second determining module 324, configured to determine that a plurality of consecutive same pressing events match the preset optimization condition when the second detecting module 323 detects that the sum of the time intervals is greater than the second preset time threshold.
The second preset time threshold used by the second detection module 323 is the maximum time threshold of the application operation provided by the application developer, or the maximum time threshold of the application operation counted in the background.
A third detecting module 325, configured to detect whether an event triggered by a key other than a preset key exists in the keyboard and mouse script;
the third determining module 326 is configured to determine that the events triggered by the keys other than the preset keys are matched with the preset optimization conditions when the third detecting module 325 detects that the events triggered by the keys other than the preset keys exist in the keyboard and mouse script.
The preset key used by the third detection module 325 is a key provided by an application developer for triggering application operation, or a key used for triggering application operation counted in the background.
A reading module 327, configured to read coordinates of an operation focus from the event;
a determining module 328, configured to determine whether the coordinate read by the reading module 327 is located in the target window;
a fourth determining module 329, configured to determine that the event corresponding to the coordinate not located in the target window matches the preset optimization condition when the determining module 328 determines that the coordinate is not located in the target window.
The deleting unit 33 is further configured to merge a plurality of consecutive time intervals into one time interval after the redundant event is deleted.
Further, the detecting unit 32 is configured to detect whether a release event corresponding to the current event is absent after the current event;
an adding unit 34, configured to add a release event after the current event when the detecting unit 32 detects that the release event corresponding to the current event is absent after the current event.
Further, as shown in fig. 4, the detecting unit 32 includes:
the fourth detecting module 3210 is configured to detect whether the current event is a press event, and if the current event is a press event, detect whether a release event is absent after the current event.
A fifth detecting module 3211, configured to detect whether there is a lack of a release event in all events after the current event.
The sixth detecting module 3212 is configured to detect whether a next event adjacent to the current event is a release event.
Further, as shown in fig. 4, the adding unit 34 includes:
a first adding module 341, configured to add a release event after the current event and before a next event adjacent to the current event.
A first detecting module 342, configured to detect whether at least one consecutive event adjacent to the current event is the same as the current event;
the second adding module 343 is configured to, when the first detecting module 342 detects that at least one consecutive event adjacent to the current event is the same as the current event, add a release event after a last event of the at least one consecutive event.
A third adding module 344 for adding a release event after all events.
A second detecting module 345, configured to detect whether the current event is an event in an event combination, where the event combination is composed of multiple events generated by triggering a combination key;
a fourth adding module 346, configured to, when the second detecting module 345 detects that the current event is an event in the event combination, add a release event corresponding to the current event after the last event in the event combination.
The device for processing the keyboard and mouse script provided by the embodiment of the invention can detect whether redundant events exist in the keyboard and mouse script and whether necessary events are lacked or not after the keyboard and mouse script to be executed is obtained, delete the redundant events when the redundant events exist, and add the necessary events when the necessary events are lacked, thereby obtaining the processed keyboard and mouse script. Compared with the keyboard and mouse script which is directly recorded in the prior art, the method and the device can not only reduce the data volume of the keyboard and mouse script, but also avoid the Windows abnormal phenomenon caused by the lack of necessary events.
The embodiment of the invention discloses:
a1, a method for keyboard and mouse script treatment, the method comprises:
acquiring a keyboard and mouse script to be executed;
detecting whether a redundant event exists in the keyboard and mouse script, wherein the redundant event is an event which does not influence the playback state of the keyboard and mouse script;
if the redundant event exists in the keyboard and mouse script, deleting the redundant event;
detecting whether an essential event is absent in the keyboard and mouse script, wherein the essential event is an event which should be recorded in the keyboard and mouse script;
adding the necessary event if the necessary event is absent from the keyboard and mouse script;
and (5) storing the treated kangaroo script.
A2, the method of A1, wherein the detecting whether the keyboard and mouse script has redundant events comprises:
judging whether an event set matched with a preset optimization condition exists in the keyboard and mouse script;
if the redundant event exists in the keyboard and mouse script, deleting the redundant event, wherein the deleting comprises:
if the keyboard and mouse script has an event set matched with a preset optimization condition, determining that the event in the event set matched with the preset optimization condition is a redundant event, and deleting the redundant event.
A3, according to the method in A2, the determining whether an event set matching a preset optimization condition exists in the keyboard and mouse script includes:
detecting whether a plurality of continuous mouse moving events exist in the keyboard and mouse script;
and if a plurality of continuous mouse moving events exist in the keyboard and mouse script, determining that the plurality of continuous mouse moving events are matched with the preset optimization condition.
A4, before the determining that the plurality of consecutive mouse movement events match the preset optimization condition, according to the method of A3, the method further comprising:
detecting whether a time interval after a last event in the plurality of continuous mouse movement events is greater than a first preset time threshold;
the determining that the plurality of continuous mouse movement events match the preset optimization condition includes:
and if the time interval after the last event in the plurality of continuous mouse movement events is greater than the first preset time threshold, determining that the plurality of continuous mouse movement events are matched with the preset optimization condition.
A5, according to the method in A2, the determining whether an event set matching a preset optimization condition exists in the keyboard and mouse script includes:
detecting whether the sum of time intervals between adjacent events in a plurality of continuous same pressing events is greater than a second preset time threshold;
if the sum of the time intervals is greater than the second preset time threshold, determining that the plurality of continuous same pressing events are matched with the preset optimization condition.
A6, according to the method in A5, the second preset time threshold is the maximum time threshold of application operation provided by an application developer;
or the second preset time threshold is the longest time threshold of the application operation of the background statistics.
A7, according to the method in A2, the determining whether an event set matching a preset optimization condition exists in the keyboard and mouse script includes:
detecting whether an event triggered by keys except for preset keys exists in the keyboard and mouse script;
and if the key mouse script has an event triggered by a key except a preset key, determining that the event triggered by the key except the preset key is matched with the preset optimization condition.
A8, according to the method A7, the preset key is a key provided by an application developer for triggering application operation;
or the preset key is used for triggering application operation and counted in the background.
A9, according to the method in A2, the determining whether an event set matching a preset optimization condition exists in the keyboard and mouse script includes:
reading the coordinates of the operation focus from the event;
judging whether the coordinates are positioned in a target window or not;
and if the coordinates are not located in the target window, determining that the event corresponding to the coordinates which are not located in the target window is matched with the preset optimization condition.
A10, the method of any one of A1 to A9, further comprising, after said deleting the redundant event:
a plurality of consecutive time intervals are combined into one time interval.
A11, the method of A1, the detecting whether an essential event is absent from the keyboard and mouse script, comprising:
detecting whether a release event corresponding to a current event is lacked after the current event;
adding the necessary event if the necessary event is absent from the keyboard and mouse script, including:
and if a release event corresponding to the current event is lacked after the current event, adding the release event after the current event.
A12, the method of A11, the detecting whether there is a release event corresponding to a current event that is absent after the current event, comprising:
detecting whether the current event is a press-down event;
and if the current event is a press-down event, detecting whether the release event is lacked after the current event.
A13, the method of A11, the detecting whether there is a release event corresponding to a current event that is absent after the current event, comprising:
detecting whether the release event is absent from all events subsequent to the current event.
A14, the method of A11, the detecting whether there is a release event corresponding to a current event that is absent after the current event, comprising:
detecting whether a next event adjacent to the current event is the release event.
A15, the adding the release event after the current event according to the method of A11, comprising:
adding the release event after the current event and before a next event adjacent to the current event.
A16, the adding the release event after the current event according to the method of A11, comprising:
detecting whether at least one continuous event adjacent to the current event is the same as the current event;
and if at least one continuous event adjacent to the current event is the same as the current event, adding the release event after the last event in the at least one continuous event.
A17, the adding the release event after the current event according to the method of A11, comprising:
the release event is added after all events.
A18, the adding the release event after the current event according to the method of A11, comprising:
detecting whether the current event is an event in an event combination, wherein the event combination consists of a plurality of events generated by triggering a combination key;
and if the current event is the event in the event combination, adding a release event corresponding to the current event after the last event in the event combination.
B19, a device for mouse-and-click script processing, the device comprising:
the acquisition unit is used for acquiring a keyboard and mouse script to be executed;
the detection unit is used for detecting whether a redundant event exists in the keyboard and mouse script acquired by the acquisition unit, wherein the redundant event is an event which does not influence the playback state of the keyboard and mouse script;
the deleting unit is used for deleting the redundant events when the detecting unit detects that the redundant events exist in the keyboard and mouse script;
the detecting unit is further used for detecting whether an essential event is absent in the keyboard and mouse script, wherein the essential event is an event which should be recorded in the keyboard and mouse script;
an adding unit configured to add the necessary event when the detecting unit detects that the necessary event is absent from the keyboard and mouse script;
and the storage unit is used for storing the processed keyboard and mouse script.
B20, the device according to B19, the detecting unit is used for judging whether the keyboard and mouse script acquired by the acquiring unit has an event set matched with a preset optimization condition;
the deleting unit is used for determining that the event in the event set matched with the preset optimization condition is a redundant event and deleting the redundant event when the detecting unit detects that the event set matched with the preset optimization condition exists in the keyboard and mouse script.
B21, the device according to B20, the detection unit comprising:
the first detection module is used for detecting whether a plurality of continuous mouse moving events exist in the keyboard and mouse script;
the first determining module is used for determining that a plurality of continuous mouse moving events are matched with the preset optimization condition when the first detecting module detects that the plurality of continuous mouse moving events exist in the keyboard and mouse script.
B22, the apparatus of B21, the first detecting module further configured to detect whether a time interval after a last event of the plurality of consecutive mouse movement events is greater than a first preset time threshold before the determining that the plurality of consecutive mouse movement events match the preset optimization condition;
the first determining module is further configured to determine that the plurality of continuous mouse movement events match the preset optimization condition when the first detecting module detects that a time interval after a last event in the plurality of continuous mouse movement events is greater than the first preset time threshold.
B23, the device according to B20, the detection unit comprising:
the second detection module is used for detecting whether the sum of time intervals between adjacent events in a plurality of continuous same pressing events is greater than a second preset time threshold value;
a second determining module, configured to determine that the multiple consecutive same pressing events match the preset optimization condition when the second detecting module detects that the sum of the time intervals is greater than the second preset time threshold.
B24, according to the device of B23, the second preset time threshold used by the second detection module is a maximum time threshold of application operation provided by an application developer, or a maximum time threshold of application operation of background statistics.
B25, the device according to B20, the detection unit comprising:
the third detection module is used for detecting whether an event triggered by keys except the preset keys exists in the keyboard and mouse script or not;
and the third determining module is used for determining that the events triggered by the keys except the preset keys are matched with the preset optimization conditions when the third detecting module detects that the events triggered by the keys except the preset keys exist in the keyboard and mouse script.
B26, according to the apparatus of B25, the preset button used by the third detection module is a button provided by an application developer for triggering application operation, or a button used by background statistics for triggering application operation.
B27, the device according to B20, the detection unit comprising:
the reading module is used for reading the coordinates of the operation focus from the event;
the judging module is used for judging whether the coordinates read by the reading module are positioned in a target window or not;
and the fourth determining module is used for determining that the event corresponding to the coordinate which is not positioned in the target window is matched with the preset optimization condition when the judgment result of the judging module is that the coordinate is not positioned in the target window.
B28, the apparatus according to any of B19 to B27, wherein the deleting unit is further configured to merge a plurality of consecutive time intervals into one time interval after the redundant event is deleted.
B29, the device according to B19, the detecting unit is used for detecting whether a release event corresponding to the current event is absent after the current event;
the adding unit is used for adding the release event after the current event when the detecting unit detects that the release event corresponding to the current event is lacked after the current event.
B30, the device according to B29, the detection unit comprising:
a fourth detection module, configured to detect whether the current event is a press event, and if the current event is a press event, detect whether a release event is absent after the current event.
B31, the device according to B29, the detection unit comprising:
and the fifth detection module is used for detecting whether the release event is absent in all the events after the current event.
B32, the device according to B29, the detection unit comprising:
a sixth detecting module, configured to detect whether a next event adjacent to the current event is the release event.
B33, the apparatus of B29, the adding unit comprising:
a first adding module for adding the release event after the current event and before a next event adjacent to the current event.
B34, the apparatus of B29, the adding unit comprising:
the first detection module is used for detecting whether at least one continuous event adjacent to the current event is the same as the current event or not;
a second adding module, configured to add the release event after a last event of the consecutive at least one event when the first detecting module detects that the consecutive at least one event adjacent to the current event is the same as the current event.
B35, the apparatus of B29, the adding unit comprising:
a third adding module for adding the release event after all events.
B36, the apparatus of B29, the adding unit comprising:
the second detection module is used for detecting whether the current event is an event in an event combination, wherein the event combination consists of a plurality of events generated by triggering a combination key;
a fourth adding module, configured to add, when the second detecting module detects that the current event is an event in an event combination, a release event corresponding to the current event after a last event in the event combination.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It will be appreciated that the relevant features of the method and apparatus described above are referred to one another. In addition, "first", "second", and the like in the above embodiments are for distinguishing the embodiments, and do not represent merits of the embodiments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of a network communication method, apparatus and system in accordance with embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (36)

1. A method of keyboard and mouse script processing, the method comprising:
acquiring a keyboard and mouse script to be executed;
detecting whether a redundant event exists in the keyboard and mouse script, wherein the redundant event is an event which does not influence the playback state of the keyboard and mouse script;
if the redundant event exists in the keyboard and mouse script, deleting the redundant event;
detecting whether an essential event is absent in the keyboard and mouse script, wherein the essential event is an event which should be recorded in the keyboard and mouse script;
adding the necessary event if the necessary event is absent from the keyboard and mouse script;
preserving the treated kangaroo script;
the detecting whether the keyboard and mouse script lacks necessary events comprises the following steps:
detecting whether a release event corresponding to a current event is absent after the current event.
2. The method of claim 1, wherein the detecting whether there is a redundant event in the keyboard and mouse script comprises:
judging whether an event set matched with a preset optimization condition exists in the keyboard and mouse script;
if the redundant event exists in the keyboard and mouse script, deleting the redundant event, wherein the deleting comprises:
if the keyboard and mouse script has an event set matched with a preset optimization condition, determining that the event in the event set matched with the preset optimization condition is a redundant event, and deleting the redundant event.
3. The method of claim 2, wherein the determining whether the set of events matching a preset optimization condition exists in the keyboard and mouse script comprises:
detecting whether a plurality of continuous mouse moving events exist in the keyboard and mouse script;
and if a plurality of continuous mouse moving events exist in the keyboard and mouse script, determining that the plurality of continuous mouse moving events are matched with the preset optimization condition.
4. The method of claim 3, wherein prior to the determining that the plurality of consecutive mouse movement events match the preset optimization condition, the method further comprises:
detecting whether a time interval after a last event in the plurality of continuous mouse movement events is greater than a first preset time threshold;
the determining that the plurality of continuous mouse movement events match the preset optimization condition includes:
and if the time interval after the last event in the plurality of continuous mouse movement events is greater than the first preset time threshold, determining that the plurality of continuous mouse movement events are matched with the preset optimization condition.
5. The method of claim 2, wherein the determining whether the set of events matching a preset optimization condition exists in the keyboard and mouse script comprises:
detecting whether the sum of time intervals between adjacent events in a plurality of continuous same pressing events is greater than a second preset time threshold;
if the sum of the time intervals is greater than the second preset time threshold, determining that the plurality of continuous same pressing events are matched with the preset optimization condition.
6. The method according to claim 5, wherein the second preset time threshold is a maximum time threshold for application operation provided by an application developer;
or the second preset time threshold is the longest time threshold of the application operation of the background statistics.
7. The method of claim 2, wherein the determining whether the set of events matching a preset optimization condition exists in the keyboard and mouse script comprises:
detecting whether an event triggered by keys except for preset keys exists in the keyboard and mouse script;
and if the key mouse script has an event triggered by a key except a preset key, determining that the event triggered by the key except the preset key is matched with the preset optimization condition.
8. The method according to claim 7, wherein the preset key is a key provided by an application developer for triggering application operation;
or the preset key is used for triggering application operation and counted in the background.
9. The method of claim 2, wherein the determining whether the set of events matching a preset optimization condition exists in the keyboard and mouse script comprises:
reading the coordinates of the operation focus from the event;
judging whether the coordinates are positioned in a target window or not;
and if the coordinates are not located in the target window, determining that the event corresponding to the coordinates which are not located in the target window is matched with the preset optimization condition.
10. The method of any one of claims 1 to 9, wherein after said removing said redundant event, said method further comprises:
a plurality of consecutive time intervals are combined into one time interval.
11. The method of claim 1, wherein adding the requisite event if the requisite event is absent from the keyboard and mouse script comprises:
and if a release event corresponding to the current event is lacked after the current event, adding the release event after the current event.
12. The method of claim 11, wherein the detecting whether a release event corresponding to a current event is absent after the current event comprises:
detecting whether the current event is a press-down event;
and if the current event is a press-down event, detecting whether the release event is lacked after the current event.
13. The method of claim 11, wherein the detecting whether a release event corresponding to a current event is absent after the current event comprises:
detecting whether the release event is absent from all events subsequent to the current event.
14. The method of claim 11, wherein the detecting whether a release event corresponding to a current event is absent after the current event comprises:
detecting whether a next event adjacent to the current event is the release event.
15. The method of claim 11, wherein adding the release event after the current event comprises:
adding the release event after the current event and before a next event adjacent to the current event.
16. The method of claim 11, wherein adding the release event after the current event comprises:
detecting whether at least one continuous event adjacent to the current event is the same as the current event;
and if at least one continuous event adjacent to the current event is the same as the current event, adding the release event after the last event in the at least one continuous event.
17. The method of claim 11, wherein adding the release event after the current event comprises:
the release event is added after all events.
18. The method of claim 11, wherein adding the release event after the current event comprises:
detecting whether the current event is an event in an event combination, wherein the event combination consists of a plurality of events generated by triggering a combination key;
and if the current event is the event in the event combination, adding a release event corresponding to the current event after the last event in the event combination.
19. A device for mousetrap script processing, the device comprising:
the acquisition unit is used for acquiring a keyboard and mouse script to be executed;
the detection unit is used for detecting whether a redundant event exists in the keyboard and mouse script acquired by the acquisition unit, wherein the redundant event is an event which does not influence the playback state of the keyboard and mouse script;
the deleting unit is used for deleting the redundant events when the detecting unit detects that the redundant events exist in the keyboard and mouse script;
the detecting unit is further used for detecting whether an essential event is absent in the keyboard and mouse script, wherein the essential event is an event which should be recorded in the keyboard and mouse script;
an adding unit configured to add the necessary event when the detecting unit detects that the necessary event is absent from the keyboard and mouse script;
the storage unit is used for storing the processed keyboard and mouse scripts;
the detection unit is used for detecting whether a release event corresponding to the current event is lacked after the current event.
20. The apparatus according to claim 19, wherein the detecting unit is configured to determine whether an event set matching a preset optimization condition exists in the keyboard and mouse script acquired by the acquiring unit;
the deleting unit is used for determining that the event in the event set matched with the preset optimization condition is a redundant event and deleting the redundant event when the detecting unit detects that the event set matched with the preset optimization condition exists in the keyboard and mouse script.
21. The apparatus of claim 20, wherein the detection unit comprises:
the first detection module is used for detecting whether a plurality of continuous mouse moving events exist in the keyboard and mouse script;
the first determining module is used for determining that a plurality of continuous mouse moving events are matched with the preset optimization condition when the first detecting module detects that the plurality of continuous mouse moving events exist in the keyboard and mouse script.
22. The apparatus of claim 21, wherein the first detecting module is further configured to detect whether a time interval after a last event of the plurality of consecutive mouse movement events is greater than a first preset time threshold before the determining that the plurality of consecutive mouse movement events match the preset optimization condition;
the first determining module is further configured to determine that the plurality of continuous mouse movement events match the preset optimization condition when the first detecting module detects that a time interval after a last event in the plurality of continuous mouse movement events is greater than the first preset time threshold.
23. The apparatus of claim 20, wherein the detection unit comprises:
the second detection module is used for detecting whether the sum of time intervals between adjacent events in a plurality of continuous same pressing events is greater than a second preset time threshold value;
a second determining module, configured to determine that the multiple consecutive same pressing events match the preset optimization condition when the second detecting module detects that the sum of the time intervals is greater than the second preset time threshold.
24. The apparatus of claim 23, wherein the second preset time threshold used by the second detection module is a maximum time threshold of an application operation provided by an application developer or a maximum time threshold of an application operation of a background statistic.
25. The apparatus of claim 20, wherein the detection unit comprises:
the third detection module is used for detecting whether an event triggered by keys except the preset keys exists in the keyboard and mouse script or not;
and the third determining module is used for determining that the events triggered by the keys except the preset keys are matched with the preset optimization conditions when the third detecting module detects that the events triggered by the keys except the preset keys exist in the keyboard and mouse script.
26. The apparatus according to claim 25, wherein the preset key used by the third detection module is a key provided by an application developer for triggering an application operation, or a key used by a background statistic for triggering an application operation.
27. The apparatus of claim 20, wherein the detection unit comprises:
the reading module is used for reading the coordinates of the operation focus from the event;
the judging module is used for judging whether the coordinates read by the reading module are positioned in a target window or not;
and the fourth determining module is used for determining that the event corresponding to the coordinate which is not positioned in the target window is matched with the preset optimization condition when the judgment result of the judging module is that the coordinate is not positioned in the target window.
28. The apparatus according to any one of claims 19 to 27, wherein said deleting unit is further configured to merge a plurality of consecutive time intervals into one time interval after said deleting the redundant event.
29. The apparatus according to claim 19, wherein the adding unit is configured to add the release event after the current event when the detecting unit detects that the release event corresponding to the current event is absent after the current event.
30. The apparatus of claim 29, wherein the detection unit comprises:
a fourth detection module, configured to detect whether the current event is a press event, and if the current event is a press event, detect whether a release event is absent after the current event.
31. The apparatus of claim 29, wherein the detection unit comprises:
and the fifth detection module is used for detecting whether the release event is absent in all the events after the current event.
32. The apparatus of claim 29, wherein the detection unit comprises:
a sixth detecting module, configured to detect whether a next event adjacent to the current event is the release event.
33. The apparatus of claim 29, wherein the adding unit comprises:
a first adding module for adding the release event after the current event and before a next event adjacent to the current event.
34. The apparatus of claim 29, wherein the adding unit comprises:
the first detection module is used for detecting whether at least one continuous event adjacent to the current event is the same as the current event or not;
a second adding module, configured to add the release event after a last event of the consecutive at least one event when the first detecting module detects that the consecutive at least one event adjacent to the current event is the same as the current event.
35. The apparatus of claim 29, wherein the adding unit comprises:
a third adding module for adding the release event after all events.
36. The apparatus of claim 29, wherein the adding unit comprises:
the second detection module is used for detecting whether the current event is an event in an event combination, wherein the event combination consists of a plurality of events generated by triggering a combination key;
a fourth adding module, configured to add, when the second detecting module detects that the current event is an event in an event combination, a release event corresponding to the current event after a last event in the event combination.
CN201510150010.8A 2015-03-31 2015-03-31 A kind of method and apparatus of key mouse script processing Expired - Fee Related CN106155886B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510150010.8A CN106155886B (en) 2015-03-31 2015-03-31 A kind of method and apparatus of key mouse script processing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510150010.8A CN106155886B (en) 2015-03-31 2015-03-31 A kind of method and apparatus of key mouse script processing

Publications (2)

Publication Number Publication Date
CN106155886A CN106155886A (en) 2016-11-23
CN106155886B true CN106155886B (en) 2019-05-14

Family

ID=57338610

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510150010.8A Expired - Fee Related CN106155886B (en) 2015-03-31 2015-03-31 A kind of method and apparatus of key mouse script processing

Country Status (1)

Country Link
CN (1) CN106155886B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108459848B (en) * 2017-02-20 2021-12-14 深圳市北斗智研科技有限公司 Script obtaining method and system applied to Excel software

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101241466A (en) * 2007-02-08 2008-08-13 深圳迈瑞生物医疗电子股份有限公司 Embedded software test method and system
CN102147756A (en) * 2010-02-05 2011-08-10 中国移动通信集团公司 Methods and systems for testing terminal
CN102799428A (en) * 2012-06-28 2012-11-28 北京大学 Operation recording and playback method for interactive software
CN102841789A (en) * 2012-06-29 2012-12-26 北京奇虎科技有限公司 Method and device for recording and playing back user operations in browser
CN103488507A (en) * 2013-09-18 2014-01-01 北京思特奇信息技术股份有限公司 User behavior trajectory playback method
CN103984626A (en) * 2014-05-13 2014-08-13 华为技术有限公司 Method and device for generating test-case script

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090265719A1 (en) * 2008-04-18 2009-10-22 Microsoft Corporation Application macro recording utilizing method interception

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101241466A (en) * 2007-02-08 2008-08-13 深圳迈瑞生物医疗电子股份有限公司 Embedded software test method and system
CN102147756A (en) * 2010-02-05 2011-08-10 中国移动通信集团公司 Methods and systems for testing terminal
CN102799428A (en) * 2012-06-28 2012-11-28 北京大学 Operation recording and playback method for interactive software
CN102841789A (en) * 2012-06-29 2012-12-26 北京奇虎科技有限公司 Method and device for recording and playing back user operations in browser
CN103488507A (en) * 2013-09-18 2014-01-01 北京思特奇信息技术股份有限公司 User behavior trajectory playback method
CN103984626A (en) * 2014-05-13 2014-08-13 华为技术有限公司 Method and device for generating test-case script

Also Published As

Publication number Publication date
CN106155886A (en) 2016-11-23

Similar Documents

Publication Publication Date Title
US8627233B2 (en) Radial menu with overshoot, fade away, and undo capabilities
EP2780820B1 (en) Measuring web page rendering time
CN104239157B (en) Method and device for optimizing and cleaning data of mobile terminal
US20100251180A1 (en) Radial menu selection with gestures
CN105847554A (en) Data processing method during abnormal shutdown of mobile terminal and mobile terminal
CN107145782B (en) Abnormal application program identification method, mobile terminal and server
CN105144117B (en) To the automatic correlation analysis method of allocating stack and context data
CN104992094A (en) Terminal operation method and terminal
CN102902515A (en) Software window processing method and device
CN109918141A (en) Thread execution method, device, terminal and storage medium
CN106648715A (en) Method and system for loading pop-up window control
CN108966016A (en) A kind of method, apparatus and terminal device of video clip replay
CN105868625B (en) Method and device for intercepting restart deletion of file
CN110442819A (en) Data processing method, device, storage medium and terminal
CN106155886B (en) A kind of method and apparatus of key mouse script processing
CN107423090B (en) Flash player abnormal log management method and system
KR101619691B1 (en) Method and system for analyzing program error
CN109876446B (en) Method and device for detecting occupation distribution of game map and grid in memory
US20150035767A1 (en) Method and electronic device for disabling a touch point
WO2016165382A1 (en) Method, device and storage medium for processing application program
CN106339155A (en) File sharing method and device
CN109491746A (en) A kind of saturating solution of touch screen terminal point, device, touch screen terminal and storage medium
CN111124519A (en) Method and system for optimizing starting speed of android application program based on input response
CN108170593A (en) The method and device of application program operation
US20130179776A1 (en) Enabling Performant Cascading Operations

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220725

Address after: Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015

Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Patentee before: Qizhi software (Beijing) Co.,Ltd.

CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20190514