Skip to content

Instantly share code, notes, and snippets.

@CTimmerman
Last active February 8, 2016 11:54
Show Gist options
  • Save CTimmerman/8223e7850da94ed89ee6 to your computer and use it in GitHub Desktop.
Save CTimmerman/8223e7850da94ed89ee6 to your computer and use it in GitHub Desktop.
Steam auto-away while idle
""" 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
@CTimmerman
Copy link
Author

@CTimmerman
Copy link
Author

Saving with tab size 4 still fails, @github. Add .blob-code-inner{tab-size: 4;} or have users hack it in with Stylish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment