Whats up and welcome,

On this put up, we’re going to speak about how we will automate a part of the home windows desktop surroundings utilizing AutoItX.

What’s AutoItX?

Earlier than we will speak about AutoItX first we have to discuss a little bit bit about AutoIt.

AutoIt as we see from the outline on their web page and their wiki is a scripting software for desktop automation. I can’t go into the small print because it’s an excessive amount of to cowl and the wiki appears to be fairly complete, simply know that it’s the foundation of what we’re going to speak about. One factor I wish to point out is that once I was working as a sport tester, there was a really good man who automated our deployment system utilizing AutoIt, so that you could be amazed at what could be achieved with correct automation within the office.

Additionally in case you need assistance with simply AutoIt, they’ve discussion board for problem-solving points, and naturally the StackOverflow group.

Okay, I do know what AutoIt is, what’s AutoItX?

Now that we bought the AutoIt facet of issues cleared at a really rudimentary stage, AutoItX is a C# wrapper over the AutoIt engine that comes as a nuget bundle with a .Web meeting and the native AutoIt dll inside. On the time of this writing, the newest model is launched on the twenty fourth of January 2019 and has a complete obtain variety of 396,649 which from my perspective it means it’s considerably battle-proven to be steady.

One thing to level out is that though it’s a wrapper over the engine, the wrapper doesn’t function the complete functionalities that the native AutoIt has like establishing hotkeys and such, however that is one thing we are going to take a look at sooner or later. However if you wish to use options not out there in C# however nonetheless wish to use C#, an thought can be to jot down the script in AutoIt, compile it, after which simply launch it from C#; After all, the disadvantage from that is the upkeep value of debugging.

See also  Silent Hunter 5 Battle of the Atlantic Crack Codex Free Download

Find out how to set up AutoItX

Since AutoItX comes as nuget bundle, including it to your challenge is simple sufficient, simply seek for it and add it, however there’s a catch as a result of it’s utilizing the native dll, we additionally must have both the AutoItX3.dll (for 32-bit purposes) or the AutoItX3_x64.dll (for the 64-bit purposes) current in our output folder so maintain that in thoughts as a result of it would come up within the demo we’re about to do.

Demo: Automating cookie clicker

For this demo we shall be utilizing the next:

  • LinqPad 6 – I desire (as talked about in earlier posts) to make use of LinqPad as a scratch pad, to prototype functionalities in it. I additionally assume (although I didn’t affirm) that it might solely work easily with LinqPad 6 model as this model lets you embrace information within the output with out numerous plumbing code to get the native assemblies to repeat to the output folder. One other factor to notice is that nuget is a paid function for LinqPad. Should you don’t have a paid model, then it is advisable manually obtain the nuget bundle, unpack it after which reference the assemblies and dlls, or use Visible Studio.
  • Cookie Clicker – This shall be our gateway into enjoying round with automation
  • The AutoItX nuget bundle – from which we may also reference in LinqPad 6 the native dll for it to work, this shouldn’t be an issue for Visible Studio for the reason that bundle incorporates a .targets file for construct, although I admit, I’ve but to make use of it in Visible Studio, but when any points happen then the identical strategy as for LinqPad would work.

Step 1: Referencing the assemblies and libraries

Open LinqPad 6 and seek for the nuget bundle AutoItX for .NET.

After downloading the nuget bundle and including the namespace for it, click on on the Add / Browse… button from the Question Properties window (needs to be already there so as to add the bundle if not the default key to open this window is F4).

See also  Phillips Place: goodbye movie theater, hello office tower

Navigate to the place the nuget bundle was downloaded at, default it’s at “%HOMEPATH%.nugetpackagesautoitx.dotnet3.3.14.5“, and from the construct folder, choose the native dll for use, I’ll use the AutoItX3_x64.dll.

Step 2: Cookie Clicker

The rationale I selected Cookie Clicker is that it’s a simple and enjoyable approach of show-casing how one can spam click on from code and get one thing in return (cookies, yey!!!).

After all, you should utilize one thing else to do this out, although I like to recommend one thing that may be spam clicked for quire a while and also can give some form of suggestions (not on the empty desktop) for this instance. You will note why in a minute.

Step 3: Writing the code

And now for the enjoyable stuff.

AutoItX makes use of a set of static strategies to carry out actions, for instance, the next code snippet will mouse click on (default left/major click on) on the present mouse place.


This technique has non-compulsory parameters specifying which mouse button to click on, the coordinates at which to click on on the display, the variety of clicks and the pace, all of those needs to be in step with the AutoIt documentation if you wish to see what every parameter does.

As a result of we wish to carry on clicking in a loop, it’s necessary to additionally be capable to cease it. That is the rationale we won’t be giving coordinates to the MouseClick technique (as a result of it would stop us from transferring the mouse) and why the press loop must cease in order that even when we do deliver up the duty supervisor to kill the method, it doesn’t proceed to click on on random issues at these coordinates.

To perform this we shall be utilizing a command that returns the present coordinates of the mouse, that command is as follows:

Level startPosition = AutoItX.MouseGetPos();

The coordinates are returned within the format of a System.Drawing.Level containing the present X and Y coordinates of the mouse.

See also  Just Cause 4 Review

Now let’s write our code:

Level startPosition = AutoItX.MouseGetPos();
whereas (startPosition == AutoItX.MouseGetPos())

With this, we then focus LinqPad, transfer the mouse over the enormous cookie within the browser (with out clicking within the browser) after which press F5 to run the script. It will begin producing all these candy candy cookies so long as we don’t transfer the mouse, and as quickly as we transfer the mouse, the script will finish as to not have points with the mouse persevering with to click on whereas we transfer it to shut the script.

Enjoyable homework

Now for some enjoyable homework, attempt to make the script to maintain operating solely whereas your mouse continues to be hovering over the enormous cookie. Some hints for this may be to seek out the highest and backside Y worth for the cookie, then discover the left and proper X values for the cookie, discover the middle then put a situation within the whereas loop to verify that the present coordinates of the mouse are inside the world of the cookie.

One other homework thought can be to seek out the cookie irrespective of the place the browser is situated at (assuming it’s not maximized or on the identical display) by searching for different useful strategies that AutoItX gives.


I do know it’s a foolish instance however I do imagine that it’s a enjoyable approach to mess around with mouse automation for starters and start line to analysis into different automation that may be performed utilizing AutoItX and C#.

I hope you loved it and we’d come again to this subject with another enjoyable additions to our scrips, like perhaps including hotkeys to activate and off our script

Till subsequent time,

Vlad V.

Share this:

Like this:



Leave a Reply

Your email address will not be published.