I want an AutoHotkey task to run daily at a specific time under the condition that there is internet access on my notebook, as it needs to open a website. If there is no internet access, run task as soon as it becomes available. Using Windows Task Scheduler, there is no apparent setting for this condition. Maybe there is a way to build a custom event trigger which checks for internet connection?
I couldn't find anything about this on the internet, despite my requirement being quite basic for a scheduled task.
The option "Start only if the following network connection is available: Any connection" in the Conditions tab of my task doesn't work. I was offline in airplane mode and the task still triggered. Probably it detects my Hyper-V Network-Adapters "vEthernet" and thus the condition is true. I also don't want to set a specific WiFi Network there, as I could be at home or at uni when the task gets triggered. So far the trigger for my task is the system clock.
Have you tried anything yet in AutoHotkey? I would recommend posting your code if you have or making an attempt first. Generally speaking, we won't write your code for you, but we will gladly help with specific problems or issues.
To get you started, I would recommend using SetTimer to regularly check what time it is. Once it has a match to your desired time, deactivate timer and check if connected to the internet (see below). If connected, do the task(s) you mention and reactivate timer. If it's not, keep rechecking every 30 sec. (or whatever you want) until connected.
Checking internet connectivity isn't quite as straight-forward, but here is a simplified example of what I occasionally use.
f1::
If NetChk( "https://www.google.com" )
MsgBox , Success!
Else
MsgBox , Nope... :(
Return
NetChk( sAddress )
{
ComObjError( false )
oWHR := ComObjCreate( "WinHttp.WinHttpRequest.5.1" )
oWHR.Open( "GET" , sAddress )
oWHR.Send()
Return oWHR.ResponseText
}