Skip to content

Instantly share code, notes, and snippets.

@alaingilbert
Last active June 28, 2024 17:29
Show Gist options
  • Save alaingilbert/a5219358b09ad73a082574b247856fe4 to your computer and use it in GitHub Desktop.
Save alaingilbert/a5219358b09ad73a082574b247856fe4 to your computer and use it in GitHub Desktop.
GeForceNOW anti anti-afk AppleScript
on GetApplicationCorrespondingToProcess(process_name)
tell application "System Events"
set application_file to file of (application processes where name is process_name)
end tell
return application_file as string
end GetApplicationCorrespondingToProcess
repeat
tell application "System Events"
set frontmostApplicationName to name of 1st process whose frontmost is true
end tell
set frontmostApplicationName1 to (GetApplicationCorrespondingToProcess(frontmostApplicationName) as string)
if frontmostApplicationName is not "GeForceNOW" then
-- Focus the GeForceNOW process
tell application "GeForceNOW" to activate
tell application "System Events"
key down "w"
delay 0.3
key up "w"
key down "s"
delay 0.3
key up "s"
end tell
delay 0.5
-- Give back focus to whatever had focus before
-- Hack for tor browser which is otherwise detected as "Firefox"
if frontmostApplicationName1 contains "Tor Browser" then
tell application "Tor Browser" to activate
else
tell application frontmostApplicationName to activate
end if
end if
delay 240 -- wait 4 min
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment