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

Learn more

Share via:

Comments in AutoIt

Comments are useful when you explain your code to others, and when you want to out-comment bits of code for testing purposes. Find out how to use them in this article.

371 views

Edited: 2018-01-22 00:18

There is a few ways to write Comments in AutoIt. You can either use semicolon (;) for single line comments, or you can use #comments-start + #comments-end for block comments.

Comments can be useful when you want to describe your code, or comment out bits of code when testing. Do not just use comments to explain the obvious. Generally, only the complex parts of your code should warrant further explanation.

Comments can also be useful for beginners when they are learning AutoIt, when used as small reminders about their code.

The below example shows how to write a Block Comment:

#comments-start
  MsgBox(4096, "", "This message box has been commented out, and should not be displayed when the script is run.")
#comments-end

sleep(1000) ; Code outside of the block comment 

To write single-line comments, use the semicolon, like demonstrated below:

 ; MsgBox(4096, "", "This message box has been commented out, and should not be displayed when the script is run.")

Abbreviated Keywords

You can also use the abbreviated keywords #cs and #ce when writing block comments, they are simply a short-hand way of writing block comments, which can be very useful. Example below:

#cs
  Just a test comment

  MsgBox(4096, "", "This message box has been commented out, and should not be displayed when the script is run.")
#ce

sleep(1000) ; Code outside of the block comment 

Links

  1. Language Reference - Comments – autoitscript.com
  2. Keyword #comments-start – autoitscript.com

Comments