ich bin auf github auf ein Admin Skript gesossen, welches zwar einwandfrei funktioniert. Allerdings Probleme bereitet sobald man mehrere Gameserver auf dem Rootserver hat. Der Grund dafür ist, das dieses Script die Konsole via Prozessnamen aufrift, da aber alle Instanzen den gleichen Prozessnamen haben sind Konflikte vorprogrammiert. Anbei einen Link zum Script:
https://github.com/Volavi/Wreckfest-2-A ... me-ov-file
Die Kritische Funktion ist der Zugriff auf die Konsole
Code: Alles auswählen
def locate_server_window(self):
"""Find and activate the Wreckfest 2 server window"""
try:
self.server_window = gw.getWindowsWithTitle('Wreckfest 2 | ')[0]
if self.server_window:
self.server_window.activate()
time.sleep(1)
if self.debug_settings.get('print_console_actions', False):
print(f"Found server window: {self.server_window.title}")
print(f"Window position: (left={self.server_window.left}, top={self.server_window.top})")
print(f"Window size: (width={self.server_window.width}, height={self.server_window.height})")
else:
raise Exception("Wreckfest 2 server window not found")
except IndexError:
print("Error: Could not find 'Wreckfest 2' server window")
print("Please make sure your Wreckfest 2 server is running and visible")
exit(1)
except Exception as e:
print(f"Error locating server window: {str(e)}")
exit(1)
Code: Alles auswählen
Func _ConsoleSendCtrlC($PID, $iEvent = 0, $iMode = 0, $iLoop = 1, $iSlp = 10, $iDll = "kernel32.dll")
;Author: rover 2k12
Local $aRet = DllCall($iDll, "bool", "AttachConsole", "dword", $PID)
If @error Or $aRet[0] = 0 Then Return SetError(1, 0, -1)
;sets GetLastError to ERROR_GEN_FAILURE (31) if process does not exist
;sets GetLastError to ERROR_ACCESS_DENIED (5) if already attached to a console
;sets GetLastError to ERROR_INVALID_HANDLE (6) if process does not have a console
$aRet = DllCall("Kernel32.dll", "hwnd", "GetConsoleWindow") ;must be attached to console to get hWnd
If Not @error And IsHWnd($aRet[0]) Then
$aRet = DllCall('user32.dll', 'int', 'IsHungAppWindow', 'hwnd', $aRet[0]);from Yashieds' WinAPIEx.au3
If Not @error And $aRet[0] Then
DllCall($iDll, "bool", "FreeConsole")
Return SetError(2, 0, -1)
EndIf
Else
Return SetError(3, 0, -1)
EndIf