Jump to content

C# ActiveX and Threading Issues


Aki999
 Share

Recommended Posts

I have the following code sample:

AutoItX3 autIt = new AutoItX3();

autIt.AutoItSetOption("WinTitleMatchMode", 2);

autIt.Sleep(500);

autIt.WinWait("MyTitle", "", 0);

This works perfectly if I execute this code in an own thread. But if I execute from within the WindowMessage thread (for example within the button click event) it does not find the dialog with MyTitle.

Ok I have a workaround - just start by a thread.

But then I have another issue. I want to log the AutoIt executions on to my gui. So within the thread a I have to do a BeginInvoke and assign the log text to the control which shows the log. After the BeginInvoke call I have trouble again with AutoItX3.

AutoItX3 autIt = new AutoItX3();

autIt.AutoItSetOption("WinTitleMatchMode", 2);

MyTextBox.BeginInvoke(new SetMyTextDelegate(SetMyText), "Click OK");

autIt.Sleep(500);

autIt.WinWait("MyTitle", "", 0);

autIt.WinActivate("MyTitle");

autIt.Sleep(500);

string result = autIt.ControlCommand("MyTitle", "", "[TEXT:&OK]", "IsEnabled", "");

Without the BeginInvoke call result is "1" with the call it is "0".

My OS: Windows 7 64-Bit.

Do you have any ideas how to solve this problem?

Thank you!

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...