=sinister= Posted January 5, 2009 Share Posted January 5, 2009 I need some help calling the dll. The main problem is that its return type is TrueLocation and I have no clue what that is ?? public TrueLocation convertCoordinates(int zoneID, double wowX, double wowY) ^ Here is the method. I tried this but it keeps returning 0: $Dll = DllOpen("./CoordsConvert.dll") $Test = DllCall($Dll, "TrueLocation", "convertCoordinates", "int", 3520, "double", 32.91302, "double", 33.69269) MsgBox(0, "Test", $Test) DllClose($Dll) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 5, 2009 Moderators Share Posted January 5, 2009 Might take a trip to the help file and see if dllcall allows for the "double" type. ... might try "float" instead. You also seem to forget that $Test will be an array, so of course the value will be blank calling it as a plain variable. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zinthose Posted January 5, 2009 Share Posted January 5, 2009 (edited) I need some help calling the dll. The main problem is that its return type is TrueLocation and I have no clue what that is ?? public TrueLocation convertCoordinates(int zoneID, double wowX, double wowY) ^ Here is the method. I tried this but it keeps returning 0: $Dll = DllOpen("./CoordsConvert.dll") $Test = DllCall($Dll, "TrueLocation", "convertCoordinates", "int", 3520, "double", 32.91302, "double", 33.69269) MsgBox(0, "Test", $Test) DllClose($Dll) More information is needed as the issue is with the CoordsConvert.dll. I have no knowledge of this DLL and can't assist without having access to the dll's api documentation. Edited January 5, 2009 by Zinthose --- TTFN Link to comment Share on other sites More sharing options...
=sinister= Posted January 5, 2009 Author Share Posted January 5, 2009 (edited) Hrm, but setting it as if it is an array leads to a "Subscript used with non-Array variable." --edit-- here is the method source, but it's not the full dll (duh): Written in C# public TrueLocation convertCoordinates(int zoneID, double wowX, double wowY) { foreach (Zone z in zonePack) { if (z.getZoneID() == zoneID) { double pctWidthValue = z.getWidth() / 100; double pctHeightValue = z.getHeight() / 100; double xValue = z.getUpperLeftX() - (pctWidthValue * wowX); double yValue = z.getUpperLeftY() - (pctHeightValue * wowY); return new TrueLocation(xValue, yValue); } } return null; } Edited January 5, 2009 by =sinister= Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 5, 2009 Moderators Share Posted January 5, 2009 Hrm, but setting it as if it is an array leads to a "Subscript used with non-Array variable." --edit-- here is the method source, but it's not the full dll (duh): Written in C# public TrueLocation convertCoordinates(int zoneID, double wowX, double wowY) { foreach (Zone z in zonePack) { if (z.getZoneID() == zoneID) { double pctWidthValue = z.getWidth() / 100; double pctHeightValue = z.getHeight() / 100; double xValue = z.getUpperLeftX() - (pctWidthValue * wowX); double yValue = z.getUpperLeftY() - (pctHeightValue * wowY); return new TrueLocation(xValue, yValue); } } return null; }You need to know what TrueLocation's return value is. That's a separate function all together, and you're using it as a return type. Seriously... You need to only use the types of returns allowed by autoit, not what other functions tell you they are. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
=sinister= Posted January 5, 2009 Author Share Posted January 5, 2009 Sorry, I never really looked into DllCall too much, and I don't know too much C#. Here is the class: public class TrueLocation { public double X; public double Y; public TrueLocation(double _X, double _Y) { X = _X; Y = _Y; } public String getPPString() { String output; String temp = Convert.ToString(this.Y); if (temp.IndexOf(".") != -1 && (temp.Length >= (temp.IndexOf(".") + 3))) { temp = temp.Remove(temp.IndexOf(".") + 2); } // adding to final output output = "[" + temp + ", "; temp = Convert.ToString(this.X); if (temp.IndexOf(".") != -1 && (temp.Length >= (temp.IndexOf(".") + 3))) { temp = temp.Remove(temp.IndexOf(".") + 2); } //adding to final output output += temp + "]"; return output; } } The only thing is, TrueLocation doesn't have a return?? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 6, 2009 Moderators Share Posted January 6, 2009 (edited) That really looks like horrible coding. Try this:$h_dll = DllOpen(".\CoordsConvert.dll") If $h_dll <> -1 Then $a_test = DllCall($Dll, "str", "convertCoordinates", "int", 3520, "float", 32.91302, "float", 33.69269) If Not @error Then MsgBox(0, "Testing", $a_test[0]) Else MsgBox(16, "Error", "Error calling Dll") EndIf DllClose($Dll) Else MsgBox(16, "Error", "Error opening Dll") EndIf Edit: That's probably wrong too... I don't see a return value to be honest... are you sure convertCoordinates isn't just for global setting vars within the dll itself? That's what it looks like to me. Edited January 6, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
=sinister= Posted January 6, 2009 Author Share Posted January 6, 2009 (edited) Well it's a good thing I didn't make it The dll is used by a application written in C# too, but I can't find where the dll is used in the application. --edit-- (There is an error calling the dll using your script) Edited January 6, 2009 by =sinister= Link to comment Share on other sites More sharing options...
monoceres Posted January 6, 2009 Share Posted January 6, 2009 Edit:That's probably wrong too... I don't see a return value to be honest... are you sure convertCoordinates isn't just for global setting vars within the dll itself? That's what it looks like to me.The return type is the TrueLocation class. Simple as that.However it gets awfully complicated when you're trying to make it work in AutoIt.First because it's a C# class and secondly because AutoIt can't return anything else than the standard types from a function in a dll. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
=sinister= Posted January 6, 2009 Author Share Posted January 6, 2009 (edited) Ok what if I add a return value to it and compile it? Edited January 6, 2009 by =sinister= Link to comment Share on other sites More sharing options...
monoceres Posted January 6, 2009 Share Posted January 6, 2009 Ok what if I add a return value to it and compile it?Yeah, since it seems that you want to get the x and y values you can just return a pointer to a struct that has a x and y member. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
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