169 lines
6.7 KiB
PowerShell
169 lines
6.7 KiB
PowerShell
# PowerShell-Skript fuer automatische Screenshots
|
|
# =============================================
|
|
|
|
param(
|
|
[string]$ConfigFile = "screenshot_config.json",
|
|
[switch]$Interactive = $false,
|
|
[switch]$QuickRun = $false,
|
|
[string]$ServerUrl = "",
|
|
[string]$OutputDir = ""
|
|
)
|
|
|
|
Write-Host "===============================================" -ForegroundColor Cyan
|
|
Write-Host "AUTOMATISCHES SCREENSHOT-TOOL FUER SCHULUNGEN" -ForegroundColor Yellow
|
|
Write-Host "===============================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Arbeitsverzeichnis zum Skript-Ordner aendern
|
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
Set-Location $ScriptDir
|
|
|
|
# Pruefe ob Python verfuegbar ist
|
|
try {
|
|
$pythonVersion = python --version 2>&1
|
|
Write-Host "Python gefunden: $pythonVersion" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "Python nicht gefunden!" -ForegroundColor Red
|
|
Write-Host "Installieren Sie Python von https://python.org" -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
|
|
# Pruefe ob Selenium installiert ist
|
|
$seleniumCheck = python -c "import selenium; print('Selenium verfuegbar')" 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Selenium nicht installiert. Installiere jetzt..." -ForegroundColor Yellow
|
|
pip install selenium webdriver-manager
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Selenium-Installation fehlgeschlagen!" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
Write-Host "Selenium erfolgreich installiert" -ForegroundColor Green
|
|
} else {
|
|
Write-Host $seleniumCheck -ForegroundColor Green
|
|
}
|
|
|
|
# Pruefe ChromeDriver
|
|
$chromeCheck = python -c "exec('from selenium import webdriver'); exec('from selenium.webdriver.chrome.service import Service'); print('Chrome WebDriver verfuegbar')" 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "ChromeDriver nicht gefunden. Installiere webdriver-manager..." -ForegroundColor Yellow
|
|
pip install webdriver-manager
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "WebDriver-Manager-Installation fehlgeschlagen!" -ForegroundColor Red
|
|
Write-Host "Manuell ChromeDriver von https://chromedriver.chromium.org/ herunterladen" -ForegroundColor Yellow
|
|
} else {
|
|
Write-Host "WebDriver-Manager installiert" -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
# Flask-App verfuegbarkeit pruefen
|
|
Write-Host ""
|
|
Write-Host "Pruefe Flask-App..." -ForegroundColor Blue
|
|
$flaskCheck = python -c "import sys; sys.path.append('..'); exec('from app import app'); print('Flask-App verfuegbar')" 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Flask-App nicht direkt verfuegbar" -ForegroundColor Yellow
|
|
Write-Host "Das Tool wird mit Standard-Routen arbeiten" -ForegroundColor Blue
|
|
} else {
|
|
Write-Host $flaskCheck -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "STARTE SCREENSHOT-TOOL" -ForegroundColor Green
|
|
Write-Host "==============================" -ForegroundColor Green
|
|
|
|
# Parameter fuer das Python-Skript vorbereiten
|
|
$pythonArgs = @("screenshot_tool.py")
|
|
|
|
if ($QuickRun) {
|
|
Write-Host "Quick-Run-Modus aktiviert" -ForegroundColor Yellow
|
|
# Setze Umgebungsvariablen fuer automatische Konfiguration
|
|
$env:SCREENSHOT_AUTO_MODE = "true"
|
|
$env:SCREENSHOT_HEADLESS = "true"
|
|
|
|
if ($ServerUrl) {
|
|
$env:SCREENSHOT_SERVER_URL = $ServerUrl
|
|
}
|
|
|
|
if ($OutputDir) {
|
|
$env:SCREENSHOT_OUTPUT_DIR = $OutputDir
|
|
}
|
|
}
|
|
|
|
# Tool ausfuehren
|
|
try {
|
|
if ($Interactive) {
|
|
Write-Host "Interaktiver Modus - Folgen Sie den Anweisungen" -ForegroundColor Blue
|
|
python @pythonArgs
|
|
} else {
|
|
Write-Host "Automatischer Modus" -ForegroundColor Blue
|
|
python @pythonArgs
|
|
}
|
|
|
|
$exitCode = $LASTEXITCODE
|
|
|
|
if ($exitCode -eq 0) {
|
|
Write-Host ""
|
|
Write-Host "SCREENSHOT-ERSTELLUNG ERFOLGREICH ABGESCHLOSSEN!" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# Zeige Ausgabe-Ordner an
|
|
$outputPath = "docs\schulung\screenshots"
|
|
if (Test-Path $outputPath) {
|
|
Write-Host "Screenshots verfuegbar in:" -ForegroundColor Blue
|
|
Write-Host " $(Resolve-Path $outputPath)" -ForegroundColor White
|
|
|
|
# Frage ob Ordner geoeffnet werden soll
|
|
$openFolder = Read-Host "Moechten Sie den Screenshot-Ordner oeffnen? (j/n)"
|
|
if ($openFolder -eq "j" -or $openFolder -eq "ja" -or $openFolder -eq "y" -or $openFolder -eq "yes") {
|
|
Start-Process "explorer.exe" -ArgumentList (Resolve-Path $outputPath)
|
|
}
|
|
}
|
|
|
|
# Zeige Bericht an
|
|
$reportPath = "$outputPath\screenshot_bericht.md"
|
|
if (Test-Path $reportPath) {
|
|
Write-Host ""
|
|
Write-Host "Detaillierter Bericht verfuegbar:" -ForegroundColor Blue
|
|
Write-Host " $(Resolve-Path $reportPath)" -ForegroundColor White
|
|
|
|
$openReport = Read-Host "Moechten Sie den Bericht oeffnen? (j/n)"
|
|
if ($openReport -eq "j" -or $openReport -eq "ja" -or $openReport -eq "y" -or $openReport -eq "yes") {
|
|
Start-Process "notepad.exe" -ArgumentList (Resolve-Path $reportPath)
|
|
}
|
|
}
|
|
|
|
} else {
|
|
Write-Host ""
|
|
Write-Host "FEHLER BEI DER SCREENSHOT-ERSTELLUNG" -ForegroundColor Red
|
|
Write-Host "Ueberpruefen Sie die Logs fuer Details" -ForegroundColor Yellow
|
|
}
|
|
|
|
} catch {
|
|
Write-Host ""
|
|
Write-Host "UNERWARTETER FEHLER: $($_.Exception.Message)" -ForegroundColor Red
|
|
$exitCode = 1
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "VERWENDUNGSHINWEISE FUER SCHULUNGEN:" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "- Admin-Screenshots: docs\schulung\screenshots\admin\" -ForegroundColor White
|
|
Write-Host "- Benutzer-Screenshots: docs\schulung\screenshots\benutzer\" -ForegroundColor White
|
|
Write-Host "- Oeffentliche Screenshots: docs\schulung\screenshots\oeffentlich\" -ForegroundColor White
|
|
Write-Host "- Verschiedene Aufloesungen in Unterordnern verfuegbar" -ForegroundColor White
|
|
Write-Host "- Perfekt fuer PowerPoint-Praesentationen geeignet" -ForegroundColor White
|
|
|
|
Write-Host ""
|
|
Write-Host "TIPPS FUER PRAESENTATIONEN:" -ForegroundColor Yellow
|
|
Write-Host "- Desktop-Screenshots fuer Hauptpraesentationen verwenden" -ForegroundColor White
|
|
Write-Host "- Mobile-Screenshots fuer Responsive-Design zeigen" -ForegroundColor White
|
|
Write-Host "- Admin-Ordner fuer Administrator-Schulungen" -ForegroundColor White
|
|
Write-Host "- Benutzer-Ordner fuer allgemeine Mitarbeiterschulungen" -ForegroundColor White
|
|
|
|
Write-Host ""
|
|
Write-Host "Bei Problemen:" -ForegroundColor Magenta
|
|
Write-Host "- Log-Datei pruefen: screenshot_tool.log" -ForegroundColor White
|
|
Write-Host "- Server laeuft auf korrekter URL?" -ForegroundColor White
|
|
Write-Host "- Admin-Zugangsdaten korrekt?" -ForegroundColor White
|
|
Write-Host "- ChromeDriver installiert?" -ForegroundColor White
|
|
|
|
exit $exitCode |