natalie.solero
Goto Top

Zwei Powershell Fenster in eine GUI zusammenführen

Hallo,
bitte nicht wundern, ich habe eine Übersetzer benutzt.
Ich habe ein Script von Powershell für Chat. Das funktioniert auch. Nach dem Start erhalte ich zwei Fenster. Für Eingabe und Erhalt der Nachricht. Wie kann ich jetzt beide in eine kleine GUI packen, das ich ein Fenster habe also übereinander zum Beispiel.
Danke für die Hilfe face-smile
$ServerShare = "C:\temp"  

function Enter-Chat 
{
  param
  (
    [Parameter(Mandatory)]
    [string]
    $ChatChannelName,
    
    [string]
    $Name = $env:USERNAME,
    
    [Switch]
    $ShowOldPosts,
    
    $HomeShare = $ServerShare
    
  )
  
  if ($ShowOldPosts)
  {
    $Option = ''  
  }
  else
  {
    $Option = '-Tail 0'  
  }

  $Path = Join-Path -Path $HomeShare -ChildPath "$ChatChannelName.txt"  
  $exists = Test-Path -Path $Path
  if ($exists -eq $false)
  {
    $null = New-Item -Path $Path -Force -ItemType File
  }

  $process = Start-Process -FilePath powershell -ArgumentList "-noprofile -windowstyle hidden -command Get-COntent -Path '$Path' $Option -Wait | Out-GridView -Title 'Chat: [$ChatChannelName]'" -PassThru  

  Write-Host "To exit, enter: quit"  
  "[$Name entered the chat]" | Add-Content -Path $Path  
  do
  {
    Write-Host "[$ChatChannelName]: " -ForegroundColor Green -NoNewline  
    $inputText = Read-Host 
    
    $isStopCommand = 'quit','exit','stop','leave' -contains $inputText  
    if ($isStopCommand -eq $false)
    {
      "[$Name] $inputText" | Add-Content -Path $Path  
    }
    
    
  } until ($isStopCommand -eq $true)
  "[$Name left the chat]" | Add-Content -Path $Path  
  
  $process | Stop-Process
}
    
function Get-ChatChannel
{
  param
  (
    $HomeShare = $ServerShare
    
  )

  Get-ChildItem -Path $HomeShare -Filter *.txt -File |
    ForEach-Object {
      [PSCustomObject]@{
        ChannelName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
        LastActive = $_.LastWriteTime
        Started = $_.CreationTime
      }
    }
}    

$Username = read-host "Username"  
Enter-Chat -ChatChannelName Chat -Name $username -ShowOldPosts
1

Content-Key: 2488831336

Url: https://administrator.de/contentid/2488831336

Printed on: April 25, 2024 at 11:04 o'clock

Mitglied: 1915348599
1915348599 Apr 13, 2022 updated at 08:18:20 (UTC)
Goto Top
Member: Frank
Frank Apr 13, 2022 at 09:41:47 (UTC)
Goto Top
Bitte die Frage auf der englischen Seite beantworten: Move or merge two windows into one gui

Gruß
Frank