- Code: Select all
window.MouseClick(int iButton, int ix, int iy, int iType);
window.MouseClick(int iButton, int ix, int iy, int iType);
# 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);
Users browsing this forum: No registered users and 7 guests