Sign in to follow this  
Followers 0
rakma

ImaheSearchDll terminates itself why ?

17 posts in this topic

Im trying to use the ImageSearchDll file from autoit on vb.net the problem is that when it searches it terminate itself and nothing happens. At this line (Dim rtn As String = ImageSearch(L, T, R, B, F) ' <- nothing happens here) nothing happens and i have tryed debugging with msgboxes and nothing happens. I have the image and the dll files and no errors in the code. HELP me plz

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(L.ToString() & " - " & T.ToString() & " - " & R.ToString() & " - " & B.ToString() & " - " & F.ToString())
        Dim rtn As String = ImageSearch(L, T, R, B, F) ' <- nothing happens here
        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

VB.NET is not telling me why the app terminates

 

'Image Search.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:UsersRakmaDocumentsVisual Studio 2012ProjectsImage SearchImage SearchbinDebugImage Search.exe', Symbols loaded.

'Image Search.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Runtime.Remotingv4.0_4.0.0.0__b77a5c561934e089System.Runtime.Remoting.dll'
The program '[3160] Image Search.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[3160] Image Search.vshost.exe: Managed (v4.0.30319)' has exited with code 1073741855 (0x4000001f).

.

Share this post


Link to post
Share on other sites



Either you imported the function incorrectly or there was an exception thrown that you aren't mentioning.

Share this post


Link to post
Share on other sites

The project ran fine for me with the exception that it clicked in the upper left corner of the screen instead of what I'm guessing was supposed to be the start button.

Try this. Click the space just to the left of the line numbers in the code editor on the line that shows "Public Shared Function FindImage(L As Integer, T As Integer, R As Integer, B As Integer, F As String) As Integer()". A red dot should appear. Run the program from the editor and it should stop and move into the editor again when you click the button. Press F11 to move one line of code at a time and put your mouse over the variables to see if they contain the values you expect them to contain. This will also show you the exact point in which the project stops running.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

btw im running Windows 7 x64 Ultimate 

OOUxCLm.png

Nothing happend 

Edited by rakma

Share this post


Link to post
Share on other sites

Yes, you've stepped into debug mode, and now you need to hit F11 (once for each line) to step through each line of code to see what's happening.

Share this post


Link to post
Share on other sites

Yes, you've stepped into debug mode, and now you need to hit F11 (once for each line) to step through each line of code to see what's happening.

i Found nothing, is there a way that i can chat with you over skype ?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Wait I think I just figured it out. You're running Windows 64 bit and I'm running Windows 32 bit. The dll is 32 bit, and that's why it didn't work.

Your project is set to run in 64 bit on your 64 bit Windows. If you change it to compile to 32 bit, it should work.

I don't have the same version of Visual Studio as you, so I can't walk you through how to change it, but this is the reason it's not working. You'll be looking for something labeled AnyCPU, and you need to change that to 32 bit or x86, however it's labeled.

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Okey so i change it and still nothing happens -.-

 

And the config

gUglVg8.png

Edited by rakma

Share this post


Link to post
Share on other sites

If you notice, it threw a DllNotFoundException. Maybe you need to put the ImageSearch.dll back in the folder since you changed the build settings.

Share this post


Link to post
Share on other sites

i added the file to the new folder and still nothing happens!

Share this post


Link to post
Share on other sites

Look in the gray box at the bottom of the screen from the last picture you posted. When you run it now, does it still say System.DllNotFoundException occured in test.exe?

Share this post


Link to post
Share on other sites

 

'test.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:UsersRakmaDocumentsVisual Studio 2012Projectstesttestbinx86Debugtest.exe', Symbols loaded.

'test.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Runtime.Remotingv4.0_4.0.0.0__b77a5c561934e089System.Runtime.Remoting.dll'
'test.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Configurationv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[5296] test.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[5296] test.vshost.exe: Managed (v4.0.30319)' has exited with code 1073741855 (0x4000001f).

Share this post


Link to post
Share on other sites

So when you click the button to run the code, does it still exit?

Share this post


Link to post
Share on other sites

yes, the app just terminates it self  

Share this post


Link to post
Share on other sites

Well I can't see what's going on without sitting at your computer with you so I can poke at the program. Like I said, it worked fine for me.

Share this post


Link to post
Share on other sites

#17 ·  Posted

Had anybody been able to resolve this issue? I'm also having this problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0