8 GloVar
David Daily edited this page 11 months ago

Global Variables

I created something so that I can always have multiple strings at my fingertips. Its like a clipboard manager but different.

First time setup: Create GloVar.ini and emails.csv in My Documents

Top-level overview

What it does is take an ini (based off this) and turn it into hotstrings that start with $ automagically. The Key (left side of the =) is the hotstring, the Value (right side of the =) is what it gets replaced with.


if your ini looks like this:

[Serial Numbers]

glovar.ahk would look like this:

#SingleInstance force



This way I'm not copying and pasting twenty different things, mixing up similar serial numbers or other information. It also doubles as a replacement to a WPF-based application the in-house IT created that generates ugly output and is a pain to use.

Why aren't you using JSON? Its so much better

You aren't wrong, it would be much easier to manipulate the data. However, since I'm actively modifying this during a call, I don't want there to be a possibility for me to mess up the syntax. ini has the easiest syntax and can be easily read at a glance.


Regex mainly. Code starts here, its not really that unreadable, but I'll walk though it here too.

One of the most important things to do is not modify the file while it is still being edited. VSCode does not like it and throws an error if the file it is saving is different than it was before it was modified by the user. However it does not care if an open file is being modified by something else. For that we do WinWaitNotActive, GloVar.ini right before we modify the file, just to make sure.

To keep track if the file was changed, we check it's last modified time with FileGetTime, gvModNew, %glovarini%, and then in the script after we modify the file we do FileGetTime, gvMod, %glovarini% so that it doesn't edit the file and say “Oh look it was modified, must mean there's new info there!” and run extra times it doesn't need to.

If the last stored modified time the script made is different than its last modified time, we process its data: if !(gvModNew = gvMod){...}

Every time we process the ini, we completely destroy the automagically created file because that is the easiest way to make sure there isn't any extra stuff in there.

Next, we loop though each line, with regex putting the section name in RESection and if it is a Key/Value pair it puts the Key in REKey and the Value in REValue (wow, what a surprise). If it is under the “Serial Numbers” section it gets made uppercase and the uppercase value is written to the ini. If it is under the “Operations Center” section and the key is usr (use it for username, usually only have one), it does the same thing. If the Key is case, it strips the ( ) off the front and the back.

If the Key is xid, we do some more work. I have a CSV I keep of people I talk to (example here) that is up to 387 lines. It is also easily added to with addemail.ahk. If the unique identifier of the caller (xID) is found in the CSV, it fills in the details in the ini and in the hostrings. If it is not found, we run addemail.ahk to add their info to the table.

If the section name is changed to clear, the contens of the documentation file (where I keep notes on the call / what goes in the case management system) and the contents of the ini are appended to a log file that I've had since I came up with the idea in August 2017. Its only 63747 lines long as of writing, but then again its just a .txt file. We also copy the template to the ini with the overwrite option enabled.

That's it.


Put things like serial numbers and usernames on the right of the =, and what you want to type to be replaced with the text on the right on the left of the =. Each line has to be unique, otherwise it won't work.

Replace [Info] with [clear] and it will clear out the whole ini, resetting it to glovarsource in the D3K folder. This also empties the documentation file as specified in the settings GUI (Alt+Shift+\)

My setup

My setup