AutoIt Scripting Language is a very user-friendly programming language. I use AutoIt quite frequently because it allows you to automate repetitive, monotonous tasks saving you valuable time and energy. I personally feel that if you have to do something that takes you 10 minutes 5 times a week, then you should spend the time (even if it takes 2 days) to automate that task so that you are then free to do other things. It helps to have some programming experience when you start using AutoIt, but I don’t think it’s really a requirement. AutoIt is a very simple, English like language, and it has an excellent help file. AutoIt allows you to easily read and write data from file, ini files, and the registry. Another great feature of AutoIt is that you can control the keyboard and mouse, which means you can automate just about any task you can do manually with the keyboard and mouse. The best feature of AutoIt is that you can compile your AutoIt scripts into executable files so you can run your script on any Windows machine without having to install the AutoIt software. There is a special text editor available through the AutoIt website, called SciTE, which has many AutoIt related functions built-in. My favorite feature of SciTE is the type-ahead feature that lets you type in a few characters of a command or variable and then displays a list of possible choices you can select. (more…)
If you don’t know too much about AutoIt, or haven’t already read my What is AutoIt Scripting Language post, it may be helpful for you to check it out before reading this.
So, how do you read files with AutoIt? Don’t worry, it’s very easy.
- The first thing that you need to do is open the file using the FileOpen function in AutoIt.
- $variableName = FileOpen( fileName , mode )
-
- $fileVariableName is a handle for the file you are opening, if you are going to be opening multiple files in your program ALWAYS use a unique handle.
-
- fileName is the full path to the file you wish to openmod, if the file is in the same folder as your script is running, you can leave out the full path.
-
- mode is the file access mode that you want to open the file with, for our example we will use 0 because we just want to open the file for reading.
-
-
- 1 - Write Mode (Append writes to the end of the file)
- 2 - Write Mode (Erase previous contents of the file)
- 8 - Create directory structure if it does not exist
- (more…)
Hopefully you already know how to read in data from a file, if not, you can check out AutoIt Script Tutorial 001: Reading Files. When you’re reading an input file, most of the time each line of your input will contain more than one item of related data. One of the most common formats that I use is a CSV (comma separated value) file. The main reason I use a CSV file is because you can save a spreadsheet as a CSV file, and it’s pretty easy to get any kind of data into a spreadsheet. So here we go…
- Let’s say you have a spreadsheet of last name, first name, area code, phone number…
-
Doe, John, 123, 4657890
Doe, Jane, 231, 6540692
Davis, Rick, 123, 4567890
-
- Save the spreadsheet as a CSV file, I believe most spreadsheet applications will allow you to do this, if not, just make the file manually with Notepad.exe or something.
- So now we have our CSV file, let’s call it “Rick Davis Tutorial 002.csv”.
- Now we need to read the data, see AutoIt Script Tutorial 001: Reading Files if you need an explanation on this…