Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance force ; Automatically update the script if it is run while already running.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetFormat, FloatFast, 0.2 ; Round decimals to two digits
CoordMode, Mouse, Window ; Sets click commands to be relative to the current window
#LTrim ; Continuation sections ignore indentation (if you don't know what this means, don't touch it)
; Gets the control ID of Google Chrome
ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, ahk_class Chrome_WidgetWin_1
; Focuses on Chrome without breaking focus on what you're doing
ControlFocus,,ahk_id %controlID%
; Refreshes Chrome
ControlSend, Chrome_RenderWidgetHostHWND1, ^r, ahk_class Chrome_WidgetWin_1
ExitApp
However, when I compile the script and try to run it via Task Scheduler, no matter what settings I use it refuses to run. Task Scheduler says "Running" (but never actually runs the script) and just... sits there.
If I manually double-click the script it works fine, though.