By using this site you agree to the use of cookies.

Learn more

AutoIt user made Functions

Tutorial on user made functions in AutoIt, the example shows a simple user made function outputting a message box when called.

Edited: 2017-02-08 02:53

AutoIt Logo

AutoIt allows the creation of custom functions, or user made functions, in combination with its own in-build functions. The user made ones are usually just a combination of code and in-build functions.

User made functions are intended for maintainability, and avoids otherwise repetitive bits of code, by keeping the code in a function that you can call whenever you want.

AutoIt Function Example

The below script contains a function to throw out a message box whenever its called. We will extend this with function arguments in another Tutorial, so that it will accept external input.


Func MessageFun()
  MsgBox(4096, "Result", "The message box function was called")

The above is not a very useful example, and you may as well just throw the MsgBox without using a function. It does however still show you the general idea, that is, to minimize the coding required to complete a given task.

The next Tutorial will concentrate on arguments, allowing us to supply the function with input to be handled. For instance, if we had multiple error codes from a script, we could call the appropriate error by passing some arguments to an error function.

Next: AutoIt Function Arguments