Add UIAutomation background injection for Roblox Studio

- bg_inject.ps1: PowerShell UIAutomation script that finds Studio command bar by AutomationId and injects Lua code without window focus
- bg_inject.py: Python wrapper for bg_inject.ps1
- bg_inject_uia2.ps1: Discovery/debugging script for finding Studio UI controls
- inject_full_gta.py: 7-step GTA city + COD weapons + enemies injection using background API
- inject_gta_bg.py: Alternative multi-file GTA injection loader

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gemini AI
2026-03-31 22:34:48 +04:00
Unverified
parent 2065361e57
commit 3af46cf15d
5 changed files with 597 additions and 0 deletions

57
bg_inject.py Normal file
View File

@@ -0,0 +1,57 @@
"""
Background injection into Roblox Studio via UI Automation.
Works when Studio is minimized, behind other windows, or in background.
No user interaction required.
"""
import subprocess, sys, os, time
PS_SCRIPT = r"C:\Users\Admin\bg_inject.ps1"
def inject(code):
"""Inject Lua code into Roblox Studio command bar in the background."""
# Write code to temp file to avoid quoting issues
tmp = os.path.join(os.environ["TEMP"], "rbx_bg_inject.lua")
with open(tmp, "w", encoding="utf-8") as f:
f.write(code)
result = subprocess.run(
["powershell", "-ExecutionPolicy", "Bypass", "-File", PS_SCRIPT, "-File", tmp],
capture_output=True, text=True, timeout=30
)
output = result.stdout.strip()
error = result.stderr.strip()
if "OK" in output:
return True, output
else:
return False, f"{output}\n{error}"
def inject_multi(scripts, label=""):
"""Inject multiple scripts sequentially."""
for i, (name, code) in enumerate(scripts, 1):
total = len(scripts)
prefix = f"[{label}] " if label else ""
print(f" {prefix}[{i}/{total}] {name}...", end="", flush=True)
ok, msg = inject(code)
if ok:
print(" OK")
else:
print(f" FAILED: {msg}")
return False
time.sleep(2.5) # Wait for Studio to process
return True
if __name__ == "__main__":
if len(sys.argv) > 1:
# Inject a file
path = sys.argv[1]
with open(path, "r", encoding="utf-8") as f:
code = f.read()
ok, msg = inject(code)
print(msg)
else:
# Test
ok, msg = inject('print("BG_INJECT_TEST_OK")')
print(msg)