Summary of the invention
In view of this, the application provides a kind of control acquisition methods and device.
Specifically, the application is achieved by the following technical solution:
A kind of acquisition methods of Windows control property, described method includes:
Judge whether target widget is Windows standard control;
If described target widget is not Windows standard control, then sends control and obtain request to installation
The software of described target widget, obtains software described in acquisition request for described software according to described control
Control property;
From the control property of described software, described target widget is obtained according to known target widget attribute
All attributes.
Further, described control acquisition request includes: window handle, store path and storage format;
Described control obtains request, for all controls obtained in described software under this window for described software
Part attribute, and all control properties under described window are stored described storage road with described storage format
In footpath;
Target widget attribute known to described basis obtains described target widget from the control of described software,
Including:
The all control properties under described window are obtained from described store path;
Described target widget is obtained according in the known target widget attribute all controls from described window
Whole attributes.
Further, described control acquisition request includes: window handle;
Described control obtains request, for all controls obtained in described software under this window for described software
Part attribute, and all control properties under described window are returned;
Target widget attribute known to described basis obtains described target widget from the control of described software
All attributes, including:
Receive all control properties under the described window that described software is returned by process communication;
Described target widget is obtained according in the known target widget attribute all controls from described window
Whole attributes.
Further, described method also includes:
Without getting whole attributes of described target widget within the default time, then resend
Control obtains request to the software installing described target widget.
Further, described method also includes:
When resending control and obtaining the number of times that the number of times arrival asked is preset, if the most do not got
Whole attributes of described target widget, then return and obtain failure information.
A kind of acquisition device of Windows control property, described device includes:
Judging unit, it is judged that whether target widget is Windows standard control;
Transmitting element, when described target widget is not Windows standard control, is sent out by process communication
Send control to obtain the request software to the described target widget of installation, obtain according to described control for described software
Take the control property of software described in acquisition request;
Acquiring unit, obtains described from the control property of described software according to known target widget attribute
Whole attributes of target widget.
Further, described control acquisition request includes: window handle, store path and storage format;
Described control obtains request, for all controls obtained in described software under this window for described software
Part attribute, and all control properties under described window are stored described storage road with described storage format
In footpath;
Described acquiring unit, specifically obtains all control properties under described window from described store path,
And obtain described target widget according in the known target widget attribute all controls from described window
All attributes.
Further, described control acquisition request includes: window handle;
Described control obtains request, for all controls obtained in described software under this window for described software
Part attribute, and all control properties under described window are returned;
Described acquiring unit, the concrete institute received under the described window that described software is returned by process communication
There is control property, and according to the known target widget attribute all controls from described window obtain institute
State whole attributes of target widget.
Further, described device also includes:
Retransmission unit, when not getting whole attribute of described target widget within the default time,
Resend control and obtain request to the software installing described target widget.
Further, described retransmission unit, obtain what the number of times arrival asked was preset when resending control
During number of times, if the most not getting whole attributes of described target widget, then return and obtain failure information.
By above description it can be seen that the application is when obtaining target widget, can first judge target widget
Whether it is Windows standard control, and when target widget is not Windows standard control, passes through
Communication between process sends control and obtains the request software to the described target widget of installation, non-to obtain
Whole attributes of Windows standard control, thus realize the acquisition to different classes of control property.
Detailed description of the invention
Here will illustrate exemplary embodiment in detail, its example represents in the accompanying drawings.Following
When description relates to accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represents same or analogous
Key element.Embodiment described in following exemplary embodiment does not represent the institute consistent with the application
There is embodiment.On the contrary, they only with as appended claims describes in detail, the one of the application
The example of the apparatus and method that a little aspects are consistent.
It is only merely for describing the purpose of specific embodiment at term used in this application, and is not intended to be limiting
The application." a kind of " of singulative used in the application and appended claims, " institute
State " and " being somebody's turn to do " be also intended to include most form, unless context clearly shows that other implications.Also should
Work as understanding, term "and/or" used herein refer to and comprise one or more be associated list item
Any or all possible combination of purpose.
Although should be appreciated that may use term first, second, third, etc. various to describe in the application
Information, but these information should not necessarily be limited by these terms.These terms only be used for by same type of information that
This distinguishes.Such as, in the case of without departing from the application scope, the first information can also be referred to as
Two information, similarly, the second information can also be referred to as the first information.Depend on linguistic context, as in this institute
Use word " if " can be construed to " and ... time " or " when ... time " or " response
In determining ".
For the problems referred to above, the application provides a kind of control to obtain scheme, it is possible to achieve mark Windows
Quasi-control and the acquisition of non-standard control.
Fig. 1 is the acquisition methods of a kind of Windows control property shown in the application one exemplary embodiment
Flow chart.
Refer to Fig. 1, the application provides the acquisition methods of a kind of Windows control property, can apply
In terminal, include following steps:
Step 101, it is judged that whether target widget is Windows standard control.If described target widget
It not Windows standard control, then perform step 102.
In the present embodiment, when obtaining target widget, first judge whether target widget is Windows mark
Quasi-control.In this step, described target can be obtained in the way of using acquisition Windows standard control
Control is to judge.Specifically, the Windows standard control of offer in correlation technique can be provided
Acquisition instrument obtains described target widget, such as: AutoIt instrument, WinRunner instrument etc., this Shen
Please this is not particularly limited.
If successfully getting described target widget, then illustrate that described target widget is Windows standard control
Part, can test described control or debug.Without getting described target widget, then
Illustrate that described target widget is not Windows standard control, perform step 102.
Step 102, sends control by process communication and obtains the request software to the described target widget of installation,
The control property of software described in acquisition request is obtained according to described control for described software.
Judged result based on abovementioned steps 101, if described target widget is not Windows standard control
Part, i.e. cannot get described target widget, then at this by the way of obtaining Windows standard control
In step, and the software installing described target widget carries out the communication between process, to obtain described target control
Whole attributes of part.
In this step, control acquisition request can be sent by self-defining interaction protocol described to installing
The software of target widget.Described transmission control obtains request can include following two situation:
Situation one, described control obtain request in carry window handle, store path and storage lattice
Formula, then obtains request by described control and is sent to install the software of described target widget, such as: pass through
The interface that described software externally provides sends described control and obtains request.Wherein, described window handle is institute
State the window handle at target widget place.The software of described installation targets control obtains receiving described control
After taking request, obtain all control properties under the window that described window handle is corresponding, then according to described
All control properties are stored under described store path by storage format.
Specifically, described storage format can be file format, such as: xml form, csv form etc.,
Described store path can be file path.Described software is by all control property foundations under described window
Described file format generates file, and is stored under described file path by the file of generation, is then back to
Confirmation.
Situation two, described control obtain request in carry window handle, then by described control obtain please
Seek the software being sent to install described target widget.In this case, the soft of described target widget is installed
Part, after receiving the acquisition request of described control, obtains all controls under the window that described window handle is corresponding
Then the described all control properties got are returned by part attribute by the communication between process.
Step 103, obtains described from the control property of described software according to known target widget attribute
Whole attributes of target widget.
In the present embodiment, a control has generally included many attributes, such as: control title, control
Coordinate, control handle etc..Described known target widget attribute can be configured in advance by user, than
As: control ID etc., this is not particularly limited by the application.Based on abovementioned steps 102, described when installing
After the software of target widget obtains the control property of software described in acquisition request according to described control, in this step
In Zhou, described target widget can be obtained from described control property according to known target widget attribute
All attributes.
Specifically, obtaining two kinds of different situations of request for sending control in step 102, this step is also
Can distinguish the following two kinds situation:
Situation one, described control obtain request and include: window handle, store path and storage format.
In this case, all control properties under described window are stored in institute by the software of installation targets control
State under store path, and return confirmation by the communication between process.In this step, receiving
After described confirmation, all control properties under described window can be obtained from described store path,
Then described target is obtained according in the known target widget attribute all control properties from described window
Whole attributes of control.Such as: the software of installation targets control can be by all controls under described window
Attribute is stored as tabular form, and every a line storage has whole attributes of a control, at this in the list
In the case of, terminal can travel through this list, and usual described known target control property determines described target control
The row at part place, then obtains whole attributes of storage in this row, to obtain the whole of described target widget
Attribute.
Situation two, described control obtain request and include: window handle.In this case, described in installing
All control properties under described window are returned by the software of target widget.In this step, described in receiving
All control properties under the described window that process returns, then according to known target widget attribute from institute
State the whole attributes obtaining described target widget in all control properties under window.
Further, in another alternative embodiment of the application, it is provided with the timeout mechanism that control obtains.
Specifically, on the basis of the embodiment shown in Fig. 1, the acquisition methods of described Windows control property
Also include:
In step 104, it may be judged whether get whole attributes of described target widget within the default time.
In the present embodiment, can in step 103 according to known target widget attribute from described software
Control property in obtain described target widget the process of whole attributes carry out timing, and judge whether
Get whole attributes of described target widget in the time preset, obtain without within the default time
Get whole attributes of described target widget, then return step 102.Wherein, the described default time can
To be configured by developer, this is not particularly limited by the application.
Further, developer can also arrange the number of times retried, and i.e. resending control acquisition please
The number of times asked.When resending control and obtaining the number of times that the number of times arrival asked is preset, if also do not had
Get whole attributes of described target widget, then can return acquisition failure information.
Optionally, in another embodiment of the application, when step 101 judging, described target widget is not
During Windows standard control, can first judge whether the software of installation targets control is provided with its control
The acquisition mode of attribute, if it is not, perform step 102, sends control and obtains request.If it has,
Then can obtain mode by the control property that described software provides and obtain whole attributes of described target widget.
As an example it is assumed that the software of installation targets control is provided with Figure recognition mode, can pass according to mouse
The coordinate entered is to position target widget, then when determining that target widget is not Windows standard control, and can
To be obtained whole attributes of described target widget by described Figure recognition mode, this is not made spy by the application
Different restriction.
By above description it can be seen that the application is when obtaining target widget, can first judge target widget
Whether it is Windows standard control, and when target widget is not Windows standard control, passes through
Communication between process sends control and obtains the request software to the described target widget of installation, non-to obtain
Whole attributes of Windows standard control, thus realize the acquisition to different classes of control property.
Corresponding with the embodiment of the acquisition methods of the application Windows control property, the application also provides for
A kind of acquisition device of Windows control property.Device described herein can be realized by software,
Can also realize by the way of hardware or software and hardware combining.As a example by implemented in software, the application
The acquisition device of Windows control property, as the device on a logical meaning, is to be set by its place
Computer program instructions corresponding in nonvolatile memory is read operation shape in internal memory by standby processor
Become.
Refer to Fig. 2 and Fig. 3, the application provides the acquisition device 200 of a kind of Windows control property,
Can apply in terminal, described device 200 includes: judging unit 201, transmitting element 202, obtain
Take unit 203 and retransmission unit 204.
Wherein, described judging unit 201, it is judged that whether target widget is Windows standard control;
Described transmitting element 202, when described target widget is not Windows standard control, by entering
Cheng Tongxin sends control and obtains the request software to the described target widget of installation, for described software according to institute
State control and obtain the control property of software described in acquisition request;
Described acquiring unit 203, according to known target widget attribute from the control property of described software
Obtain whole attributes of described target widget.
Further, described control acquisition request includes: window handle, store path and storage format;
Described control obtains request, for all controls obtained in described software under this window for described software
Part attribute, and all control properties under described window are stored described storage road with described storage format
In footpath;
Described acquiring unit 203, specifically obtains all controls under described window from described store path
Attribute, and obtain described target according in the known target widget attribute all controls from described window
Whole attributes of control.
Further, described control acquisition request includes: window handle;
Described control obtains request, for all controls obtained in described software under this window for described software
Part attribute, and all control properties under described window are returned;
Described acquiring unit 203, concrete receives under the described window that described software is returned by process communication
All control properties, and obtain according in the known target widget attribute all controls from described window
Take whole attributes of described target widget.
Described retransmission unit 204, is not getting the whole of described target widget within the default time
During attribute, resend control and obtain request to the software installing described target widget.
Further, described retransmission unit 204, obtain the number of times arrival of request in advance when resending control
If number of times time, if the most not getting whole attributes of described target widget, then return obtain unsuccessfully
Information.
In said apparatus, the function of unit and the process that realizes of effect specifically refer in said method corresponding
Step realize process, do not repeat them here.
The foregoing is only the preferred embodiment of the application, not in order to limit the application, all at this
Within the spirit of application and principle, any modification, equivalent substitution and improvement etc. done, should be included in
Within the scope of the application protection.