実行するとFirefoxを起動し、ウィンドウのプロセスとハンドルを取得し、Firefoxのスクリーンキャプチャを実行してディスク(temp.bmp)に保存し、ProcessGetWindowを呼び出すWindowsフォームアプリがあります。私は基本的にMODIでMiSelectRectsを使用して、探している単語の周りの長方形をキャプチャし、次にAutoITを使用して単語をマウスクリックします。
問題は、私の座標が上から約10ピクセルずれていることです。
何が間違っているのでしょうか?これが処理を行う関数です。AutoIT処理をコメントアウトしました。実際の座標を表示するために、MessageBoxを使用してデバッグしています。次に、AutoITのウィンドウ情報ツールで確認しましたが、間違いなくオフになっています...何か間違ったことをしているのですか、それともMODIに問題がありますか?
public void ProcessGetWindow(Bitmap image)
{
Document modiDoc = null;
MiDocSearch modiSearch = null;
IMiSelectableItem modiTextSel = null;
MiSelectRects modiSelectRects = null;
MiSelectRect modiSelectRect = null;
MiRects modiRects = null;
int intSelInfoPN;
string intSelInfoTop;
int intSelInfoBottom;
string intSelInfoLeft;
int intSelInfoRight;
// Load an existing image file.
modiDoc = new Document();
modiDoc.Create(@"C:\\temp.bmp");
// Perform OCR.
modiDoc.Images[0].OCR();
// Search for the selected word.
modiSearch = new MiDocSearch();
modiSearch.Initialize(modiDoc, "Click Me", 0, 0, false, false);
modiSearch.Search(null, ref modiTextSel);
try
{
modiSelectRects = modiTextSel.GetSelectRects();
}
catch (COMException)
{
MessageBox.Show("Me thinks that the OCR didn't work right!");
}
foreach (MiSelectRect mr in modiSelectRects)
{
//intSelInfoPN = mr.PageNumber.ToString();
intSelInfoTop = mr.Top.ToString();
//intSelInfoBottom = mr.Bottom;
intSelInfoLeft = mr.Left.ToString();
//intSelInfoRight = mr.Right;
/*AutoItX3 auto = new AutoItX3();
auto.AutoItSetOption("MouseCoordMode", 2);
auto.MouseClick("", intSelInfoLeft, intSelInfoTop, 1, 80);*/
MessageBox.Show("Coordinates: " + intSelInfoLeft + ", " + intSelInfoTop, "Coordinates", MessageBoxButtons.OK);
}
//string textResult = modiTextSel.Text;
//MessageBox.Show(textResult, "Search Results", MessageBoxButtons.OK);
// Close this dialog.
Application.Exit();
}