I currently have a powershell script that I would like to use with AHK that sends an email to a specified email address:
Code: Select all
$EmailFrom = "SETEMAIL"
$EmailTo = "SETEMAIL"
$Subject = Read-Host -Prompt 'Input Task Name'
$Body = $null
$SMTPServer = "PROVIDERSMTPSERVER"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("SMTP_USERNAME", "API_PASSWORD");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Once I try to invoke it with AHK it opens the Powershell window for a second and immediately closes it without giving me the chance to input anything and the email is never sent, here is the AHK script:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
#Persistent
^J::
psScript := "C:\Scripts\SendEmail.ps1"
Runwait, Powershell "%psScript%"