How to draw a rectangle, ellipse, circle and polygon using mouse press and mouse release or mouse drag in Squish.
Asked
Active
Viewed 175 times
1 Answers
1
You can do this using the functions mousePress
, mouseMove
and mouseRelease
.
You could describe all those shapes as a sequence of points, e.g. clockwise. So a rectangle at position 150/200 which is 300 pixels wide and 100 pixels high might be described as
rectangle = [(150,200), (450,200), (450,300), (150, 300)]
You could then feed this list of points to a generic function 'drawShape' or so which draws the shape, something like this (in Python, but the same thing can be done in any other of the scripting languages supported by Squish):
def drawShape(shape):
firstPoint = shape[0]
# Press mouse button at first position
mousePress(firstPoint[0], firstPoint[1], MouseButton.PrimaryButton)
# Call mouseMove repeatedly for all subsequent positions
for x in range(1, len(shape)):
mouseMove(shape[x][0], shape[x][1])
# Close the shape by connecting last with the first position
mouseMove(firstPoint[0], firstPoint[1])
# Release mouse button to finish drawing
mouseRelease()

Frerich Raabe
- 90,689
- 19
- 115
- 207
-
Thanks a lot for the response. It was very helpful – pigsrule Jul 18 '16 at 15:19