Last active
February 8, 2016 11:54
-
-
Save CTimmerman/8223e7850da94ed89ee6 to your computer and use it in GitHub Desktop.
Steam auto-away while idle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Steam auto-away while idle. 2016-02-07 v1.0 by Cees Timmerman """ | |
import ctypes, subprocess, time | |
class LASTINPUTINFO(ctypes.Structure): # https://msdn.microsoft.com/en-us/library/windows/desktop/ms646272%28v=vs.85%29.aspx | |
_fields_ = [('cbSize', ctypes.c_uint), | |
('dwTime', ctypes.c_ulong)] # DWORD | |
lii = LASTINPUTINFO() | |
lii.cbSize = ctypes.sizeof(lii) | |
away = False | |
while 1: | |
time.sleep(2) | |
ctypes.windll.user32.GetLastInputInfo(ctypes.byref(lii)) | |
idle_ms = ctypes.windll.kernel32.GetTickCount() - lii.dwTime | |
#print(time.ctime(), idle_ms) | |
if idle_ms > 5 * 60 * 1000: | |
if not away: | |
print("Setting Steam away at", time.ctime()) | |
subprocess.call(["C:\Program Files (x86)\Steam\steam.exe", "steam://friends/status/away"]) | |
away = True | |
elif away: | |
print("Setting Steam online at", time.ctime()) | |
subprocess.call(["C:\Program Files (x86)\Steam\steam.exe", "steam://friends/status/online"]) | |
away = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Bash, try this.