Iäm trying to use the ImageSearchDLL.dll file made in autoit but in vb.net, i have no errors in my code but when i press the button the application terminates itself and nothing happens. Why ?
Both the window and the image exists under the app is running. the dll files i in the bin folder at the space location as the application.exe
Both the window and the image exists under the app is running. the dll files i in the bin folder at the space location as the application.exe
Quote:
Imports System.Runtime.InteropServices
Imports System
Imports AutoItX3Lib
Public Class Form1
<DllImport("ImageSearchDLL.dll", EntryPoint:="ImageSearch")> Public Shared Function ImageSearch(ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal str As String) As String
End Function
Public Shared Function FindImage(ByVal L As Integer, ByVal T As Integer, ByVal R As Integer, ByVal B As Integer, ByVal F As String) As Integer()
Dim ARTN As Integer() = New Integer(4) {}
'MessageBox.Show(R.ToString());
Dim rtn As String = ImageSearch(L, T, R, B, F)
' MessageBox.Show(rtn)
If rtn = "0" Then
aRTN(0) = 0
Return aRTN
Else
Dim coords As String() = rtn.Split("|"c)
'split return value of imagesearch into array
'int[] aRTN = new int[5]; //declare int array with enough elements
aRTN(0) = Integer.Parse(coords(0))
'convert the string values into ints
aRTN(1) = Integer.Parse(coords(1))
aRTN(2) = Integer.Parse(coords(2))
aRTN(3) = Integer.Parse(coords(3))
aRTN(4) = Integer.Parse(coords(4))
Return aRTN
End If
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim x1 As Integer
Dim y1 As Integer
Dim res() As Integer = FindImage(x1, y1, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, "C:\launcher.play.jpg")
Dim s As New AutoItX3Lib.AutoItX3
s.MouseClick("LEFT", res(1), res(2))
End Sub
End Class