Sign in to follow this  
Followers 0
SueImWeb

@jcddcjjcd - C# youse of the dll

5 posts in this topic

#1 ·  Posted (edited)

Hello,

first of all I want to say THANK YOU for your very helpful article! :idea:

Would you please additionally help me understanding some parameters?

//AU3_API void WINAPI AU3_ControlGetHandle(const char *szTitle, /*[in,defaultvalue("")]*/const char *szText
//, const char *szControl, char *szRetText, int nBufSize);
[DllImport("AutoItX3.dll", SetLastError = true, CharSet = CharSet.Auto)]
static public extern void AU3_ControlGetHandle([MarshalAs(UnmanagedType.LPStr)] string Title
, [MarshalAs(UnmanagedType.LPStr)] string Text, [MarshalAs(UnmanagedType.LPStr)] string Control
, byte[] RetText, int BufSize);

Using the registered version I do only need 3 parameters, the dll expects 5.

What do I have to put in for byte[] RetText and int BufSize ? :P

Greetings from Germany

Sue

Ups.....sorry for mistyping the word use in the headline.... :(

Edited by SueImWeb

Share this post


Link to post
Share on other sites



Sue.

Try this:

string Title = "WhateverWorks";

string Text = "WhateverWorks";

string TheControlID = "TheControlID";

byte[] RetText = new byte[50]; //a number big enought to hold result, trailing bytes will be 0

AutoItX3Declarations.AU3_ControlGetHandle(Title, Text, TheControlID, RetText, RetText.Length);

//may need to convert back to a string or int

string TheControlIDasString = System.Text.Encoding.ASCII.GetString(RetText).TrimEnd('\0');

Regards,

John.

Share this post


Link to post
Share on other sites

I just tested the above and it works.

Open up Notepad and then add a button to your application thus:

private void btnTest_Click(object sender, EventArgs e)

{

string Title = "Untitled - Notepad";

string Text = "";

string TheControlID = "Edit1";

byte[] RetText = new byte[50]; //a number big enought to hold result, trailing bytes will be 0

AutoItX3Declarations.AU3_ControlGetHandle(Title, Text, TheControlID, RetText, RetText.Length);

//may need to convert back to a string or int

string TheControlIDasString = System.Text.Encoding.ASCII.GetString(RetText).TrimEnd('\0');

MessageBox.Show(TheControlIDasString);

}

Regards,

John.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you very much, it works.

But unfortunately I have the same problem as with using the registered version of AutoItX.

The method returns an empty string instead of the control's handle.

If I only knew what's the reason....

Until a few days ago everything worked without any problem.

Regards

Sue

Edited by SueImWeb

Share this post


Link to post
Share on other sites

Sue.

Use the AU3Info.exe tool on your target to get some ideas as to what to put in the first two fields. It can take quite a bit of trial and error to get values that work consistantly and it varies according to the control. Some controls are strangely implemented and won't yeild at all.

Good luck.

Regards,

John.

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