Skip to content

Instantly share code, notes, and snippets.

@bitingsock
Last active April 6, 2023 23:05
Show Gist options
  • Save bitingsock/a56dddb1e953fdd40e3035b37c387f28 to your computer and use it in GitHub Desktop.
Save bitingsock/a56dddb1e953fdd40e3035b37c387f28 to your computer and use it in GitHub Desktop.
send virtual keystroke (F15) during playback to prevent auto afk of some applications (requires Windows powershell)
local afkTimer = mp.add_periodic_timer(60, function()
if mp.get_property("pause") == "no" and mp.get_property("vid") ~= "no" then
mp.command_native({
name = "subprocess",
capture_stdout = false,
playback_only = false,
args = { "powershell", "(New-Object -ComObject WScript.Shell).SendKeys('{F15}')" }
})
end
end)
local function reset()
afkTimer:kill()
afkTimer:resume()
end
mp.observe_property("pause", nil, reset)
mp.register_event("seek", reset)
mp.add_key_binding("MOUSE_MOVE", "", reset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment