Jump to content
Sign in to follow this  
trancexx

Access AutoIt

Recommended Posts

Yes, the server script is running and you are right, sp_OACreate is more like ObjCreate from AutoIt and creates an instance of an object instead to create a reference to the existing object from AutoIt Server. I don't know if SQL Server have something similar to ObjGet. It would be such great way to access AutoIt with so many possibilities.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

I know this is an old thread but I came across it and this could be a HUGE help to what I'm doing, except I can't quite get it working. I want to automate a windows application that uses wpf and winforms so I was using CUIAutomation2.au3 by junkew and that worked great. Now I have a need to integrate this into another testing tool that can use Java, Python, or C#. Our dev team uses C# so I was leaning in that direction.

Anyways, using this com server approach I was able to launch our application but when I tried to call functions like GetRootElement and FindFirst, I couldn't quite figure out the syntax. Here's a code sample:

dynamic myAu3Object = Marshal.BindToMoniker("AutoIt.Application");
            
            // Create UI Automation object
            dynamic oUIAutomation = myAu3Object.Call("ObjCreateInterface", "$sCLSID_CUIAutomation", "$sIID_IUIAutomation", "$dtagIUIAutomation");
            
            // Get Desktop element
            dynamic pDesktop = null;
            myAu3Object.Call("oUIAutomation.GetRootElement", pDesktop);
            var oDesktop = myAu3Object.Call("ObjCreateInterface", pDesktop, "$sIID_IUIAutomationElement", "$dtagIUIAutomationElement");

I don't believe pDesktop gets filled properly b/c if I write out oDesktop to the console it always returns '1'. I've tried a bunch of variations of the syntax but can't quite wrap my head around the proper way to do it, or if it's even possible.

I'm still learning AutoIt and have very little knowledge of C# so I'm a bit over my head but would dive right in if I knew it could work. It looks like both of those functions set the value of a variable sent to them but I'm not sure I have access to those values back in C#. Can anyone confirm that?

If more details are needed please let me know. My alternative is to create a bunch of small au3 scripts, convert them to exe files and call them externally but I was hoping to avoid that if I could. Any help would be greatly appreciated!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...