[Qtp automated testing (iii)] Click any coordinates on the desktop

Source: Internet
Author: User

FunctionMouse_click (x, y)
DimDevice
SetDevice =Createobject("Mercury. devicereplay ")
Device. mousemove X, Y
Device. mouseclick X, Y, left_mouse_button
End Function

The mercury. devicereplay object is used to simulate Mouse clicking and moving, keyboard input, and so on. However, before using this object, you must ensure that the keyboard status is correct. For example, whether numlock is enabled, because devicereplay cannot detect the keyboard status.

Mercury. devicereplay includes the following methods:

1. sendstring Method
Send one or more keyboard buttons to the activated window: object. sendstring (STR)

2. keydown Method
Simulate the pressing and holding of a key: object. keydown (key)
Key: Numeric Value of the key.

3. keyup Method
Simulate releasing a pressed key through the keyboard: object. keyup (key)

4. presskey Method
Press the next button on the keyboard and immediately release: object. presskey (key)

5. pressnkeys Method
Simulate pressing the next button multiple times on the keyboard and immediately releasing: object. pressnkey (Key, n)
N: Repeated times

6. draganddrop Method
This operation is used to drag objects from one point to another: object. draganddrop (dragx, dragy, dropx, dropy, button)
The button values include:
Left_mouse_button = 0
Middle_mouse_button = 1
Right_mouse_button = 2

7. mouseclick Method
Click the object. mouseclick (X, Y, button) with the left or right mouse button at the specified screen position)

8. mousedbclick Method
Double-click object. mousedblclick (X, Y, button)

9. mousedown Method
Press the Left or Right button at the specified position on the screen and keep the following status: object. mousedown (X, Y, button)

10. mouseup Method
The mouse button used to release the previously executed mousedown method: object. mousedown (X, Y, button)

11. mousemove Method
Used to simulate mouse movement: object. mousemove (x, y)

12. setsynchronizationtimeout Method
Set a new synchronization timeout value: object. setsynchronizationtimeout (nsynctimeout, is_sec)
Nsynctimeout: Specifies the synchronization timeout value.
Is_sec: Specifies whether the set time value is in seconds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.