Wednesday, January 24, 2018

AHK scripting

It's been a while since the last post here and a lot has happened. It might take more than a few posts, but I will try to catch up. My current job has taken a way a big chunk of the time that used to be dedicated to creative tasks, however it allowed me to advance my programming skills and do some interesting things.

I noted in a previous post about what it entails- a lot data validation and entry. The company has allowed me to automate the majority of the processes via scripting. For that I chose Autohotkey- as it's the perfect windows api for macros and its open source.The AHK scripting language looks like Basic mixed with javascript and can be a pain in the neck in the start- but it's pretty cool once you get a hang on it.
Using it, I wrote a gui macro app that does my job's process automatically. Under the custom interface, the app holds a giant collection of macro scripts, web crawlers, logging and automatic data correction functions.
I called it "Sunlotion" - the name is a joke- for it fills in for all the flaws of the scheduling software that the company has been using- we shall call that "Soul Destroyer" in this article.

When I get a job request in an email or a spreadsheet, all I need to do is highlight the text and pop up Sunlotion's custom menu - it gives me the option to parse the text. Via a combination of regular expressions and functions, Sunlotion populates it's own interface's fields with the correct information from the text I fed to it. Who requested the job, who it's for, duration, date, project code, etc, etc

The date gets checked- is it on a weekend, is the date too soon (short notice jobs) , is it this year (believe it or not people make that mistake too) and so on. It gets converted to the correct format automatically- "fri 12 jan"  becomes 12/01/2018 - so as not to trip Soul Destroyer.
The duration also gets converted to the right format automatically- "2 days" becomes "15" hours. 1.5 hours becomes 1.30 hours. Project codes get automagicaly validated via a web crawler macro - when it receives it, Sunlotion  navigates to a website in the background, checks the status of the project code and if valid- proceeds. If not- it creates a reply email about the status of the code and sends it to the requester.
Another crawler macro checks what area the job is for (so it knows whom to email later) by navigating to another website and extracting the data.It detects if its fed a site code or a site name. If its a site name, the web crawler macro will retrieve the site code.

And after all the raw data is automatically organized, cleaned up, analyzed and validated by Sunlotion, I click on a button and it fires a macro that raises the job on Soul Destroyer, writes the email, attaches the right files, the right send to emails, logs the job to a spreadsheet and moves on to the next job. Rinse and repeat.
For some types of job forms I was able to completely automate the process , so my tool would raise a sequence of hundreds of jobs on Soul Destroyer without need of any supervision.

These are just scratching the surface though- there are so many macros, crawlers and functions, that it would take too long to list all.

Of course my managers noticed that this was freeing my time and gave me other tasks to keep busy. I started raising jobs that another department had to raise in the past. I wrote little apps for my department and other departments to save the company time by automating other processes(over 10 apps so far). The company in return gave me a yearly bonus and an innovation award.

There is no raise in sight, I am not technically getting a programmer's wage either, but the experience has helped me tremendously in becoming better at writing my own apps.
Since I can't show or share Sunlotion here because it was written in company time- I made another AHK app in my personal time for fun. It's called Metasnap.
You can check it out here:

I might write a post about in later on.

I have also been working on another app- that I am writing in Gdscript via Godot. Stay tuned- it will be more interesting to present :)

No comments:

Post a Comment