🅰️HK Lesson #19: How to read and work with files in your computer.

Hello,

With AutoHotkey we’re often automating programs, however there are times where we have local files that we want to read. There are several ways to do this in AutoHotkey however in this video (that I extracted from Intro to AutoHotkey) I demonstrate using the FileWrite command.

I demonstrate using UTF-8 encoding which is a great default to use for most of your scripts.

I also show how to use FileExist command to check if a file exists.

You can use those commands to read the contents of a file and then operate on them. Maybe you want to replace some words, or append data to the file and then save it again.

Many times you want to make decisions in your script depending on whether a file exists or not.

For example: You might want to check if your settings.ini file exists or not. If it doesn’t exist, then you want to create a file with the default settings.

In our Intermediate AHK v2 course we touch on many interesting situations that we find in which you can use file manipulation techniques. Click here to get a 15% discount!

Additional Resources

  • AddRequires is a tool that is a good example of when to use the FileRead and FileWrite commands.

Joe, Isaias, Irfan & Team

the-Automator.com

This campaign was designed to allow you to jump around. At any time you can jump to any one of the emails by clicking below

1) Intro2) AHK Versions3) Editors4) First AHK Script5) Getting Help
6) Variables7) Run @ Startup8) Downloading Viruses9) HotStrings10) Hotkeys
11) One vs Many Scripts12) Intro to QAP13) Functions & Directives14) Custom Functions15) Includes & Lib
16) Troubleshooting17) Intro to GUIs18) Using Clipboard19) Reading Files20) Saving Preferences
21) Automating older Progs22) Automating Menus

P.S. Reading/Writing files is a common topic in our AHK Hero meeting calls. Remember that if you are member, you get a 25% discount to all our courses

Comments are closed.