Jump to content

Can't get AutoItX to work using it by DLLImport (C#)


SueImWeb
 Share

Recommended Posts

Hello,

since yesterday I am trying to use AutoItX by DllImport for the umpteenth time - no success again.

It's the same like before, registering the dll and referencing it, there are no problems.

Using my old AutoIt.dll from 2002 by DllImport does also work.

But using AutoItX V3 by DllImport...nothing happens.

Would someone please tell me, what's wrong?

This is what I do:

1. Stored the AutoItX3.dll into the program folder of my C# Project(tried the system32 folder also).

2. Created a class like this one or that one and named it "AutoItX".

3. Tried to call different methods.

...none of them seem to work...

Sue

Link to comment
Share on other sites

Hello Richard,

according to the postings I linked to, I used the type of string.

But a few month ago (also with version 3) I also tried it with StringBuilder.

The first example shows it like this:

[DllImport(dllpath, SetLastError = true, CharSet = CharSet.Auto)]
private static extern int AU3_WinExists([MarshalAs(UnmanagedType.LPStr)]string Title, [MarshalAs(UnmanagedType.LPStr)]string Text);

public static int WinExists(string vsTitle, string vsText) 
{
   return AU3_WinExists(vsTitle, vsText);
}

Sue

Link to comment
Share on other sites

Thank you very much ... that works. :D

But there is one thing left. Using the dll this way I am not able to look for a window by its handle.

I tried it in different ways (got the handle through API's GetForegroundWindow method):

AU3_WinExists("[HANDLE:" + hWnd.toString() + "]", "");
AU3_WinExists("handle=" + hWnd.toString(), "");
AU3_WinExists(hWnd.toString(), "");

Every call returns 0.

Do you have any idea?

Sue

Edited by SueImWeb
Link to comment
Share on other sites

That's very nice, but afaik C# does only support the SendKeys method.

I need to send keystrokes to different (text control) windows outside of my application,

e. g. CTRL + SHIFT + RIGHT which marks one word to the right.

Those windows can be a Word document, a new email, a textbox within another application etc.

And this has to work also if the regarding window is not the active (foreground) window and if another window has the same title.

Therefore I need to address the window by it's handle.

Link to comment
Share on other sites

I do understand that I am able to call API functions from C# too.

What I primarily was looking for was an ability of sending keystrokes (combinations) to not active windows.

Trying to find a solution I played with .NET SendKeys and API methods SendInput and PostMessage (with WM_KEYDOWN, WM_CHAR etc).

But I had to end up with the information, that this is not possible because you can't simulate holding a key pressed respectivly simulate key combinations with WM_KEYDOWN.

Besides SendInput and keybd_event are sent to the active window and WM_CHAR does only support ascii codes or ALT + 1 ascii key.

So for the first I changed my application code to send messages only to active windows.

Because I am less of time and using AutoItX for that is more comfortable than using API methods directly I implemented it.

My next step is to learn how to register hotkeys.

I hope WM_HOTKEY could be the solution for my problem.

Any other idea?

Sue

Edited by SueImWeb
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...