mouseDown and mouseUp commands

In my testing I need to test all the button states mouseDown and MouseUp. In order to do this I need to be able to take a snapshot of a button before the mouse button is released. Is this possible with Eggplant? What are the SenseTalk commands?

Thanks!

Sure, you can do this. Do you want to capture the images from Capture Mode for comparison during the script run? Or do you want to capture the screen image during the script run?

I’m going to assume in this discussion that your buttons don’t trigger their target actions until you release the mouse button – if that’s not the case then I think you’re asking Eggplant to do something the user can’t, which is usually not possible.

If you just want to do this in Capture mode then do this: In Live mode, click the mouse down on your button and then hit the Command key to toggle Eggplant into Capture mode. Now you can capture the image of the depressed button. When you return to Live mode the remote mouse will still be in a “mouse button down” state – you may need to click once to release it.

If you wanted to do this in your script Eggplant includes MouseButtonDown and MouseButtonUp commands. The trick is whether you want to capture the whole screen, or just the button. The simple version just captures the whole screen:

MoveTo "MyTargetButton"
MouseButtonDown 1 // "1" represents the left button on a 3-button mouse
CaptureScreen
MouseButtonUp 1

If you want to capture just the area covered by your search image then you’d need to do something like this:

MoveTo "MyTargetButton"
MouseButtonDown 1 // "1" represents the left button on a 3-button mouse
put ImageFoundLocation() - the hotspot of imageInfo("MyTargetButton") into upperLeftCorner // this assumes the hotspot is in the middle of the image
put ImageFoundLocation() + the hotspot of ImageInfo("MyTargetButton") into lowerRightCorner
CaptureScreen "ButtonDown", (upperLeftCorner, lowerRightCorner)
MouseButtonUp 1

I’m not going to try to explain all of that in this post, but let me know if you have any specific questions and I’ll try to clarify.

2/24/2004

A colleague pointed out that the above code could be improved a bit by changing the fourth line to the following:

put ImageFoundLocation() + the [b]size[/b] of ImageInfo("MyTargetButton") into lowerRightCorner

This removes the dependency that the hotspot be located in the center of the image and so it will work with any image.