Created
October 25, 2014 02:24
-
-
Save lazywinadmin/0cd57fee94607ace5bc3 to your computer and use it in GitHub Desktop.
textbox_paste_clipboard.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------ | |
# Source File Information (DO NOT MODIFY) | |
# Source ID: 7cc35deb-97f1-4821-9fac-1339de8a644c | |
# Source File: C:\Users\Francois-Xavier\SkyDrive\Scripts\PowerShell\GitHub\PowerShellGUI\_Examples_Winforms\ClipBoard_Paste.psf | |
#------------------------------------------------------------------------ | |
<# | |
.NOTES | |
-------------------------------------------------------------------------------- | |
Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.71 | |
Generated on: 2014-10-24 10:21 PM | |
Generated by: Francois-Xavier Cat | |
Organization: LazyWinAdmin.com | |
-------------------------------------------------------------------------------- | |
.DESCRIPTION | |
GUI script generated by PowerShell Studio 2014 | |
#> | |
#---------------------------------------------- | |
#region Application Functions | |
#---------------------------------------------- | |
function OnApplicationLoad { | |
#Note: This function is not called in Projects | |
#Note: This function runs before the form is created | |
#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path | |
#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList) | |
#Important: Form controls cannot be accessed in this function | |
#TODO: Add modules and custom code to validate the application load | |
return $true #return true for success or false for failure | |
} | |
function OnApplicationExit { | |
#Note: This function is not called in Projects | |
#Note: This function runs after the form is closed | |
#TODO: Add custom code to clean up and unload modules when the application exits | |
$script:ExitCode = 0 #Set the exit code for the Packager | |
} | |
#endregion Application Functions | |
#---------------------------------------------- | |
# Generated Form Function | |
#---------------------------------------------- | |
function Call-ClipBoard_Paste_psf { | |
#---------------------------------------------- | |
#region Import the Assemblies | |
#---------------------------------------------- | |
[void][reflection.assembly]::Load('mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | |
[void][reflection.assembly]::Load('System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | |
[void][reflection.assembly]::Load('System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | |
#endregion Import Assemblies | |
#---------------------------------------------- | |
#region Generated Form Objects | |
#---------------------------------------------- | |
[System.Windows.Forms.Application]::EnableVisualStyles() | |
$form1 = New-Object 'System.Windows.Forms.Form' | |
$textbox1 = New-Object 'System.Windows.Forms.TextBox' | |
$buttonPasteClipboard = New-Object 'System.Windows.Forms.Button' | |
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' | |
#endregion Generated Form Objects | |
#---------------------------------------------- | |
# User Generated Script | |
#---------------------------------------------- | |
function OnApplicationLoad { | |
#Note: This function is not called in Projects | |
#Note: This function runs before the form is created | |
#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path | |
#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList) | |
#Important: Form controls cannot be accessed in this function | |
#TODO: Add modules and custom code to validate the application load | |
return $true #return true for success or false for failure | |
} | |
function OnApplicationExit { | |
#Note: This function is not called in Projects | |
#Note: This function runs after the form is closed | |
#TODO: Add custom code to clean up and unload modules when the application exits | |
$script:ExitCode = 0 #Set the exit code for the Packager | |
} | |
$form1_Load={ | |
#TODO: Initialize Form Controls here | |
} | |
$buttonPasteClipboard_Click={ | |
$textbox1.Text = [Windows.Clipboard]::GetText() | |
} | |
# --End User Generated Script-- | |
#---------------------------------------------- | |
#region Generated Events | |
#---------------------------------------------- | |
$Form_StateCorrection_Load= | |
{ | |
#Correct the initial state of the form to prevent the .Net maximized form issue | |
$form1.WindowState = $InitialFormWindowState | |
} | |
$Form_Cleanup_FormClosed= | |
{ | |
#Remove all event handlers from the controls | |
try | |
{ | |
$buttonPasteClipboard.remove_Click($buttonPasteClipboard_Click) | |
$form1.remove_Load($form1_Load) | |
$form1.remove_Load($Form_StateCorrection_Load) | |
$form1.remove_FormClosed($Form_Cleanup_FormClosed) | |
} | |
catch [Exception] | |
{ } | |
} | |
#endregion Generated Events | |
#---------------------------------------------- | |
#region Generated Form Code | |
#---------------------------------------------- | |
$form1.SuspendLayout() | |
# | |
# form1 | |
# | |
$form1.Controls.Add($textbox1) | |
$form1.Controls.Add($buttonPasteClipboard) | |
$form1.ClientSize = '175, 68' | |
$form1.MaximumSize = '191, 107' | |
$form1.MinimumSize = '191, 107' | |
$form1.Name = "form1" | |
$form1.Text = "Form" | |
$form1.add_Load($form1_Load) | |
# | |
# textbox1 | |
# | |
$textbox1.Location = '12, 42' | |
$textbox1.Name = "textbox1" | |
$textbox1.Size = '155, 20' | |
$textbox1.TabIndex = 1 | |
# | |
# buttonPasteClipboard | |
# | |
$buttonPasteClipboard.Location = '12, 12' | |
$buttonPasteClipboard.Name = "buttonPasteClipboard" | |
$buttonPasteClipboard.Size = '155, 23' | |
$buttonPasteClipboard.TabIndex = 0 | |
$buttonPasteClipboard.Text = "Paste Clipboard" | |
$buttonPasteClipboard.UseVisualStyleBackColor = $True | |
$buttonPasteClipboard.add_Click($buttonPasteClipboard_Click) | |
$form1.ResumeLayout() | |
#endregion Generated Form Code | |
#---------------------------------------------- | |
#Save the initial state of the form | |
$InitialFormWindowState = $form1.WindowState | |
#Init the OnLoad event to correct the initial state of the form | |
$form1.add_Load($Form_StateCorrection_Load) | |
#Clean up the control events | |
$form1.add_FormClosed($Form_Cleanup_FormClosed) | |
#Show the Form | |
return $form1.ShowDialog() | |
} #End Function | |
#Call OnApplicationLoad to initialize | |
if((OnApplicationLoad) -eq $true) | |
{ | |
#Call the form | |
Call-ClipBoard_Paste_psf | Out-Null | |
#Perform cleanup | |
OnApplicationExit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment