Skip to content

Instantly share code, notes, and snippets.

@gioxx
Created April 12, 2017 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gioxx/b74a21fb682f76ea30a463595c113aa7 to your computer and use it in GitHub Desktop.
Save gioxx/b74a21fb682f76ea30a463595c113aa7 to your computer and use it in GitHub Desktop.
Genera una MessageBox (Visual Basic) per mostrare a video un testo di "promemoria".
param (
[Parameter(Mandatory=$true)]
[String]$MsgTitle,
[Parameter(Mandatory=$true)]
[String]$MsgText
)
Add-Type -AssemblyName Microsoft.VisualBasic
$showWindowAsync = Add-Type –memberDefinition @”
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
“@ -name “Win32ShowWindowAsync” -namespace Win32Functions –passThru
function Show-PowerShell() { [void]$showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 10) }
function Hide-PowerShell() { [void]$showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 2) }
Clear-Host
Hide-PowerShell
$MsgBox = [Microsoft.VisualBasic.Interaction]
[void] $MsgBox::MsgBox($MsgText,0,$MsgTitle)
Show-PowerShell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment