tri_94 Posted March 25, 2020 Posted March 25, 2020 (edited) Hi there I've got the following code with works as i require, however i would perfer not to use Out-GridView for displaying. I would prefer a really basic Text window for chats and under a box to enter text. Like the code below creates. I just can't seem to work out how to put the two together as when i have tried the GUI doesn't appear only the gridview. Im sure if you know how this is a very simple fix. Please help Many Thanks <# This form was created using POSHGUI.com a free online gui designer for PowerShell .NAME Untitled #> Add-Type -AssemblyName System.Windows.Forms [system.Windows.Forms.Application]::EnableVisualStyles() $Form = New-Object system.Windows.Forms.Form $Form.ClientSize = '859,676' $Form.text = "Form" $Form.TopMost = $false $ListView1 = New-Object system.Windows.Forms.ListView $ListView1.text = "listView" $ListView1.width = 787 $ListView1.height = 461 $ListView1.location = New-Object System.Drawing.Point(31,19) $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.width = 787 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(32,516) $TextBox1.Font = 'Microsoft Sans Serif,10' $Form.controls.AddRange(@($ListView1,$TextBox1)) #Write your logic code here [void]$Form.ShowDialog() ------------------------------------------------- Chatroom Code below $ServerShare = "\\Share" 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 } Enter-Chat -ChatChannelName RemoteSupport -Name User -ShowOldPosts Edited March 25, 2020 by tri_94
HPlum78 Posted March 25, 2020 Posted March 25, 2020 I love me a PowerShell, a lot some might say.... Before I roll my sleeves up and sink my arms into this particular script can you just tell me why?
tri_94 Posted March 25, 2020 Author Posted March 25, 2020 (edited) The reasons why is at current it opens the grid view doesn't auto scroll, You have to type in the powershell window so have to have both showing. When your busy doing something else its two easy to miss messages. It not about it looking nice, just really want to be able to use it in a single form. Edited March 25, 2020 by tri_94
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now