Hy Guys.
I want to use ImageSearch in VS(2008 or 2010) C#
I have found this, but this is written for VB:
[Only registered and activated users can see links. Click Here To Register...]
But i have found this code(below) with google, but this throw me an exception, when i "click" on button, and try to search an image: "System.ExecutionEngineException"
If anybody have a solution, please share with me, thanks.
Any help would be appreciated.
I want to use ImageSearch in VS(2008 or 2010) C#
I have found this, but this is written for VB:
[Only registered and activated users can see links. Click Here To Register...]
But i have found this code(below) with google, but this throw me an exception, when i "click" on button, and try to search an image: "System.ExecutionEngineException"
If anybody have a solution, please share with me, thanks.
Any help would be appreciated.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ImageSearch
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int[] img = IMGSearch.FindImage(0, 0, 1366, 768, "C:\\s.bmp");
if (img[0] != 0)
{
MessageBox.Show("Img found", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
}
}
public static class IMGSearch
{
//[DllImport("ImageSearchDLL.dll", EntryPoint="ImageSearch")]
[DllImport("ImageSearchDLL.dll")]
public static extern string ImageSearch(int x1, int y1, int x2, int y2, string str);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main2()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
public static int[] FindImage(int L, int T, int R, int B, string F)
{
int[] aRTN = new int[5];
//MessageBox.Show(R.ToString());
string rtn = ImageSearch(L, T, R, B, F);
//MessageBox.Show(rtn);
if (rtn == "0")
{
aRTN[0] = 0;
return aRTN;
}
else
{
string[] coords = rtn.Split('|'); //split return value of imagesearch into array
//int[] aRTN = new int[5]; //declare int array with enough elements
aRTN[0] = int.Parse(coords[0]); //convert the string values into ints
aRTN[1] = int.Parse(coords[1]);
aRTN[2] = int.Parse(coords[2]);
aRTN[3] = int.Parse(coords[3]);
aRTN[4] = int.Parse(coords[4]);
return aRTN;
}
}
}
}