<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.autoitscript.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Trids</id>
	<title>AutoIt Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.autoitscript.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Trids"/>
	<link rel="alternate" type="text/html" href="https://www.autoitscript.com/wiki/Special:Contributions/Trids"/>
	<updated>2026-04-05T23:49:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User:Trids&amp;diff=6219</id>
		<title>User:Trids</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User:Trids&amp;diff=6219"/>
		<updated>2005-01-25T07:28:32Z</updated>

		<summary type="html">&lt;p&gt;Trids: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Just an avid AU3 fan ;o)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
experimenting with layout etc.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Tutorials|Back to Tutorials index]]&lt;br /&gt;
&lt;br /&gt;
=Tutorial: Automating MSPaint to play Hangman=&lt;br /&gt;
==Lesson 1: Starting an application==&lt;br /&gt;
* Starts MSPaint, displays a welcome message.&lt;br /&gt;
* Illustrates Run, RunWait, WinSetTitle, MsgBox, SplashTextOn, SplashOff&lt;br /&gt;
&lt;br /&gt;
We&#039;re going to automate MSPaint to play Hangman. So lets start by launching &#039;&#039;&#039;mspaint.exe&#039;&#039;&#039;. According to the AU3 helpfile, we can use either [[Run]] or [[RunWait]]. The difference lies in when we get control back from the command.&lt;br /&gt;
&lt;br /&gt;
Lets see this in action. Create a file called &#039;&#039;&#039;Hangman.au3&#039;&#039;&#039; and copy in the following lines:&lt;br /&gt;
    &lt;br /&gt;
 ;&lt;br /&gt;
 ; Hangman with MSPaint&lt;br /&gt;
 ;&lt;br /&gt;
    ;we don&#039;t need to specify the path if the exe is in the system directory..&lt;br /&gt;
     RunWait (&amp;quot;MSPAINT.EXE&amp;quot;) &lt;br /&gt;
    &lt;br /&gt;
     MsgBox (0,&amp;quot;&amp;quot;,&amp;quot;Script continues&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
When you run this, notice that the [[MsgBox]] pops up only &#039;&#039;after&#039;&#039; we shutdown mspaint. This won&#039;t do, because the MsgBox is standing in for the rest of the code that we still need to write. Lets see what happens if we use &#039;&#039;&#039;Run&#039;&#039;&#039; instead, so that the MsgBox comes up &#039;&#039;while mspaint is still running&#039;&#039;. Also, notice that the title of the mspaint window says &amp;quot;untitled - Paint&amp;quot;: we&#039;ll change this to show that we&#039;re playing Hangman, and display a splash page for the same reason. We&#039;ll also maximise the mspaint window (see the change to the &#039;&#039;&#039;Run&#039;&#039;&#039; command).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll be using the title in some further commands, so lets create a variable for it instead of typing it out each time (and possibly misspelling it!):&lt;br /&gt;
&lt;br /&gt;
 ;&lt;br /&gt;
 ; Hangman with MSPaint&lt;br /&gt;
 ;&lt;br /&gt;
 Dim $sTitle = &amp;quot;Hangman by AutoIt&amp;quot;&lt;br /&gt;
     &lt;br /&gt;
     ;Get things going&lt;br /&gt;
     SplashTextOn(&amp;quot;Hangman&amp;quot;, &amp;quot;This is a tutorial on how to use AutoIt v3&amp;quot;,-1,-1,-1,-1,16)&lt;br /&gt;
     Run (&amp;quot;MSPAINT.EXE&amp;quot;, &amp;quot;&amp;quot;, @SW_MAXIMIZE) &lt;br /&gt;
     WinSetTitle (&amp;quot;untitled - Paint&amp;quot;, &amp;quot;&amp;quot;, $sTitle)&lt;br /&gt;
     Sleep (2000)&lt;br /&gt;
     SplashOff ()&lt;br /&gt;
     &lt;br /&gt;
     MsgBox (0,&amp;quot;&amp;quot;,&amp;quot;Waiting&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
But when we run this, we see that something is wrong: the title hasn&#039;t changed! And according to the helpfile, our syntax is correct. The problem is that mspaint takes a little longer to create the window that says &amp;quot;untitled - Paint&amp;quot; than the script takes to get to the point where it wants to change it. So lets just make sure with [[WinWait]] that the &#039;&#039;window exists&#039;&#039; before we change it with [[WinSetTitle]]. &lt;br /&gt;
&lt;br /&gt;
At the same time, we&#039;ll change the dimensions of the splash page from the defaults, by altering the parameters to the [[SplashTextOn]] statement. &lt;br /&gt;
&lt;br /&gt;
One last step for this lesson - if you&#039;ve been running the scripts at each step as we&#039;ve tested our changes (which is the best way to learn), you&#039;ll have several instances of mspaint hanging around unless you&#039;ve closed them manually. So lets also add a feature that closes mspaint when the script terminates, using [[ProcessClose]] and capturing the Process ID for it from the &#039;&#039;&#039;Run&#039;&#039;&#039; command. Here&#039;s the final script for this stage:&lt;br /&gt;
&lt;br /&gt;
 ;&lt;br /&gt;
 ; Hangman with MSPaint&lt;br /&gt;
 ;&lt;br /&gt;
 Dim $sTitle = &amp;quot;Hangman by AutoIt&amp;quot;&lt;br /&gt;
     &lt;br /&gt;
     ;Get things going&lt;br /&gt;
     SplashTextOn (&amp;quot;Hangman&amp;quot;, &amp;quot;This is a tutorial on how to use AutoIt v3&amp;quot;,400,100,-1,-1,16)&lt;br /&gt;
     $nPID = Run (&amp;quot;MSPAINT.EXE&amp;quot;, &amp;quot;&amp;quot;, @SW_MAXIMIZE) &lt;br /&gt;
     WinWait (&amp;quot;untitled - Paint&amp;quot;)&lt;br /&gt;
     WinSetTitle (&amp;quot;untitled - Paint&amp;quot;, &amp;quot;&amp;quot;, $sTitle)&lt;br /&gt;
     Sleep (2000)&lt;br /&gt;
     SplashOff ()&lt;br /&gt;
     &lt;br /&gt;
     MsgBox (0,&amp;quot;&amp;quot;,&amp;quot;Waiting&amp;quot;)&lt;br /&gt;
     ProcessClose ($nPID)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Lesson 2: Navigating a menu==&lt;br /&gt;
&lt;br /&gt;
* Sets Image size, saves/opens a file.&lt;br /&gt;
* Illustrates &amp;lt;Various way of navigating a menu&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion&lt;br /&gt;
&lt;br /&gt;
 code &lt;br /&gt;
 code &lt;br /&gt;
 code &lt;br /&gt;
&lt;br /&gt;
Discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion&lt;br /&gt;
&lt;br /&gt;
 code &lt;br /&gt;
 code &lt;br /&gt;
 code&lt;br /&gt;
&lt;br /&gt;
==Lesson 3: Clicks and Drags==&lt;br /&gt;
&lt;br /&gt;
* Draws some shapes in different colours, introduces AutoitSpy.&lt;br /&gt;
* Illustrates AutoitSetOption, Opt, MouseCoordMode, MouseMove, MouseClick, MouseClickDrag, MouseDown, MouseUp &lt;br /&gt;
&lt;br /&gt;
Discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion&lt;br /&gt;
&lt;br /&gt;
 code &lt;br /&gt;
 code &lt;br /&gt;
 code &lt;br /&gt;
&lt;br /&gt;
Discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion discussion&lt;br /&gt;
&lt;br /&gt;
 code &lt;br /&gt;
 code &lt;br /&gt;
 code&lt;br /&gt;
&lt;br /&gt;
==Lesson 4: Arrays and ini files==&lt;br /&gt;
&lt;br /&gt;
* Prepares for the game ahead, reads previous game settings from an INI file, loads arrays to be used in the game.&lt;br /&gt;
* Illustrates Dim, INIRead, INIWrite, InputBox &lt;br /&gt;
&lt;br /&gt;
 etc .. you know, that kind of thing .. &lt;br /&gt;
 each lesson building on the previous one, &lt;br /&gt;
 and showing good practice: &lt;br /&gt;
 indentation, naming standards, use of UDFs&lt;br /&gt;
&lt;br /&gt;
[[Tutorials|Back to Tutorials index]]&lt;/div&gt;</summary>
		<author><name>Trids</name></author>
	</entry>
</feed>