# OnClick Script

The OnClick script will be used in conjunction with the Acquire Image Button on the Page, and will be used to run the Image File Device, and subsequently, the Task.

1. Right-click on the Acquire Image button and select Scripts | On Mouse Click.

2. Enter the following script:

       $Tasks.BufferImage.Run();
       $Tasks.CopyRegion.Run();

3. In Properties, add using statements to the Code property.

4. Press the drop-down button, and in the blank text field, enter "Cognex.VisionPro" and "Cognex.VisionPro.Display".

5. Press the browse button of the References property, using the Script References dialog, from the Discovered References pane, add Cognex.VisionPro.dll, Cognex.VisionPro.Core.dll and Cognex.VisionPro.Display.Controls.dll to the Local References, and press the Accept button.

6. Press the Compile button to ensure the script correctly compiles.