rakma Posted April 9, 2014 Posted April 9, 2014 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 expandcollapse popupImports 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). .
Richard Robertson Posted April 10, 2014 Posted April 10, 2014 Either you imported the function incorrectly or there was an exception thrown that you aren't mentioning.
rakma Posted April 10, 2014 Author Posted April 10, 2014 (edited) I posted all i got. i can upload the project if needed https://mega.co.nz/#!REh1FQaR!kl8Q0z8FcGSQ5Lror7_-Se4U5edTYKI4Jyc8JyuPGhk Edited April 10, 2014 by rakma
Richard Robertson Posted April 11, 2014 Posted April 11, 2014 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.
rakma Posted April 11, 2014 Author Posted April 11, 2014 (edited) btw im running Windows 7 x64 Ultimate Nothing happend Edited April 11, 2014 by rakma
Richard Robertson Posted April 11, 2014 Posted April 11, 2014 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.
rakma Posted April 11, 2014 Author Posted April 11, 2014 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 ?
Richard Robertson Posted April 12, 2014 Posted April 12, 2014 (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 April 12, 2014 by Richard Robertson
rakma Posted April 12, 2014 Author Posted April 12, 2014 (edited) Okey so i change it and still nothing happens -.- And the config Edited April 12, 2014 by rakma
Richard Robertson Posted April 15, 2014 Posted April 15, 2014 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.
rakma Posted April 15, 2014 Author Posted April 15, 2014 i added the file to the new folder and still nothing happens!
Richard Robertson Posted April 16, 2014 Posted April 16, 2014 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?
rakma Posted April 17, 2014 Author Posted April 17, 2014 '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).
Richard Robertson Posted April 18, 2014 Posted April 18, 2014 So when you click the button to run the code, does it still exit?
Richard Robertson Posted April 20, 2014 Posted April 20, 2014 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.
ZxPwd Posted August 1, 2017 Posted August 1, 2017 Had anybody been able to resolve this issue? I'm also having this problem.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now