AHK Script on Start & PowerShell Send Email

I was playing with Febooti Automation Workshop (community edition for personal use only) when setting up a new PC and had an issue about starting a AutoHotKey Script on startup and it didn’t allow for running a script.

Automation Workshop & Task Scheduler

I looked at what I had on my other PC and it used Windows Task Scheduler to run the script on Booting up the PC. I set it on this one to do that (its not currently working).

I got distracted with a couple of items in Task Scheduler , as in, can it send an email notification if a certain event happens? Like Automation Workshop? It could, but when I went to test it in Win 10 this feature has been depreciated ( I think , although its to be depreciated, its still running on Windows Server, not PC versions).

So for Task Scheduler the solution is to write a PowerShell script to do this for you.

I started writing scripts as EmailTest.ps1, then had issues in hoew to run the file, but if you right click on the file you get the option to run it in PowerShell.

Once debugged youd need to run a bat file with using powershell.exe with a call to the file that you wanted to run, and then point the Task Scheduler to that file. So a more circuitous route , but once setup it should work fine.

PowerShell Scripts for Emails & Automation Workshop

I’ve been playing with this feature and have been testing it from a couple of my accounts, a hotmail (outlook) and a gmail one.

I’ve copied a few scripts from the web on the topic and have had some success with sending from Hotmail, but not from GMail.

I’ve got the basic code running but when I started to try attachments Gmail flipped its lid and blocked ones, and after blocking the first one would not accept any others from the same address. The issue being it doesn’t like .zip, macro and other ones that could hide malicious code,and the first attachment I was trying to share was a .ps1 (PowerShell script) so that caused a few issues. I’ll not put my code as I pretty much followed these articles:

The links below were successful, but only from Outlook, not Gmail.

Powershell to send mail using gmail smtp settings

Send Mails And Attachments From PowerShell Using Gmail SMTP Server

Overall, a bit fiddly, but interesting in PowerShell, but this is where the Automation Workshop process makes it so much easier to set up tasks.

I’m glad I explored the Task Scheduler, I was questioning my use of Automation Workshop (AW), but at the end of the day I will stick with AW as its so much easier to use and to test.

Back to AutoHotKeys script trigger

There is an alternative method of starting these up, as shown in the video below, I think I’m going to set up my files as he has them, it looks like a much better method.

This method works fine, the only issue I had was commenting out link in script file, with a “;” instead of a “#” and then it worked fine. I like the idea of adding a few more automation AHK scripts so will be able to play using this method. I’ll now have to go and reconfigure my other computers.

End comment

A lot of effort for a simple trigger, but I’d been doing some research on PWA’s and push notifications in WordPress and generally the plugins use OneSignal, which, apparently sells all your user details to 3rd parties if you use the free account, so when sending push notifications to subscribers you could be adding them to other peoples spamming lists, which would not be my intention.

So the excursion into using PowerScripts to send emails could be considered as a method for automating messaging, via email, to subscribers.

I now have my AHK script working, so that is a definite win. About the push notifications and PWA’s , that will require a lot more researching.