Hello-
If you know what the image is ahead of time, you can use Phantom's bitmap functions to find an image and then click on it. I have included some sample code below to do this:
- Code: Select all
# Before running this, open the Phantom Target application, then:
# 1. Check Options->MessageBox->Controls (to verify the mouse click)
# 2. Select Controls->PushButton
# Uncomment to create the search bitmap
#bitmap b = MainWin("Button Dialog", "#32770").MainWin("GBUTTON", "Button").CaptureBitmap();
#b.Save("search.bmp");
#return;
# Function to click on an image
function void ClickImage(window w, bitmap b){
# Capture the bitmap of the target window
bitmap temp = w.CaptureBitmap();
# Get the height of the target window bitmap
int wH = temp.GetHeight();
# Get dimensions of the search bitmap
int bH = b.GetHeight();
int bW = b.GetWidth();
# Variables to hold the X, Y location of the bitmap
int X;
int Y;
# Search the window bitmap for the desired bitmap
if(temp.Find(X, Y, b)){
# Click on the center of the bitmap if found
w.MouseClick(0,X+bW/2,wH-(Y+bH/2),0);
disp("Image found and clicked");
}else{
# Throw an error if not found
exception e;
e.SetError("Could not find image");
e.throw();
}
}
# An example of how to use ClickImage:
bitmap bSearch;
bSearch.Load("search.bmp");
window wSearch = MainWin("Button Dialog", "#32770");
ClickImage(wSearch, bSearch);
This code finds a bitmap in the Phantom Target application PushButton window, and then clicks the center of the bitmap. A message should appear from the Phantom Target saying the button was clicked. You should be able to copy and paste the function directly into your script. Note that, if possible, you should use Phantom to capture the bitmap ahead of time to ensure it is in the correct format. The help documentation has more information on using bitmaps.
I hope this helps!
-John