The script works flawlessly on some employee computers, but on others it randomly stops working, for example sometimes when you right click on it the tray menu is blacked out; sometimes it wont allow you to right click on it at all.
If you want to see the whole thing I attached the script in a zip file too. If someone could have a look at it and see if theres anywhere in the code that needs tweaked, possibly fixing the issues i described above.
Thanks!

#Persistent
#SingleInstance
#NoEnv
;#Warn ; returns alot of warnings
SendMode Input
COM_Error(False)
#include \\MAINFRAMESERVER\Server Documents\tray_notifier\includes\COM.ahk
#include \\MAINFRAMESERVER\Server Documents\tray_notifier\includes\MI.ahk
ImgDir = \\MAINFRAMESERVER\Server Documents\tray_notifier\icons\
icon_off = %ImgDir%icon_off.ico
icon_grn = %ImgDir%icon_green.ico
icon_red = %ImgDir%icon_red.ico
Ricon = MI_ExtractIcon(icon_red, null, 16)
Gicon = MI_ExtractIcon(icon_grn, null, 16)
URL1 = "https://www.website1.com/admin/gadget.php"
URL2 = "https://www.website2.com/admin/gadget.php"
URL3 = "http://mainframeserver/company-calendar/assets/ajax/checker.php" ; local network calendar
SK = Software\Microsoft\Windows\CurrentVersion\Run
Version = 1
RegRead ScrPath, HKCU, %SK%, %A_ScriptName%
AutorunOn := !ErrorLevel
if (AutorunOn == 0) {
IfNotEqual ScrPath, A_ScriptFullPath
{
RegWrite, REG_SZ, HKCU, %SK%, %A_ScriptName%, %A_ScriptFullPath%
}
else {
RegWrite, REG_SZ, HKCU, %SK%, %A_ScriptName%, %A_ScriptFullPath%
}
}
loop {
COM_Init()
pwhr1 := COM_CreateObject("WinHttp.WinHttpRequest.5.1")
COM_Invoke(pwhr1, "Open", "GET", URL1)
COM_Invoke(pwhr1, "Send")
sResponseText1 := COM_Invoke(pwhr1, "ResponseText")
COM_Release(pwhr1)
pwhr2 := COM_CreateObject("WinHttp.WinHttpRequest.5.1")
COM_Invoke(pwhr2, "Open", "GET", URL2)
COM_Invoke(pwhr2, "Send")
sResponseText2 := COM_Invoke(pwhr2, "ResponseText")
COM_Release(pwhr2)
pwhr3 := COM_CreateObject("WinHttp.WinHttpRequest.5.1")
COM_Invoke(pwhr3, "Open", "GET", URL3)
COM_Invoke(pwhr3, "Send")
sResponseText3 := COM_Invoke(pwhr3, "ResponseText")
COM_Release(pwhr3)
COM_Term()
if (sResponseText1 = "Y") or (sResponseText2 = "Y") or (sResponseText3 = "Y") {
if (sResponseText1 = "Y") {
TipString = WEBSITE1 ORDER
SetMenu(Gicon,Ricon,Ricon)
}
if (sResponseText2 = "Y") {
TipString = WEBSITE2 ORDER
SetMenu(Ricon,Gicon,Ricon)
}
if (sResponseText3 = "Y") {
TipString = NEW CALENDAR EVENT
SetMenu(Ricon,Ricon,Gicon)
}
if ((sResponseText1 = "Y") and (sResponseText2 = "Y")) {
TipString = WEBSITE1 ORDER `nWEBSITE2 ORDER
SetMenu(Gicon,Gicon,Ricon)
}
if ((sResponseText1 = "Y") and (sResponseText3 = "Y")) {
TipString = WEBSITE1 ORDER `nNEW CALENDAR EVENT
SetMenu(Gicon,Ricon,Gicon)
}
if ((sResponseText2 = "Y") and (sResponseText3 = "Y")) {
TipString = WEBSITE2 ORDER `nNEW CALENDAR EVENT
SetMenu(Ricon,Gicon,Gicon)
}
if ((sResponseText1 = "Y") and (sResponseText2 = "Y") and (sResponseText3 = "Y")) {
TipString = WEBSITE1 ORDER `nWEBSITE2 ORDER `nNEW CALENDAR EVENT
SetMenu(Gicon,Gicon,Gicon)
}
RefreshTrayTip(TipString)
menu, tray, icon, %icon_grn%
} else {
SetMenu(Ricon,Ricon,Ricon)
menu, tray, icon, %icon_red%
SetTimer, RemoveTrayTip, 5000
}
sleep, 30000 ;30 secs (30000)
}
RefreshTrayTip(txt) {
trayTip,, %txt%
}
SetMenu(a=0,b=0,c=0) {
global
menu, tray, DeleteAll
menu, tray, NoStandard
menu, tray, add, Website1 Orders, RunCFS
menu, tray, add, Website2 Orders, RunGFS
menu, tray, add, Calendar, RunCal
hTM := MI_GetMenuHandle("Tray")
MI_SetMenuItemIcon(hTM, 1, a, "", 16)
MI_SetMenuItemIcon(hTM, 2, b, "", 16)
MI_SetMenuItemIcon(hTM, 3, c, "", 16)
Menu, Tray, Add
Menu, Tray, Add
menu tray, add, Exit
return
}
RunCFS:
run https://www.website1.com/admin/
return
RunGFS:
run https://www.website2.com/admin/
return
RunCal:
run http://mainframeserver/company-calendar/index.php ; local network calendar
return
RunNothing:
return
RemoveTrayTip:
SetTimer, RemoveTrayTip, Off
TrayTip
return
Exit:
ExitApp
return




