├── DPI Scaling.txt
├── Designer.fbs
├── Designer
├── Designer.ps1
├── Events.ps1
└── Finds.txt
├── Examples
├── WPF Window Fuse.fbs
├── WPF Window Fuse
│ ├── Events.ps1
│ ├── Finds.txt
│ └── WPF Window Fuse.ps1
├── Window Spy.fbs
├── Window Spy
│ ├── Events.ps1
│ ├── Finds.txt
│ └── Window Spy.ps1
├── XAMLPad Express.fbs
└── XAMLPad Express
│ ├── Events.ps1
│ ├── Finds.txt
│ └── XAMLPad Express.ps1
├── FastColoredTextBox.dll
├── FastColoredTextBoxLicense.txt
├── PSGetModuleInfo.xml
├── README.md
├── WinFormsCreatorLicense.txt
├── famfamfam.md
├── functions
├── Dependencies.ps1
└── functions.psm1
├── license.md
├── powershell-designer.nuspec
├── powershell-designer.psd1
└── powershell-designer.psm1
/DPI Scaling.txt:
--------------------------------------------------------------------------------
1 | For simple projects, add 'DPIAware' to the Tag property on the Form to attempt a scaling fix on high resolution displays.
2 | You may have to multiply resize event values by $ctscale (height, width, top, left or size[] location[]).
3 | Sometimes the export does not include a 'Size' properly in the XML if the control has not been resized. Resize all controls by at least one pixel.
4 | To enable VisualStyle, add 'VisualStyle' to the Tag property on the Form.
5 | See Calc.fbs for an example.
6 |
7 | Tags are comma seperated.
--------------------------------------------------------------------------------
/Designer.fbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
378 |
--------------------------------------------------------------------------------
/Designer/Finds.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brandoncomputer/powershell-designer/95199dfd51eab1c88f9008a0ef4fbc689610c54d/Designer/Finds.txt
--------------------------------------------------------------------------------
/Examples/WPF Window Fuse.fbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Examples/WPF Window Fuse/Events.ps1:
--------------------------------------------------------------------------------
1 | #region Images
2 |
3 | #endregion
4 |
5 | ConvertFrom-WPFXaml -xaml @"
6 |
14 |
15 |
16 |
17 |
18 |
19 | "@
20 |
21 | $Button.Add_Click({Show-InformationDialog -Message 'Hello' -Title $Title})
22 |
23 | $MainWindow.Show()
24 | $MainWindow.Top = 0
25 | $MainWindow.Left = 0
26 |
27 | Set-WindowParent (Get-WindowExists "MainWindow") $MainForm.Handle
28 |
29 | #end region
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Examples/WPF Window Fuse/Finds.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brandoncomputer/powershell-designer/95199dfd51eab1c88f9008a0ef4fbc689610c54d/Examples/WPF Window Fuse/Finds.txt
--------------------------------------------------------------------------------
/Examples/WPF Window Fuse/WPF Window Fuse.ps1:
--------------------------------------------------------------------------------
1 | #region VDS
2 | $RunSpace = [RunspaceFactory]::CreateRunspacePool(); $RunSpace.ApartmentState = "STA"; $RunSpace.Open(); $PowerShell = [powershell]::Create();$PowerShell.RunspacePool = $RunSpace; [void]$PowerShell.AddScript({
3 |
4 | function ConvertFrom-WinFormsXML {
5 | <#
6 | .SYNOPSIS
7 | Opens a form from XAML in the format specified by 'powershell-designer'
8 | or its predecessor, PowerShell WinForms Creator
9 |
10 | .DESCRIPTION
11 | This function opens a form from XAML in the format specified by 'powershell-designer'
12 | or its predecessor, PowerShell WinForms Creator
13 |
14 | .PARAMETER XML
15 | The XML object or XML string specifying the parameters for the form object
16 |
17 | .PARAMETER Reference
18 | This function recursively calls itself. Internal parameter for child
19 | objects, not typically called programatically. Also this function is
20 | maintained for legacy compatibility PowerShell WinForm Creator, which
21 | does require the call in some instances due to not creating automatic
22 | variables.
23 |
24 | .PARAMETER Supress
25 | This function recursively calls itself. Internal parameter for child
26 | objects, not typically called programatically.
27 |
28 | .EXAMPLE
29 | ConvertFrom-WinFormsXML -Xml @"
30 |
33 | "@
34 |
35 | .EXAMPLE
36 | ConvertFrom-WinFormsXML @"
37 |
40 | "@
41 |
42 | .EXAMPLE
43 | $content = [xml](get-content $Path)
44 | ConvertFrom-WinformsXML -xml $content.Data.Form.OuterXml
45 |
46 | .EXAMPLE
47 | $content = [xml](get-content $Path)
48 | ConvertFrom-WinformsXML $content.Data.Form.OuterXml
49 |
50 | .INPUTS
51 | Xml as String || Xml as xml
52 |
53 | .OUTPUTS
54 | Object
55 |
56 | .NOTES
57 | Each object created has a variable created to access the object
58 | according to its Name attribute e.g. $Button1
59 | #>
60 | param(
61 | [Parameter(Mandatory)]
62 | $Xml,
63 | [string]$Reference,
64 | $ParentControl,
65 | [switch]$Suppress
66 | )
67 | try {
68 | if ( $Xml.GetType().Name -eq 'String' ) {
69 | $Xml = ([xml]$Xml).ChildNodes
70 | }
71 | $Xml.Attributes | ForEach-Object {
72 | $attrib = $_
73 | $attribName = $_.ToString()
74 | $attrib = $_
75 | $attribName = $_.ToString()
76 | if ($attribName -eq 'Tag'){
77 | if (($attrib.Value | Out-String).Contains("VisualStyle")) {
78 | Set-EnableVisualStyle
79 | }
80 | if (($attrib.Value | Out-String).Contains("DPIAware")) {
81 | Set-DPIAware
82 | }
83 | }
84 | }
85 | $Cskip = $false
86 | if ($attribName -eq 'ControlType') {
87 | $newControl = New-Object ($attrib.Value | Out-String)
88 | $Cskip = $true
89 | }
90 | switch ($Xml.ToString()){
91 | 'SplitterPanel'{}
92 | 'Form'{$newControl = [vdsForm] @{
93 | ClientSize = New-Object System.Drawing.Point 0,0}
94 | $Cskip = $true
95 | }
96 | 'String'{$newControl = New-Object System.String
97 | $Cskip = $true}
98 | 'WebView2'{$newControl = New-Object Microsoft.Web.WebView2.WinForms.WebView2
99 | $Cskip = $true}
100 | 'FastColoredTextBox'{$newControl = New-Object FastColoredTextBoxNS.FastColoredTextBox
101 | $Cskip = $true}
102 | default{
103 | if ($Cskip -eq $false){
104 | $newControl = New-Object System.Windows.Forms.$($Xml.ToString())}}
105 | }
106 | if ( $ParentControl ) {
107 | if ( $Xml.ToString() -eq 'ToolStrip' ) {
108 | $newControl = New-Object System.Windows.Forms.MenuStrip
109 | $ParentControl.Controls.Add($newControl)
110 | }
111 | else {
112 | if ( $Xml.ToString() -match "^ToolStrip" ) {
113 | if ( $ParentControl.GetType().Name -match "^ToolStrip" ) {
114 | [void]$ParentControl.DropDownItems.Add($newControl)
115 | }
116 | else {
117 | [void]$ParentControl.Items.Add($newControl)
118 | }
119 | }
120 | elseif ( $Xml.ToString() -eq 'ContextMenuStrip' ) {
121 | $ParentControl.ContextMenuStrip = $newControl
122 | }
123 | elseif ( $Xml.ToString() -eq 'SplitterPanel' ) {
124 | $newControl = $ParentControl.$($Xml.Name.Split('_')[-1])
125 | }
126 | else {
127 | $ParentControl.Controls.Add($newControl)
128 | }
129 | }
130 | }
131 |
132 | $Xml.Attributes | ForEach-Object {
133 | $attrib = $_
134 | $attribName = $_.ToString()
135 | $attrib = $_
136 | $attribName = $_.ToString()
137 | if ($attribName -eq 'Opacity'){
138 | $n = $attrib.Value.split('%')
139 | $attrib.value = $n[0]/100
140 | }
141 | if ($attribName -eq 'ColumnWidth'){
142 | $attrib.Value = [math]::round(($attrib.Value / 1) * $ctscale)
143 | }
144 | if ($attribName -eq 'Size'){
145 | $n = $attrib.Value.split(',')
146 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
147 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
148 | if ("$($n[0]),$($n[1])" -ne ",") {
149 | $attrib.Value = "$($n[0]),$($n[1])"
150 | }
151 | }
152 | if ($attribName -eq 'Location'){
153 | $n = $attrib.Value.split(',')
154 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
155 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
156 | if ("$($n[0]),$($n[1])" -ne ",") {
157 | $attrib.Value = "$($n[0]),$($n[1])"
158 | }
159 | }
160 | if ($attribName -eq 'MaximumSize'){
161 | $n = $attrib.Value.split(',')
162 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
163 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
164 | if ("$($n[0]),$($n[1])" -ne ",") {
165 | $attrib.Value = "$($n[0]),$($n[1])"
166 | }
167 | }
168 | if ($attribName -eq 'MinimumSize'){
169 | $n = $attrib.Value.split(',')
170 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
171 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
172 | if ("$($n[0]),$($n[1])" -ne ",") {
173 | $attrib.Value = "$($n[0]),$($n[1])"
174 | }
175 | }
176 | if ($attribName -eq 'ImageScalingSize'){
177 | $n = $attrib.Value.split(',')
178 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
179 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
180 | if ("$($n[0]),$($n[1])" -ne ",") {
181 | $attrib.Value = "$($n[0]),$($n[1])"
182 | }
183 | }
184 |
185 | if ($attribName -eq 'TileSize'){
186 | $n = $attrib.Value.split(',')
187 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
188 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
189 | if ("$($n[0]),$($n[1])" -ne ",") {
190 | $attrib.Value = "$($n[0]),$($n[1])"
191 | }
192 | }
193 |
194 | if ( $Script:specialProps.Array -contains $attribName ) {
195 | if ( $attribName -eq 'Items' ) {
196 | $($_.Value -replace "\|\*BreakPT\*\|","`n").Split("`n") | ForEach-Object {
197 | [void]$newControl.Items.Add($_)
198 | }
199 | }
200 | else {
201 | # Other than Items only BoldedDate properties on MonthCalendar control
202 | $methodName = "Add$($attribName)" -replace "s$"
203 | $($_.Value -replace "\|\*BreakPT\*\|","`n").Split("`n") | ForEach-Object {
204 | $newControl.$attribName.$methodName($_)
205 | }
206 | }
207 | }
208 | else {
209 | switch ($attribName) {
210 | ControlType{}
211 | FlatAppearance {
212 | $attrib.Value.Split('|') | ForEach-Object {
213 | $newControl.FlatAppearance.$($_.Split('=')[0]) = $_.Split('=')[1]
214 | }
215 | }
216 | default {
217 | if ( $null -ne $newControl.$attribName ) {
218 | if ( $newControl.$attribName.GetType().Name -eq 'Boolean' ) {
219 | if ( $attrib.Value -eq 'True' ) {
220 | $value = $true
221 | }
222 | else {
223 | $value = $false
224 | }
225 | }
226 | else {
227 | $value = $attrib.Value
228 | }
229 | }
230 | else {
231 | $value = $attrib.Value
232 | }
233 | switch ($xml.ToString()) {
234 | "FolderBrowserDialog" {
235 | if ($xml.Description) {
236 | $newControl.Description = $xml.Description
237 | }
238 | if ($xml.Tag) {
239 | $newControl.Tag = $xml.Tag
240 | }
241 | if ($xml.RootFolder) {
242 | $newControl.RootFolder = $xml.RootFolder
243 | }
244 | if ($xml.SelectedPath) {
245 | $newControl.SelectedPath = $xml.SelectedPath
246 | }
247 | if ($xml.ShowNewFolderButton) {
248 | $newControl.ShowNewFolderButton = $xml.ShowNewFolderButton
249 | }
250 | }
251 | "OpenFileDialog" {
252 | if ($xml.AddExtension) {
253 | $newControl.AddExtension = $xml.AddExtension
254 | }
255 | if ($xml.AutoUpgradeEnabled) {
256 | $newControl.AutoUpgradeEnabled = $xml.AutoUpgradeEnabled
257 | }
258 | if ($xml.CheckFileExists) {
259 | $newControl.CheckFileExists = $xml.CheckFileExists
260 | }
261 | if ($xml.CheckPathExists) {
262 | $newControl.CheckPathExists = $xml.CheckPathExists
263 | }
264 | if ($xml.DefaultExt) {
265 | $newControl.DefaultExt = $xml.DefaultExt
266 | }
267 | if ($xml.DereferenceLinks) {
268 | $newControl.DereferenceLinks = $xml.DereferenceLinks
269 | }
270 | if ($xml.FileName) {
271 | $newControl.FileName = $xml.FileName
272 | }
273 | if ($xml.Filter) {
274 | $newControl.Filter = $xml.Filter
275 | }
276 | if ($xml.FilterIndex) {
277 | $newControl.FilterIndex = $xml.FilterIndex
278 | }
279 | if ($xml.InitialDirectory) {
280 | $newControl.InitialDirectory = $xml.InitialDirectory
281 | }
282 | if ($xml.Multiselect) {
283 | $newControl.Multiselect = $xml.Multiselect
284 | }
285 | if ($xml.ReadOnlyChecked) {
286 | $newControl.ReadOnlyChecked = $xml.ReadOnlyChecked
287 | }
288 | if ($xml.RestoreDirectory) {
289 | $newControl.RestoreDirectory = $xml.RestoreDirectory
290 | }
291 | if ($xml.ShowHelp) {
292 | $newControl.ShowHelp = $xml.ShowHelp
293 | }
294 | if ($xml.ShowReadOnly) {
295 | $newControl.ShowReadOnly = $xml.ShowReadOnly
296 | }
297 | if ($xml.SupportMultiDottedExtensions) {
298 | $newControl.SupportMultiDottedExtensions = $xml.SupportMultiDottedExtensions
299 | }
300 | if ($xml.Tag) {
301 | $newControl.Tag = $xml.Tag
302 | }
303 | if ($xml.Title) {
304 | $newControl.Title = $xml.Title
305 | }
306 | if ($xml.ValidateNames) {
307 | $newControl.ValidateNames = $xml.ValidateNames
308 | }
309 | }
310 | "ColorDialog" {
311 | if ($xml.AllowFullOpen) {
312 | $newControl.AllowFullOpen = $xml.AllowFullOpen
313 | }
314 | if ($xml.AnyColor) {
315 | $newControl.AnyColor = $xml.AnyColor
316 | }
317 | if ($xml.Color) {
318 | $newControl.Color = $xml.Color
319 | }
320 | if ($xml.FullOpen) {
321 | $newControl.FullOpen = $xml.FullOpen
322 | }
323 | if ($xml.ShowHelp) {
324 | $newControl.ShowHelp = $xml.ShowHelp
325 | }
326 | if ($xml.SolidColorOnly) {
327 | $newControl.SolidColorOnly = $xml.SolidColorOnly
328 | }
329 | if ($xml.Tag) {
330 | $newControl.Tag = $xml.Tag
331 | }
332 | }
333 | "FontDialog" {
334 | if ($xml.AllowScriptChange) {
335 | $newControl.AllowScriptChange = $xml.AllowScriptChange
336 | }
337 | if ($xml.AllowSimulations) {
338 | $newControl.AllowSimulations = $xml.AllowSimulations
339 | }
340 | if ($xml.AllowVectorFonts) {
341 | $newControl.AllowVectorFonts = $xml.AllowVectorFonts
342 | }
343 | if ($xml.Color) {
344 | $newControl.Color = $xml.Color
345 | }
346 | if ($xml.FixedPitchOnly) {
347 | $newControl.FixedPitchOnly = $xml.FixedPitchOnly
348 | }
349 | if ($xml.Font) {
350 | $newControl.Font = $xml.Font
351 | }
352 | if ($xml.FontMustExists) {
353 | $newControl.FontMustExists = $xml.FontMustExists
354 | }
355 | if ($xml.MaxSize) {
356 | $newControl.MaxSize = $xml.MaxSize
357 | }
358 | if ($xml.MinSize) {
359 | $newControl.MinSize = $xml.MinSize
360 | }
361 | if ($xml.ScriptsOnly) {
362 | $newControl.ScriptsOnly = $xml.ScriptsOnly
363 | }
364 | if ($xml.ShowApply) {
365 | $newControl.ShowApply = $xml.ShowApply
366 | }
367 | if ($xml.ShowColor) {
368 | $newControl.ShowColor = $xml.ShowColor
369 | }
370 | if ($xml.ShowEffects) {
371 | $newControl.ShowEffects = $xml.ShowEffects
372 | }
373 | if ($xml.ShowHelp) {
374 | $newControl.ShowHelp = $xml.ShowHelp
375 | }
376 | if ($xml.Tag) {
377 | $newControl.Tag = $xml.Tag
378 | }
379 | }
380 | "PageSetupDialog" {
381 | if ($xml.AllowMargins) {
382 | $newControl.AllowMargins = $xml.AllowMargins
383 | }
384 | if ($xml.AllowOrientation) {
385 | $newControl.AllowOrientation = $xml.AllowOrientation
386 | }
387 | if ($xml.AllowPaper) {
388 | $newControl.AllowPaper = $xml.AllowPaper
389 | }
390 | if ($xml.Document) {
391 | $newControl.Document = $xml.Document
392 | }
393 | if ($xml.EnableMetric) {
394 | $newControl.EnableMetric = $xml.EnableMetric
395 | }
396 | if ($xml.MinMargins) {
397 | $newControl.MinMargins = $xml.MinMargins
398 | }
399 | if ($xml.ShowHelp) {
400 | $newControl.ShowHelp = $xml.ShowHelp
401 | }
402 | if ($xml.ShowNetwork) {
403 | $newControl.ShowNetwork = $xml.ShowNetwork
404 | }
405 | if ($xml.Tag) {
406 | $newControl.Tag = $xml.Tag
407 | }
408 | }
409 | "PrintDialog" {
410 | if ($xml.AllowCurrentPage) {
411 | $newControl.AllowCurrentPage = $xml.AllowCurrentPage
412 | }
413 | if ($xml.AllowPrintToFile) {
414 | $newControl.AllowPrintToFile = $xml.AllowPrintToFile
415 | }
416 | if ($xml.AllowSelection) {
417 | $newControl.AllowSelection = $xml.AllowSelection
418 | }
419 | if ($xml.AllowSomePages) {
420 | $newControl.AllowSomePages = $xml.AllowSomePages
421 | }
422 | if ($xml.Document) {
423 | $newControl.Document = $xml.Document
424 | }
425 | if ($xml.PrintToFile) {
426 | $newControl.PrintToFile = $xml.PrintToFile
427 | }
428 | if ($xml.ShowHelp) {
429 | $newControl.ShowHelp = $xml.ShowHelp
430 | }
431 | if ($xml.ShowNetwork) {
432 | $newControl.ShowNetwork = $xml.ShowNetwork
433 | }
434 | if ($xml.Tag) {
435 | $newControl.Tag = $xml.Tag
436 | }
437 | if ($xml.UseEXDialog) {
438 | $newControl.UseEXDialog = $xml.UseEXDialog
439 | }
440 | }
441 | "PrintPreviewDialog" {
442 | if ($xml.AutoSizeMode) {
443 | $newControl.AutoSizeMode = $xml.AutoSizeMode
444 | }
445 | if ($xml.Document) {
446 | $newControl.Document = $xml.Document
447 | }
448 | if ($xml.MainMenuStrip) {
449 | $newControl.MainMenuStrip = $xml.MainMenuStrip
450 | }
451 | if ($xml.ShowIcon) {
452 | $newControl.ShowIcon = $xml.ShowIcon
453 | }
454 | if ($xml.UseAntiAlias) {
455 | $newControl.UseAntiAlias = $xml.UseAntiAlias
456 | }
457 | }
458 | "SaveFileDialog" {
459 | if ($xml.AddExtension) {
460 | $newControl.AddExtension = $xml.AddExtension
461 | }
462 | if ($xml.AutoUpgradeEnabled) {
463 | $newControl.AutoUpgradeEnabled = $xml.AutoUpgradeEnabled
464 | }
465 | if ($xml.CheckFileExists) {
466 | $newControl.CheckFileExists = $xml.CheckFileExists
467 | }
468 | if ($xml.CheckPathExists) {
469 | $newControl.CheckPathExists = $xml.CheckPathExists
470 | }
471 | if ($xml.CreatePrompt) {
472 | $newControl.CreatePrompt = $xml.CreatePrompt
473 | }
474 | if ($xml.DefaultExt) {
475 | $newControl.DefaultExt = $xml.DefaultExt
476 | }
477 | if ($xml.DereferenceLinks) {
478 | $newControl.DereferenceLinks = $xml.DereferenceLinks
479 | }
480 | if ($xml.FileName) {
481 | $newControl.FileName = $xml.FileName
482 | }
483 | if ($xml.Filter) {
484 | $newControl.Filter = $xml.Filter
485 | }
486 | if ($xml.FilterIndex) {
487 | $newControl.FilterIndex = $xml.FilterIndex
488 | }
489 | if ($xml.InitialDirectory) {
490 | $newControl.InitialDirectory = $xml.InitialDirectory
491 | }
492 | if ($xml.Multiselect) {
493 | $newControl.OverwritePrompt = $xml.OverwritePrompt
494 | }
495 | if ($xml.RestoreDirectory) {
496 | $newControl.RestoreDirectory = $xml.RestoreDirectory
497 | }
498 | if ($xml.ShowHelp) {
499 | $newControl.ShowHelp = $xml.ShowHelp
500 | }
501 | if ($xml.SupportMultiDottedExtensions) {
502 | $newControl.SupportMultiDottedExtensions = $xml.SupportMultiDottedExtensions
503 | }
504 | if ($xml.Tag) {
505 | $newControl.Tag = $xml.Tag
506 | }
507 | if ($xml.Title) {
508 | $newControl.Title = $xml.Title
509 | }
510 | if ($xml.ValidateNames) {
511 | $newControl.ValidateNames = $xml.ValidateNames
512 | }
513 | }
514 | "Timer" {
515 | if ($xml.Enabled) {
516 | $newControl.Enabled = $xml.Enabled
517 | }
518 | if ($xml.Interval) {
519 | $newControl.Interval = $xml.Interval
520 | }
521 | if ($xml.Tag) {
522 | $newControl.Tag = $xml.Tag
523 | }
524 | }
525 | default {
526 | $newControl.$attribName = $value
527 | }
528 | }
529 | }
530 | }
531 | }
532 | if ($xml.Name){
533 | if ((Test-Path variable:global:"$($xml.Name)") -eq $False) {
534 | New-Variable -Name $xml.Name -Scope global -Value $newControl | Out-Null
535 | }
536 | }
537 | if (( $attrib.ToString() -eq 'Name' ) -and ( $Reference -ne '' )) {
538 | try {
539 | $refHashTable = Get-Variable -Name $Reference -Scope global -ErrorAction Stop
540 | }
541 | catch {
542 | New-Variable -Name $Reference -Scope global -Value @{} | Out-Null
543 | $refHashTable = Get-Variable -Name $Reference -Scope global -ErrorAction SilentlyContinue
544 | }
545 | $refHashTable.Value.Add($attrib.Value,$newControl)
546 | }
547 | }
548 | if ( $Xml.ChildNodes ) {
549 | $Xml.ChildNodes | ForEach-Object {ConvertFrom-WinformsXML -Xml $_ -ParentControl $newControl -Reference $Reference -Suppress}
550 | }
551 | if ( $Suppress -eq $false ) {
552 | return $newControl
553 | }
554 | }
555 | catch {
556 | Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered adding $($Xml.ToString()) to $($ParentControl.Name)"
557 | }
558 | }
559 |
560 | function ConvertFrom-WPFXaml {
561 | <#
562 | .SYNOPSIS
563 | Transforms XAML string into a Windows Presentation Foundation window
564 |
565 | .DESCRIPTION
566 | This function transforms XAML string into a Windows Presentation
567 | Foundation window (ambiguous)
568 |
569 | .PARAMETER xaml
570 | The source XAML string to transform
571 |
572 | .EXAMPLE
573 | ConvertFrom-WPFXaml $xaml
574 |
575 | .EXAMPLE
576 | ConvertFrom-WPFXaml -xaml $xaml
577 |
578 | .EXAMPLE
579 | $xaml | ConvertFrom-WPFXaml
580 |
581 | .INPUTS
582 | xaml as String
583 |
584 | .OUTPUTS
585 | Windows.Markup.XamlReader and Global Variables for Controls within the window by Control Name
586 | #>
587 | [Alias("Assert-WPF")]
588 | [CmdletBinding()]
589 | param (
590 | [Parameter(Mandatory,
591 | ValueFromPipeline)]
592 | [string]$xaml
593 | )
594 | $xaml = $xaml -replace "x:Name", 'Name' -replace 'd:DesignHeight="\d*?"', '' -replace 'x:Class=".*?"', '' -replace 'mc:Ignorable="d"', '' -replace 'd:DesignWidth="\d*?"', ''
595 | [xml]$xaml = $xaml
596 | $presentation = [Windows.Markup.XamlReader]::Load((new-object System.Xml.XmlNodeReader $xaml))
597 | $xaml.SelectNodes("//*[@Name]") | %{
598 | Set-Variable -Name $_.Name.ToString() -Value $presentation.FindName($_.Name) -Scope global
599 | }
600 | return $presentation
601 | }
602 |
603 | function Get-CurrentDirectory {
604 | <#
605 | .SYNOPSIS
606 | Returns the current directory as string
607 |
608 | ALIASES
609 | Curdir
610 |
611 | .DESCRIPTION
612 | This function returns the current directory of the application as string.
613 |
614 | .EXAMPLE
615 | Write-Host Get-CurrentDirectory
616 |
617 | .OUTPUTS
618 | String
619 | #>
620 | [Alias("Curdir")]
621 | param()
622 | return (Get-Location | Select-Object -expandproperty Path | Out-String).Trim()
623 | }
624 |
625 | function Get-WindowExists {
626 | <#
627 | .SYNOPSIS
628 | Returns the handle of a window, or null if it doesn't exists
629 |
630 | ALIASES
631 | Winexists
632 |
633 | .DESCRIPTION
634 | This function returns the handle of a window, or null if it doesn't exists
635 |
636 | .PARAMETER Window
637 | The title of a window, the class of a window, or the window as a powershell object
638 |
639 | .EXAMPLE
640 | Set-WindowText (Get-WindowExists "Untitled - Notepad") "Hello World"
641 |
642 | .EXAMPLE
643 | Set-WindowText -handle (Get-WindowExists -window "Untitled - Notepad") -text "Hello World"
644 |
645 | .EXAMPLE
646 | ("Untitled - Notepad" | Get-WindowExists) | Set-WindowText -text "Hello World"
647 |
648 | .INPUTS
649 | Window as String
650 | #>
651 | [Alias("Winexists")]
652 | [CmdletBinding()]
653 | param (
654 | [Parameter(Mandatory,
655 | ValueFromPipeline)]
656 | [string]$Window
657 | )
658 | $class = [vds]::FindWindowByClass($Window)
659 | if ($class) {
660 | return $class/1
661 | }
662 | else {
663 | $title = [vds]::FindWindowByTitle($Window)
664 | if ($title){
665 | return $title/1
666 | }
667 | else {
668 | if ($Window.handle) {
669 | return $Window.handle
670 | }
671 | }
672 | }
673 | }
674 |
675 | function Invoke-Form {
676 | <#
677 | .SYNOPSIS
678 | Runs a form as an application.
679 |
680 | .DESCRIPTION
681 | Runs a form as an application. This differs from ShowDialog and Show.
682 |
683 | .PARAMETER Form
684 | The form to run as an application
685 |
686 | .EXAMPLE
687 | Invoke-Form $MainForm
688 |
689 | .EXAMPLE
690 | Invoke-Form -form $MainForm
691 |
692 | .EXAMPLE
693 | $MainWindow | Invoke-Form
694 |
695 | .INPUTS
696 | Form as Object
697 | #>
698 | [CmdletBinding()]
699 | param (
700 | [Parameter(Mandatory,
701 | ValueFromPipeline)]
702 | [object]$Form
703 | )
704 | [System.Windows.Forms.Application]::Run($Form) | Out-Null
705 | }
706 |
707 | function Move-Window {
708 | <#
709 | .SYNOPSIS
710 | Moves a window
711 |
712 | ALIASES
713 | Window-Position
714 |
715 | .DESCRIPTION
716 | This function moves a window per left, top, width and height parameters
717 |
718 | .PARAMETER Handle
719 | The handle of the window
720 |
721 | .PARAMETER Left
722 | The left position of the window
723 |
724 | .PARAMETER Top
725 | The top position of the window
726 |
727 | .PARAMETER Width
728 | The width of the window
729 |
730 | .PARAMETER Height
731 | The height of the window
732 |
733 | .EXAMPLE
734 | Move-Window -handle (Get-WindowExists "Untitled - Notepad") 10 100 1000 100
735 |
736 | .EXAMPLE
737 | Move-Window -handle (Get-WindowExists "Untitled - Notepad") -left 10 -height 100 -width 1000 -height 100
738 |
739 | .EXAMPLE
740 | (Get-WindowExists "Untitled - Notepad") | Move-Window -left 10 -height 100 -width 1000 -height 100
741 |
742 | .INPUTS
743 | Handle as Handle
744 | #>
745 | [Alias("Window-Position")]
746 | [CmdletBinding()]
747 | param (
748 | [Parameter(Mandatory,
749 | ValueFromPipeline)]
750 | [int]$Handle,
751 | [Parameter(Mandatory)]
752 | [int]$Left,
753 | [Parameter(Mandatory)]
754 | [int]$Top,
755 | [Parameter(Mandatory)]
756 | [int]$Width,
757 | [Parameter(Mandatory)]
758 | [int]$Height
759 | )
760 | [vds]::MoveWindow($Handle,$Left,$Top,$Width,$Height,$true)
761 | }
762 |
763 | function Set-ActiveWindow {
764 | <#
765 | .SYNOPSIS
766 | Sets the window as active
767 |
768 | ALIASES
769 | Window-Activate
770 |
771 | .DESCRIPTION
772 | This function sets the active window
773 |
774 | .PARAMETER Handle
775 | The handle of the window
776 |
777 | .EXAMPLE
778 | Set-ActiveWindow (Get-WindowExists "Untitled - Notepad")
779 |
780 | .EXAMPLE
781 | Set-ActiveWindow -handle (Get-WindowExists "Untitled - Notepad")
782 |
783 | .EXAMPLE
784 | (Get-WindowExists "Untitled - Notepad") | Set-ActiveWindow
785 |
786 | .INPUTS
787 | Handle as Handle
788 | #>
789 | [Alias("Window-Activate")]
790 | [CmdletBinding()]
791 | param (
792 | [Parameter(Mandatory,
793 | ValueFromPipeline)]
794 | [int]$Handle
795 | )
796 | [vds]::SetForegroundWindow($Handle)
797 | }
798 |
799 | function Set-DPIAware {
800 | <#
801 | .SYNOPSIS
802 | Causes the dialog window to be DPI Aware.
803 | .DESCRIPTION
804 | This function will call upon the windows application programming
805 | interface to cause the window to be DPI Aware.
806 | .EXAMPLE
807 | Set-DPIAware
808 | #>
809 | $vscreen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height
810 | [vds]::SetProcessDPIAware() | out-null
811 | $screen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height
812 | $global:ctscale = ($screen/$vscreen)
813 | }
814 |
815 | function Set-EnableVisualStyle {
816 | <#
817 | .SYNOPSIS
818 | Enables modern visual styles in the dialog window.
819 | .DESCRIPTION
820 | This function will call upon the windows application programming
821 | interface to apply modern visual style to the window.
822 | .EXAMPLE
823 | Set-EnableVisualStyle
824 | #>
825 | [vds]::SetCompat() | out-null
826 | }
827 |
828 | function Set-Types {
829 |
830 | <#
831 | .SYNOPSIS
832 | Various C# calls and references
833 | #>
834 | Add-Type -AssemblyName System.Windows.Forms,presentationframework, presentationcore, Microsoft.VisualBasic
835 |
836 | Add-Type @"
837 | using System;
838 | using System.Drawing;
839 | using System.Runtime.InteropServices;
840 | using System.Windows.Forms;
841 | using System.ComponentModel;
842 | using System.Collections.Generic;
843 |
844 | public class vds {
845 |
846 | public static void SetCompat()
847 | {
848 | // SetProcessDPIAware();
849 | Application.EnableVisualStyles();
850 | Application.SetCompatibleTextRenderingDefault(false);
851 | }
852 |
853 | [System.Runtime.InteropServices.DllImport("user32.dll")]
854 | public static extern bool SetProcessDPIAware();
855 |
856 | [DllImport("user32.dll")]
857 | public static extern bool InvertRect(IntPtr hDC, [In] ref RECT lprc);
858 |
859 | [DllImport("user32.dll")]
860 | public static extern IntPtr GetDC(IntPtr hWnd);
861 |
862 | [DllImport("user32.dll")]
863 | public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
864 |
865 | [DllImport("user32.dll")]
866 | public static extern IntPtr WindowFromPoint(System.Drawing.Point p);
867 | // Now working in pwsh 7 thanks to advice from seeminglyscience#2404 on Discord
868 | [DllImport("user32.dll")]
869 | public static extern IntPtr GetParent(IntPtr hWnd);
870 | [DllImport("user32.dll")]
871 | public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
872 | [DllImport("user32.dll")]
873 | public static extern bool ShowWindow(int hWnd, WindowState nCmdShow);
874 | public enum WindowState
875 | {
876 | SW_HIDE = 0,
877 | SW_SHOW_NORMAL = 1,
878 | SW_SHOW_MINIMIZED = 2,
879 | SW_MAXIMIZE = 3,
880 | SW_SHOW_MAXIMIZED = 3,
881 | SW_SHOW_NO_ACTIVE = 4,
882 | SW_SHOW = 5,
883 | SW_MINIMIZE = 6,
884 | SW_SHOW_MIN_NO_ACTIVE = 7,
885 | SW_SHOW_NA = 8,
886 | SW_RESTORE = 9,
887 | SW_SHOW_DEFAULT = 10,
888 | SW_FORCE_MINIMIZE = 11
889 | }
890 |
891 | [DllImport("user32.dll")]
892 | private static extern bool SetCursorPos(int x, int y);
893 |
894 | [DllImport("User32.dll")]
895 | public static extern bool MoveWindow(int hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
896 | [DllImport("User32.dll")]
897 | public static extern bool GetWindowRect(int hWnd, out RECT lpRect);
898 |
899 |
900 | [DllImport("user32.dll", EntryPoint="FindWindow")]
901 | internal static extern int FWBC(string lpClassName, int ZeroOnly);
902 | public static int FindWindowByClass(string lpClassName) {
903 | return FWBC(lpClassName, 0);}
904 |
905 | [DllImport("user32.dll", EntryPoint="FindWindow")]
906 | internal static extern int FWBT(int ZeroOnly, string lpTitle);
907 | public static int FindWindowByTitle(string lpTitle) {
908 | return FWBT(0, lpTitle);}
909 |
910 | [DllImport("user32.dll")]
911 | public static extern IntPtr GetForegroundWindow();
912 |
913 | [DllImport("user32.dll")]
914 | public static extern IntPtr GetWindow(int hWnd, uint uCmd);
915 |
916 | [DllImport("user32.dll")]
917 | public static extern int GetWindowTextLength(int hWnd);
918 |
919 | [DllImport("user32.dll")]
920 | public static extern IntPtr GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
921 |
922 | [DllImport("user32.dll")]
923 | public static extern IntPtr GetClassName(IntPtr hWnd, System.Text.StringBuilder text, int count);
924 |
925 | [DllImport("user32.dll")]
926 | public static extern bool SetWindowPos(int hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
927 |
928 | [DllImport ("user32.dll")]
929 | public static extern bool SetParent(int ChWnd, int hWnd);
930 |
931 | [DllImport("user32.dll")]
932 | public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
933 |
934 | [DllImport("User32.dll")]
935 | public static extern bool SetWindowText(IntPtr hWnd, string lpString);
936 |
937 |
938 | //CC-BY-SA
939 | //Adapted from script by StephenP
940 | //https://stackoverflow.com/users/3594883/stephenp
941 | [DllImport("User32.dll")]
942 | extern static uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
943 |
944 | public struct INPUT
945 | {
946 | public int type; // 0 = INPUT_MOUSE,
947 | // 1 = INPUT_KEYBOARD
948 | // 2 = INPUT_HARDWARE
949 | public MOUSEINPUT mi;
950 | }
951 |
952 | public struct MOUSEINPUT
953 | {
954 | public int dx ;
955 | public int dy ;
956 | public int mouseData ;
957 | public int dwFlags;
958 | public int time;
959 | public IntPtr dwExtraInfo;
960 | }
961 |
962 | const int MOUSEEVENTF_MOVED = 0x0001 ;
963 | const int MOUSEEVENTF_LEFTDOWN = 0x0002 ;
964 | const int MOUSEEVENTF_LEFTUP = 0x0004 ;
965 | const int MOUSEEVENTF_RIGHTDOWN = 0x0008 ;
966 | const int MOUSEEVENTF_RIGHTUP = 0x0010 ;
967 | const int MOUSEEVENTF_MIDDLEDOWN = 0x0020 ;
968 | const int MOUSEEVENTF_MIDDLEUP = 0x0040 ;
969 | const int MOUSEEVENTF_WHEEL = 0x0080 ;
970 | const int MOUSEEVENTF_XDOWN = 0x0100 ;
971 | const int MOUSEEVENTF_XUP = 0x0200 ;
972 | const int MOUSEEVENTF_ABSOLUTE = 0x8000 ;
973 |
974 | const int screen_length = 0x10000 ;
975 |
976 | public static void LeftClickAtPoint(int x, int y, int width, int height)
977 | {
978 | //Move the mouse
979 | INPUT[] input = new INPUT[3];
980 | input[0].mi.dx = x*(65535/width);
981 | input[0].mi.dy = y*(65535/height);
982 | input[0].mi.dwFlags = MOUSEEVENTF_MOVED | MOUSEEVENTF_ABSOLUTE;
983 | //Left mouse button down
984 | input[1].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
985 | //Left mouse button up
986 | input[2].mi.dwFlags = MOUSEEVENTF_LEFTUP;
987 | SendInput(3, input, Marshal.SizeOf(input[0]));
988 | }
989 |
990 | public static void RightClickAtPoint(int x, int y, int width, int height)
991 | {
992 | //Move the mouse
993 | INPUT[] input = new INPUT[3];
994 | input[0].mi.dx = x*(65535/width);
995 | input[0].mi.dy = y*(65535/height);
996 | input[0].mi.dwFlags = MOUSEEVENTF_MOVED | MOUSEEVENTF_ABSOLUTE;
997 | //Left mouse button down
998 | input[1].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
999 | //Left mouse button up
1000 | input[2].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
1001 | SendInput(3, input, Marshal.SizeOf(input[0]));
1002 | }
1003 | //End CC-SA
1004 | [DllImport("user32.dll")] public static extern int SetForegroundWindow(IntPtr hwnd);
1005 |
1006 |
1007 | }
1008 |
1009 | public struct RECT
1010 |
1011 | {
1012 | public int Left;
1013 | public int Top;
1014 | public int Right;
1015 | public int Bottom;
1016 | }
1017 | "@ -ReferencedAssemblies System.Windows.Forms, System.Drawing, System.Drawing.Primitives
1018 |
1019 | if ((get-host).version.major -eq 7) {
1020 | if ((get-host).version.minor -eq 0) {
1021 | Add-Type @"
1022 | using System;
1023 | using System.Drawing;
1024 | using System.Runtime.InteropServices;
1025 | using System.Windows.Forms;
1026 | using System.ComponentModel;
1027 | public class vdsForm:Form {
1028 | [DllImport("user32.dll")]
1029 | public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
1030 | [DllImport("user32.dll")]
1031 | public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
1032 | protected override void WndProc(ref Message m) {
1033 | base.WndProc(ref m);
1034 | if (m.Msg == 0x0312) {
1035 | int id = m.WParam.ToInt32();
1036 | foreach (Control item in this.Controls) {
1037 | if (item.Name == "hotkey") {
1038 | item.Text = id.ToString();
1039 | }
1040 | }
1041 | }
1042 | }
1043 | }
1044 | "@ -ReferencedAssemblies System.Windows.Forms,System.Drawing,System.Drawing.Primitives,System.Net.Primitives,System.ComponentModel.Primitives,Microsoft.Win32.Primitives
1045 | }
1046 | else{
1047 | Add-Type @"
1048 | using System;
1049 | using System.Drawing;
1050 | using System.Runtime.InteropServices;
1051 | using System.Windows.Forms;
1052 | using System.ComponentModel;
1053 | public class vdsForm:Form {
1054 | [DllImport("user32.dll")]
1055 | public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
1056 | [DllImport("user32.dll")]
1057 | public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
1058 | protected override void WndProc(ref Message m) {
1059 | base.WndProc(ref m);
1060 | if (m.Msg == 0x0312) {
1061 | int id = m.WParam.ToInt32();
1062 | foreach (Control item in this.Controls) {
1063 | if (item.Name == "hotkey") {
1064 | item.Text = id.ToString();
1065 | }
1066 | }
1067 | }
1068 | }
1069 | }
1070 | "@ -ReferencedAssemblies System.Windows.Forms,System.Drawing,System.Drawing.Primitives,System.Net.Primitives,System.ComponentModel.Primitives,Microsoft.Win32.Primitives,System.Windows.Forms.Primitives
1071 | }
1072 | }
1073 | else {
1074 | Add-Type @"
1075 | using System;
1076 | using System.Drawing;
1077 | using System.Runtime.InteropServices;
1078 | using System.Windows.Forms;
1079 | using System.ComponentModel;
1080 | public class vdsForm:Form {
1081 | [DllImport("user32.dll")]
1082 | public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
1083 | [DllImport("user32.dll")]
1084 | public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
1085 | protected override void WndProc(ref Message m) {
1086 | base.WndProc(ref m);
1087 | if (m.Msg == 0x0312) {
1088 | int id = m.WParam.ToInt32();
1089 | foreach (Control item in this.Controls) {
1090 | if (item.Name == "hotkey") {
1091 | item.Text = id.ToString();
1092 | }
1093 | }
1094 | }
1095 | }
1096 | }
1097 | "@ -ReferencedAssemblies System.Windows.Forms,System.Drawing
1098 | }
1099 |
1100 | <#
1101 | Function: FlashWindow
1102 | Author: Boe Prox
1103 | https://social.technet.microsoft.com/profile/boe%20prox/
1104 | Adapted to VDS: 20190212
1105 | License: Microsoft Limited Public License
1106 | #>
1107 |
1108 | Add-Type -TypeDefinition @"
1109 | //"
1110 | using System;
1111 | using System.Collections.Generic;
1112 | using System.Text;
1113 | using System.Runtime.InteropServices;
1114 |
1115 | public class Window
1116 | {
1117 | [StructLayout(LayoutKind.Sequential)]
1118 | public struct FLASHWINFO
1119 | {
1120 | public UInt32 cbSize;
1121 | public IntPtr hwnd;
1122 | public UInt32 dwFlags;
1123 | public UInt32 uCount;
1124 | public UInt32 dwTimeout;
1125 | }
1126 |
1127 | //Stop flashing. The system restores the window to its original state.
1128 | const UInt32 FLASHW_STOP = 0;
1129 | //Flash the window caption.
1130 | const UInt32 FLASHW_CAPTION = 1;
1131 | //Flash the taskbar button.
1132 | const UInt32 FLASHW_TRAY = 2;
1133 | //Flash both the window caption and taskbar button.
1134 | //This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
1135 | const UInt32 FLASHW_ALL = 3;
1136 | //Flash continuously, until the FLASHW_STOP flag is set.
1137 | const UInt32 FLASHW_TIMER = 4;
1138 | //Flash continuously until the window comes to the foreground.
1139 | const UInt32 FLASHW_TIMERNOFG = 12;
1140 |
1141 |
1142 | [DllImport("user32.dll")]
1143 | [return: MarshalAs(UnmanagedType.Bool)]
1144 | static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
1145 |
1146 | public static bool FlashWindow(IntPtr handle, UInt32 timeout, UInt32 count)
1147 | {
1148 | IntPtr hWnd = handle;
1149 | FLASHWINFO fInfo = new FLASHWINFO();
1150 |
1151 | fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
1152 | fInfo.hwnd = hWnd;
1153 | fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
1154 | fInfo.uCount = count;
1155 | fInfo.dwTimeout = timeout;
1156 |
1157 | return FlashWindowEx(ref fInfo);
1158 | }
1159 | }
1160 | "@
1161 | $global:ctscale = 1
1162 | }
1163 | Set-Types
1164 |
1165 | function Set-WindowParent {
1166 | <#
1167 | .SYNOPSIS
1168 | This function fuses a window into another window
1169 |
1170 | ALIAS
1171 | Window-Fuse
1172 |
1173 | .DESCRIPTION
1174 | This function fuses a child window into a parent window
1175 |
1176 | .PARAMETER Child
1177 | The child window
1178 |
1179 | .PARAMETER Parent
1180 | The parent window
1181 |
1182 | .EXAMPLE
1183 | Set-WindowParent (Get-WindowExists "Untitled - Notepad") (Get-WindowExists "Libraries")
1184 |
1185 | .EXAMPLE
1186 | Set-WindowParent -child (Get-WindowExists "Untitled - Notepad") -parent (Get-WindowExists "Libraries")
1187 |
1188 | .EXAMPLE
1189 | (Get-WindowExists "Untitled - Notepad") | Set-WindowParent -parent (Get-WindowExists "Libraries")
1190 |
1191 | .INPUTS
1192 | Child as Handle,Parent as Handle
1193 | #>
1194 | [Alias("Window-Fuse")]
1195 | [CmdletBinding()]
1196 | param (
1197 | [Parameter(Mandatory,
1198 | ValueFromPipeline)]
1199 | [int]$Child,
1200 | [Parameter(Mandatory)]
1201 | [int]$Parent
1202 | )
1203 | [vds]::SetParent($Child,$Parent)
1204 | }
1205 |
1206 | function Show-InformationDialog {
1207 | <#
1208 | .SYNOPSIS
1209 | Displays a information dialog with a message and title specified.
1210 |
1211 | ALIAS
1212 | Info
1213 |
1214 | .DESCRIPTION
1215 | This function displays a information dialog with a message and title specified.
1216 |
1217 | .PARAMETER Message
1218 | The message to display
1219 |
1220 | .PARAMETER Title
1221 | The title to display
1222 |
1223 | .EXAMPLE
1224 | Show-InformationDialog "Message"
1225 |
1226 | .EXAMPLE
1227 | Show-InformationDialog -message "Message" -title "Title"
1228 |
1229 | .EXAMPLE
1230 | "Message" | Show-InformationDialog -title "Title"
1231 |
1232 | .INPUTS
1233 | Message as String, Title as String
1234 |
1235 | .OUTPUTS
1236 | MessageBox
1237 | #>
1238 | [Alias("Info")]
1239 | [CmdletBinding()]
1240 | param (
1241 | [Parameter(Mandatory,
1242 | ValueFromPipeline)]
1243 | [string]$Message,
1244 | [string]$Title
1245 | )
1246 | [System.Windows.Forms.MessageBox]::Show($Message,$Title,'OK',64) | Out-Null
1247 | }
1248 |
1249 | function Update-ErrorLog {
1250 | <#
1251 | .SYNOPSIS
1252 | Logs errors to the text file 'exceptions.txt' for use in the catch
1253 | statement of a try catch.
1254 |
1255 | .DESCRIPTION
1256 | This function logs errors to the text file 'exceptions.txt' residing in
1257 | the current directory in use by powershell, for use in the catch
1258 | statement of a try catch.
1259 |
1260 | .PARAMETER ErrorRecord
1261 | The object from the pipeline represented by $_ or $PSItem
1262 |
1263 | .PARAMETER Message
1264 | The message to display to the end user.
1265 |
1266 | .PARAMETER Promote
1267 | Switch that defines to also call a throw of the ValueFromPipeline
1268 |
1269 | .EXAMPLE
1270 | Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered adding $($Xml.ToString()) to $($ParentControl.Name)"
1271 |
1272 | .EXAMPLE
1273 | Update-ErrorLog -Promote -ErrorRecord $_ -Message "Exception encountered adding $($Xml.ToString()) to $($ParentControl.Name)"
1274 |
1275 | .INPUTS
1276 | ErrorRecord as ValueFromPipeline, Message as String, Promote as Switch
1277 |
1278 | .Outputs
1279 | String || String, Throw method of ValueFromPipeline
1280 | #>
1281 | param(
1282 | [System.Management.Automation.ErrorRecord]$ErrorRecord,
1283 | [string]$Message,
1284 | [switch]$Promote
1285 | )
1286 |
1287 | if ( $Message -ne '' ) {
1288 | [void][System.Windows.Forms.MessageBox]::Show("$($Message)`r`n`r`nCheck '$(get-currentdirectory)\exceptions.txt' for details.",'Exception Occurred')
1289 | }
1290 | $date = Get-Date -Format 'yyyyMMdd HH:mm:ss'
1291 | $ErrorRecord | Out-File "$(get-currentdirectory)\tmpError.txt"
1292 | Add-Content -Path "$(get-currentdirectory)\exceptions.txt" -Value "$($date): $($(Get-Content "$(get-currentdirectory)\tmpError.txt") -replace "\s+"," ")"
1293 | Remove-Item -Path "$(get-currentdirectory)\tmpError.txt"
1294 | if ( $Promote ) {
1295 | throw $ErrorRecord
1296 | }
1297 | }
1298 |
1299 |
1300 | ConvertFrom-WinFormsXML -Reference refs -Suppress -Xml @"
1301 |
1302 | "@
1303 | #endregion VDS
1304 | #region Images
1305 |
1306 | #endregion
1307 |
1308 | ConvertFrom-WPFXaml -xaml @"
1309 |
1317 |
1318 |
1319 |
1320 |
1321 |
1322 | "@
1323 |
1324 | $Button.Add_Click({Show-InformationDialog -Message 'Hello' -Title $Title})
1325 |
1326 | $MainWindow.Show()
1327 | $MainWindow.Top = 0
1328 | $MainWindow.Left = 0
1329 |
1330 | Set-WindowParent (Get-WindowExists "MainWindow") $MainForm.Handle
1331 |
1332 | #end region
1333 |
1334 |
1335 |
1336 |
1337 | [System.Windows.Forms.Application]::Run($MainForm) | Out-Null}); $PowerShell.AddParameter('File',$args[0]) | Out-Null; $PowerShell.Invoke() | Out-Null; $PowerShell.Dispose() | Out-Null
1338 |
--------------------------------------------------------------------------------
/Examples/Window Spy.fbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
29 |
--------------------------------------------------------------------------------
/Examples/Window Spy/Events.ps1:
--------------------------------------------------------------------------------
1 | #region Images
2 | $MainForm.Icon = [System.Drawing.Icon]::FromHandle(([System.Drawing.Bitmap][System.Drawing.Image]::FromStream([System.IO.MemoryStream][System.Convert]::FromBase64String("AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAUXZUDEFqSGv///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAiZp4GG2KarSJnnf8RW5OH////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAycqoGK22lrVWNvP+Jtd3/GF+X/////wD///8A////AP///wD///8A////AP///wD///8A////AP///wBEf7cGPHmxrWSXxf+dweT/ZpnH/x9lnev///8A////AP///wD///8A3bKPAtmuipfWqYXj06V//dCge/3NnHbkopOK3nWizP+ry+j/dqTO/zBwqOsoa6Mn////AP///wD///8A5L2bAuG4lsDoya7/9eHN//fl0//35dH/893I/9+6nP/HqJH/hq7V/0F9tes5d68n////AP///wD///8A////AOjDopft0Lf/+OjZ//XeyP/z2L3/89a7//Tbwv/35NL/37ud/52UkvdLhLwn////AP///wD///8A////AP///wDsyKjj9+fX//bhzP/028L/9NrA//PYvf/z17v/9NvC//Peyf/Nn3vn////AP///wD///8A////AP///wD///8A8M6u/fns3//138j/9d3G//Tcw//02sH/89m+//PXvf/45tP/06V//f///wD///8A////AP///wD///8A////APTTtP357eH/9uHM//Xfyf/13sf/9NzE//Tbwv/02sD/+OfW/9eqhv3///8A////AP///wD///8A////AP///wD317nj+eve//fn1v/24cz/9eDK//XeyP/13cX/9uHL//Xi0P/bsIzj////AP///wD///8A////AP///wD///8A+tu9l/jizP/67uP/9+fW//bizv/24cv/9uPQ//nq3f/sz7X/37aTl////wD///8A////AP///wD///8A////APzewAL6277A+eLN//rs3v/57uL/+e3i//jp2v/w1b3/58CfwOO8mgL///8A////AP///wD///8A////AP///wD///8A/N7BAvrcv5f52bvj9ta4/fTTtP3xz6/j7surl+vGpgL///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD/4wAA/8MAAP+DAADgBwAAwA8AAIAfAACAHwAAgB8AAIAfAACAHwAAgB8AAMA/AADgfwAA//8AAA=="))).GetHicon())
3 |
4 | #endregion
5 |
6 | $Button.add_Click({param($sender, $e);
7 | $Button.Text = "Click on Another Window"
8 | $winactive = (winactive)
9 | while ($winactive -eq $MainForm.Handle)
10 | {
11 | start-sleep 1
12 | $winactive = (winactive)
13 | }
14 | $Button.text = "Capture"
15 | $win = $(winatpoint $(mousepos).X $(mousepos).Y)
16 | if ($win -ne 0){
17 | $buildstring = "
18 | Window: $win
19 | Window Class: $(winclass $win)
20 | Window Text: $(wintext $win)
21 | "
22 | $Label1.Text = $buildstring
23 | $ask = $(ask "Attempt to Capture parents? I may crash!")
24 | if ($ask -eq "Yes"){
25 | $tabstr = ""
26 | $parent = $(winparent $win)
27 | if ($parent -ne $null) {
28 | while ($parent -ne 0) {
29 | $tabstr+=$(tab)
30 | $buildstring+= "
31 | $tabstr Parent: $parent
32 | $tabstr Parent Class: $(winclass $parent)
33 | $tabstr Parent Text: $(wintext $parent)
34 | "
35 | $Label1.Text = $buildstring
36 | $parent = $(winparent $parent)
37 | }
38 | $Label1.Text = $buildstring
39 | $buildstring = ""
40 | }
41 | }
42 | }
43 | })
44 |
45 | $Button2.add_Click({param($sender, $e);
46 | $Button2.Text = "Hover over another window."
47 | start-sleep 1
48 | $Button2.Text = "5"
49 | while ($i -lt 5)
50 | {
51 | start-sleep 1
52 | $i = $i+1
53 | $button2.text = ((5-$i) | out-string).trim()
54 | }
55 | $Button2.text = "Countdown Capture"
56 | $win = $(winatpoint $(mousepos).X $(mousepos).Y)
57 | if ($win -ne 0){
58 | $buildstring = "
59 | Window: $win
60 | Window Class: $(winclass $win)
61 | Window Text: $(wintext $win)
62 | "
63 | $Label1.Text = $buildstring
64 | $ask = $(ask "Attempt to Capture parents? I may crash!")
65 | if ($ask -eq "Yes"){
66 | $tabstr = ""
67 | $parent = $(winparent $win)
68 | if ($parent -ne $null) {
69 | while ($parent -ne 0) {
70 | $tabstr+=$(tab)
71 | $buildstring+= "
72 | $tabstr Parent: $parent
73 | $tabstr Parent Class: $(winclass $parent)
74 | $tabstr Parent Text: $(wintext $parent)
75 | "
76 | $Label1.Text = $buildstring
77 | $parent = $(winparent $parent)
78 | }
79 | $Label1.Text = $buildstring
80 | $buildstring = ""
81 | }
82 | }
83 | }
84 |
85 | })
--------------------------------------------------------------------------------
/Examples/Window Spy/Finds.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brandoncomputer/powershell-designer/95199dfd51eab1c88f9008a0ef4fbc689610c54d/Examples/Window Spy/Finds.txt
--------------------------------------------------------------------------------
/Examples/Window Spy/Window Spy.ps1:
--------------------------------------------------------------------------------
1 | #region VDS
2 | $RunSpace = [RunspaceFactory]::CreateRunspacePool(); $RunSpace.ApartmentState = "STA"; $RunSpace.Open(); $PowerShell = [powershell]::Create();$PowerShell.RunspacePool = $RunSpace; [void]$PowerShell.AddScript({
3 |
4 | function Add-Tab() {
5 | <#
6 | .SYNOPSIS
7 | Sends the tab key
8 |
9 | ALIASES
10 | Tab
11 |
12 | .DESCRIPTION
13 | This function sends the tab key
14 |
15 | .EXAMPLE
16 | Send-Window (Get-Window notepad) Add-Tab
17 |
18 | .OUTPUTS
19 | String
20 |
21 | .NOTES
22 | Only useful with 'Send-Window'.
23 | #>
24 | [Alias("Tab")]
25 | param()
26 | return "`t"
27 | }
28 |
29 | function ConvertFrom-WinFormsXML {
30 | <#
31 | .SYNOPSIS
32 | Opens a form from XAML in the format specified by 'powershell-designer'
33 | or its predecessor, PowerShell WinForms Creator
34 |
35 | .DESCRIPTION
36 | This function opens a form from XAML in the format specified by 'powershell-designer'
37 | or its predecessor, PowerShell WinForms Creator
38 |
39 | .PARAMETER XML
40 | The XML object or XML string specifying the parameters for the form object
41 |
42 | .PARAMETER Reference
43 | This function recursively calls itself. Internal parameter for child
44 | objects, not typically called programatically. Also this function is
45 | maintained for legacy compatibility PowerShell WinForm Creator, which
46 | does require the call in some instances due to not creating automatic
47 | variables.
48 |
49 | .PARAMETER Supress
50 | This function recursively calls itself. Internal parameter for child
51 | objects, not typically called programatically.
52 |
53 | .EXAMPLE
54 | ConvertFrom-WinFormsXML -Xml @"
55 |
58 | "@
59 |
60 | .EXAMPLE
61 | ConvertFrom-WinFormsXML @"
62 |
65 | "@
66 |
67 | .EXAMPLE
68 | $content = [xml](get-content $Path)
69 | ConvertFrom-WinformsXML -xml $content.Data.Form.OuterXml
70 |
71 | .EXAMPLE
72 | $content = [xml](get-content $Path)
73 | ConvertFrom-WinformsXML $content.Data.Form.OuterXml
74 |
75 | .INPUTS
76 | Xml as String || Xml as xml
77 |
78 | .OUTPUTS
79 | Object
80 |
81 | .NOTES
82 | Each object created has a variable created to access the object
83 | according to its Name attribute e.g. $Button1
84 | #>
85 | param(
86 | [Parameter(Mandatory)]
87 | $Xml,
88 | [string]$Reference,
89 | $ParentControl,
90 | [switch]$Suppress
91 | )
92 | try {
93 | if ( $Xml.GetType().Name -eq 'String' ) {
94 | $Xml = ([xml]$Xml).ChildNodes
95 | }
96 | $Xml.Attributes | ForEach-Object {
97 | $attrib = $_
98 | $attribName = $_.ToString()
99 | $attrib = $_
100 | $attribName = $_.ToString()
101 | if ($attribName -eq 'Tag'){
102 | if (($attrib.Value | Out-String).Contains("VisualStyle")) {
103 | Set-EnableVisualStyle
104 | }
105 | if (($attrib.Value | Out-String).Contains("DPIAware")) {
106 | Set-DPIAware
107 | }
108 | }
109 | }
110 | $Cskip = $false
111 | if ($attribName -eq 'ControlType') {
112 | $newControl = New-Object ($attrib.Value | Out-String)
113 | $Cskip = $true
114 | }
115 | switch ($Xml.ToString()){
116 | 'SplitterPanel'{}
117 | 'Form'{$newControl = [vdsForm] @{
118 | ClientSize = New-Object System.Drawing.Point 0,0}
119 | $Cskip = $true
120 | }
121 | 'String'{$newControl = New-Object System.String
122 | $Cskip = $true}
123 | 'WebView2'{$newControl = New-Object Microsoft.Web.WebView2.WinForms.WebView2
124 | $Cskip = $true}
125 | 'FastColoredTextBox'{$newControl = New-Object FastColoredTextBoxNS.FastColoredTextBox
126 | $Cskip = $true}
127 | default{
128 | if ($Cskip -eq $false){
129 | $newControl = New-Object System.Windows.Forms.$($Xml.ToString())}}
130 | }
131 | if ( $ParentControl ) {
132 | if ( $Xml.ToString() -eq 'ToolStrip' ) {
133 | $newControl = New-Object System.Windows.Forms.MenuStrip
134 | $ParentControl.Controls.Add($newControl)
135 | }
136 | else {
137 | if ( $Xml.ToString() -match "^ToolStrip" ) {
138 | if ( $ParentControl.GetType().Name -match "^ToolStrip" ) {
139 | [void]$ParentControl.DropDownItems.Add($newControl)
140 | }
141 | else {
142 | [void]$ParentControl.Items.Add($newControl)
143 | }
144 | }
145 | elseif ( $Xml.ToString() -eq 'ContextMenuStrip' ) {
146 | $ParentControl.ContextMenuStrip = $newControl
147 | }
148 | elseif ( $Xml.ToString() -eq 'SplitterPanel' ) {
149 | $newControl = $ParentControl.$($Xml.Name.Split('_')[-1])
150 | }
151 | else {
152 | $ParentControl.Controls.Add($newControl)
153 | }
154 | }
155 | }
156 |
157 | $Xml.Attributes | ForEach-Object {
158 | $attrib = $_
159 | $attribName = $_.ToString()
160 | $attrib = $_
161 | $attribName = $_.ToString()
162 | if ($attribName -eq 'Opacity'){
163 | $n = $attrib.Value.split('%')
164 | $attrib.value = $n[0]/100
165 | }
166 | if ($attribName -eq 'ColumnWidth'){
167 | $attrib.Value = [math]::round(($attrib.Value / 1) * $ctscale)
168 | }
169 | if ($attribName -eq 'Size'){
170 | $n = $attrib.Value.split(',')
171 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
172 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
173 | if ("$($n[0]),$($n[1])" -ne ",") {
174 | $attrib.Value = "$($n[0]),$($n[1])"
175 | }
176 | }
177 | if ($attribName -eq 'Location'){
178 | $n = $attrib.Value.split(',')
179 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
180 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
181 | if ("$($n[0]),$($n[1])" -ne ",") {
182 | $attrib.Value = "$($n[0]),$($n[1])"
183 | }
184 | }
185 | if ($attribName -eq 'MaximumSize'){
186 | $n = $attrib.Value.split(',')
187 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
188 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
189 | if ("$($n[0]),$($n[1])" -ne ",") {
190 | $attrib.Value = "$($n[0]),$($n[1])"
191 | }
192 | }
193 | if ($attribName -eq 'MinimumSize'){
194 | $n = $attrib.Value.split(',')
195 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
196 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
197 | if ("$($n[0]),$($n[1])" -ne ",") {
198 | $attrib.Value = "$($n[0]),$($n[1])"
199 | }
200 | }
201 | if ($attribName -eq 'ImageScalingSize'){
202 | $n = $attrib.Value.split(',')
203 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
204 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
205 | if ("$($n[0]),$($n[1])" -ne ",") {
206 | $attrib.Value = "$($n[0]),$($n[1])"
207 | }
208 | }
209 |
210 | if ($attribName -eq 'TileSize'){
211 | $n = $attrib.Value.split(',')
212 | $n[0] = [math]::round(($n[0]/1) * $ctscale)
213 | $n[1] = [math]::round(($n[1]/1) * $ctscale)
214 | if ("$($n[0]),$($n[1])" -ne ",") {
215 | $attrib.Value = "$($n[0]),$($n[1])"
216 | }
217 | }
218 |
219 | if ( $Script:specialProps.Array -contains $attribName ) {
220 | if ( $attribName -eq 'Items' ) {
221 | $($_.Value -replace "\|\*BreakPT\*\|","`n").Split("`n") | ForEach-Object {
222 | [void]$newControl.Items.Add($_)
223 | }
224 | }
225 | else {
226 | # Other than Items only BoldedDate properties on MonthCalendar control
227 | $methodName = "Add$($attribName)" -replace "s$"
228 | $($_.Value -replace "\|\*BreakPT\*\|","`n").Split("`n") | ForEach-Object {
229 | $newControl.$attribName.$methodName($_)
230 | }
231 | }
232 | }
233 | else {
234 | switch ($attribName) {
235 | ControlType{}
236 | FlatAppearance {
237 | $attrib.Value.Split('|') | ForEach-Object {
238 | $newControl.FlatAppearance.$($_.Split('=')[0]) = $_.Split('=')[1]
239 | }
240 | }
241 | default {
242 | if ( $null -ne $newControl.$attribName ) {
243 | if ( $newControl.$attribName.GetType().Name -eq 'Boolean' ) {
244 | if ( $attrib.Value -eq 'True' ) {
245 | $value = $true
246 | }
247 | else {
248 | $value = $false
249 | }
250 | }
251 | else {
252 | $value = $attrib.Value
253 | }
254 | }
255 | else {
256 | $value = $attrib.Value
257 | }
258 | switch ($xml.ToString()) {
259 | "FolderBrowserDialog" {
260 | if ($xml.Description) {
261 | $newControl.Description = $xml.Description
262 | }
263 | if ($xml.Tag) {
264 | $newControl.Tag = $xml.Tag
265 | }
266 | if ($xml.RootFolder) {
267 | $newControl.RootFolder = $xml.RootFolder
268 | }
269 | if ($xml.SelectedPath) {
270 | $newControl.SelectedPath = $xml.SelectedPath
271 | }
272 | if ($xml.ShowNewFolderButton) {
273 | $newControl.ShowNewFolderButton = $xml.ShowNewFolderButton
274 | }
275 | }
276 | "OpenFileDialog" {
277 | if ($xml.AddExtension) {
278 | $newControl.AddExtension = $xml.AddExtension
279 | }
280 | if ($xml.AutoUpgradeEnabled) {
281 | $newControl.AutoUpgradeEnabled = $xml.AutoUpgradeEnabled
282 | }
283 | if ($xml.CheckFileExists) {
284 | $newControl.CheckFileExists = $xml.CheckFileExists
285 | }
286 | if ($xml.CheckPathExists) {
287 | $newControl.CheckPathExists = $xml.CheckPathExists
288 | }
289 | if ($xml.DefaultExt) {
290 | $newControl.DefaultExt = $xml.DefaultExt
291 | }
292 | if ($xml.DereferenceLinks) {
293 | $newControl.DereferenceLinks = $xml.DereferenceLinks
294 | }
295 | if ($xml.FileName) {
296 | $newControl.FileName = $xml.FileName
297 | }
298 | if ($xml.Filter) {
299 | $newControl.Filter = $xml.Filter
300 | }
301 | if ($xml.FilterIndex) {
302 | $newControl.FilterIndex = $xml.FilterIndex
303 | }
304 | if ($xml.InitialDirectory) {
305 | $newControl.InitialDirectory = $xml.InitialDirectory
306 | }
307 | if ($xml.Multiselect) {
308 | $newControl.Multiselect = $xml.Multiselect
309 | }
310 | if ($xml.ReadOnlyChecked) {
311 | $newControl.ReadOnlyChecked = $xml.ReadOnlyChecked
312 | }
313 | if ($xml.RestoreDirectory) {
314 | $newControl.RestoreDirectory = $xml.RestoreDirectory
315 | }
316 | if ($xml.ShowHelp) {
317 | $newControl.ShowHelp = $xml.ShowHelp
318 | }
319 | if ($xml.ShowReadOnly) {
320 | $newControl.ShowReadOnly = $xml.ShowReadOnly
321 | }
322 | if ($xml.SupportMultiDottedExtensions) {
323 | $newControl.SupportMultiDottedExtensions = $xml.SupportMultiDottedExtensions
324 | }
325 | if ($xml.Tag) {
326 | $newControl.Tag = $xml.Tag
327 | }
328 | if ($xml.Title) {
329 | $newControl.Title = $xml.Title
330 | }
331 | if ($xml.ValidateNames) {
332 | $newControl.ValidateNames = $xml.ValidateNames
333 | }
334 | }
335 | "ColorDialog" {
336 | if ($xml.AllowFullOpen) {
337 | $newControl.AllowFullOpen = $xml.AllowFullOpen
338 | }
339 | if ($xml.AnyColor) {
340 | $newControl.AnyColor = $xml.AnyColor
341 | }
342 | if ($xml.Color) {
343 | $newControl.Color = $xml.Color
344 | }
345 | if ($xml.FullOpen) {
346 | $newControl.FullOpen = $xml.FullOpen
347 | }
348 | if ($xml.ShowHelp) {
349 | $newControl.ShowHelp = $xml.ShowHelp
350 | }
351 | if ($xml.SolidColorOnly) {
352 | $newControl.SolidColorOnly = $xml.SolidColorOnly
353 | }
354 | if ($xml.Tag) {
355 | $newControl.Tag = $xml.Tag
356 | }
357 | }
358 | "FontDialog" {
359 | if ($xml.AllowScriptChange) {
360 | $newControl.AllowScriptChange = $xml.AllowScriptChange
361 | }
362 | if ($xml.AllowSimulations) {
363 | $newControl.AllowSimulations = $xml.AllowSimulations
364 | }
365 | if ($xml.AllowVectorFonts) {
366 | $newControl.AllowVectorFonts = $xml.AllowVectorFonts
367 | }
368 | if ($xml.Color) {
369 | $newControl.Color = $xml.Color
370 | }
371 | if ($xml.FixedPitchOnly) {
372 | $newControl.FixedPitchOnly = $xml.FixedPitchOnly
373 | }
374 | if ($xml.Font) {
375 | $newControl.Font = $xml.Font
376 | }
377 | if ($xml.FontMustExists) {
378 | $newControl.FontMustExists = $xml.FontMustExists
379 | }
380 | if ($xml.MaxSize) {
381 | $newControl.MaxSize = $xml.MaxSize
382 | }
383 | if ($xml.MinSize) {
384 | $newControl.MinSize = $xml.MinSize
385 | }
386 | if ($xml.ScriptsOnly) {
387 | $newControl.ScriptsOnly = $xml.ScriptsOnly
388 | }
389 | if ($xml.ShowApply) {
390 | $newControl.ShowApply = $xml.ShowApply
391 | }
392 | if ($xml.ShowColor) {
393 | $newControl.ShowColor = $xml.ShowColor
394 | }
395 | if ($xml.ShowEffects) {
396 | $newControl.ShowEffects = $xml.ShowEffects
397 | }
398 | if ($xml.ShowHelp) {
399 | $newControl.ShowHelp = $xml.ShowHelp
400 | }
401 | if ($xml.Tag) {
402 | $newControl.Tag = $xml.Tag
403 | }
404 | }
405 | "PageSetupDialog" {
406 | if ($xml.AllowMargins) {
407 | $newControl.AllowMargins = $xml.AllowMargins
408 | }
409 | if ($xml.AllowOrientation) {
410 | $newControl.AllowOrientation = $xml.AllowOrientation
411 | }
412 | if ($xml.AllowPaper) {
413 | $newControl.AllowPaper = $xml.AllowPaper
414 | }
415 | if ($xml.Document) {
416 | $newControl.Document = $xml.Document
417 | }
418 | if ($xml.EnableMetric) {
419 | $newControl.EnableMetric = $xml.EnableMetric
420 | }
421 | if ($xml.MinMargins) {
422 | $newControl.MinMargins = $xml.MinMargins
423 | }
424 | if ($xml.ShowHelp) {
425 | $newControl.ShowHelp = $xml.ShowHelp
426 | }
427 | if ($xml.ShowNetwork) {
428 | $newControl.ShowNetwork = $xml.ShowNetwork
429 | }
430 | if ($xml.Tag) {
431 | $newControl.Tag = $xml.Tag
432 | }
433 | }
434 | "PrintDialog" {
435 | if ($xml.AllowCurrentPage) {
436 | $newControl.AllowCurrentPage = $xml.AllowCurrentPage
437 | }
438 | if ($xml.AllowPrintToFile) {
439 | $newControl.AllowPrintToFile = $xml.AllowPrintToFile
440 | }
441 | if ($xml.AllowSelection) {
442 | $newControl.AllowSelection = $xml.AllowSelection
443 | }
444 | if ($xml.AllowSomePages) {
445 | $newControl.AllowSomePages = $xml.AllowSomePages
446 | }
447 | if ($xml.Document) {
448 | $newControl.Document = $xml.Document
449 | }
450 | if ($xml.PrintToFile) {
451 | $newControl.PrintToFile = $xml.PrintToFile
452 | }
453 | if ($xml.ShowHelp) {
454 | $newControl.ShowHelp = $xml.ShowHelp
455 | }
456 | if ($xml.ShowNetwork) {
457 | $newControl.ShowNetwork = $xml.ShowNetwork
458 | }
459 | if ($xml.Tag) {
460 | $newControl.Tag = $xml.Tag
461 | }
462 | if ($xml.UseEXDialog) {
463 | $newControl.UseEXDialog = $xml.UseEXDialog
464 | }
465 | }
466 | "PrintPreviewDialog" {
467 | if ($xml.AutoSizeMode) {
468 | $newControl.AutoSizeMode = $xml.AutoSizeMode
469 | }
470 | if ($xml.Document) {
471 | $newControl.Document = $xml.Document
472 | }
473 | if ($xml.MainMenuStrip) {
474 | $newControl.MainMenuStrip = $xml.MainMenuStrip
475 | }
476 | if ($xml.ShowIcon) {
477 | $newControl.ShowIcon = $xml.ShowIcon
478 | }
479 | if ($xml.UseAntiAlias) {
480 | $newControl.UseAntiAlias = $xml.UseAntiAlias
481 | }
482 | }
483 | "SaveFileDialog" {
484 | if ($xml.AddExtension) {
485 | $newControl.AddExtension = $xml.AddExtension
486 | }
487 | if ($xml.AutoUpgradeEnabled) {
488 | $newControl.AutoUpgradeEnabled = $xml.AutoUpgradeEnabled
489 | }
490 | if ($xml.CheckFileExists) {
491 | $newControl.CheckFileExists = $xml.CheckFileExists
492 | }
493 | if ($xml.CheckPathExists) {
494 | $newControl.CheckPathExists = $xml.CheckPathExists
495 | }
496 | if ($xml.CreatePrompt) {
497 | $newControl.CreatePrompt = $xml.CreatePrompt
498 | }
499 | if ($xml.DefaultExt) {
500 | $newControl.DefaultExt = $xml.DefaultExt
501 | }
502 | if ($xml.DereferenceLinks) {
503 | $newControl.DereferenceLinks = $xml.DereferenceLinks
504 | }
505 | if ($xml.FileName) {
506 | $newControl.FileName = $xml.FileName
507 | }
508 | if ($xml.Filter) {
509 | $newControl.Filter = $xml.Filter
510 | }
511 | if ($xml.FilterIndex) {
512 | $newControl.FilterIndex = $xml.FilterIndex
513 | }
514 | if ($xml.InitialDirectory) {
515 | $newControl.InitialDirectory = $xml.InitialDirectory
516 | }
517 | if ($xml.Multiselect) {
518 | $newControl.OverwritePrompt = $xml.OverwritePrompt
519 | }
520 | if ($xml.RestoreDirectory) {
521 | $newControl.RestoreDirectory = $xml.RestoreDirectory
522 | }
523 | if ($xml.ShowHelp) {
524 | $newControl.ShowHelp = $xml.ShowHelp
525 | }
526 | if ($xml.SupportMultiDottedExtensions) {
527 | $newControl.SupportMultiDottedExtensions = $xml.SupportMultiDottedExtensions
528 | }
529 | if ($xml.Tag) {
530 | $newControl.Tag = $xml.Tag
531 | }
532 | if ($xml.Title) {
533 | $newControl.Title = $xml.Title
534 | }
535 | if ($xml.ValidateNames) {
536 | $newControl.ValidateNames = $xml.ValidateNames
537 | }
538 | }
539 | "Timer" {
540 | if ($xml.Enabled) {
541 | $newControl.Enabled = $xml.Enabled
542 | }
543 | if ($xml.Interval) {
544 | $newControl.Interval = $xml.Interval
545 | }
546 | if ($xml.Tag) {
547 | $newControl.Tag = $xml.Tag
548 | }
549 | }
550 | default {
551 | $newControl.$attribName = $value
552 | }
553 | }
554 | }
555 | }
556 | }
557 | if ($xml.Name){
558 | if ((Test-Path variable:global:"$($xml.Name)") -eq $False) {
559 | New-Variable -Name $xml.Name -Scope global -Value $newControl | Out-Null
560 | }
561 | }
562 | if (( $attrib.ToString() -eq 'Name' ) -and ( $Reference -ne '' )) {
563 | try {
564 | $refHashTable = Get-Variable -Name $Reference -Scope global -ErrorAction Stop
565 | }
566 | catch {
567 | New-Variable -Name $Reference -Scope global -Value @{} | Out-Null
568 | $refHashTable = Get-Variable -Name $Reference -Scope global -ErrorAction SilentlyContinue
569 | }
570 | $refHashTable.Value.Add($attrib.Value,$newControl)
571 | }
572 | }
573 | if ( $Xml.ChildNodes ) {
574 | $Xml.ChildNodes | ForEach-Object {ConvertFrom-WinformsXML -Xml $_ -ParentControl $newControl -Reference $Reference -Suppress}
575 | }
576 | if ( $Suppress -eq $false ) {
577 | return $newControl
578 | }
579 | }
580 | catch {
581 | Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered adding $($Xml.ToString()) to $($ParentControl.Name)"
582 | }
583 | }
584 |
585 | function Get-ActiveWindow {
586 | <#
587 | .SYNOPSIS
588 | Returns the handle of the active window
589 |
590 | ALIASES
591 | Winactive
592 |
593 | .DESCRIPTION
594 | This function returns the handle of the active window
595 |
596 | .EXAMPLE
597 | $winactive = Get-ActiveWindow
598 |
599 | .OUTPUTS
600 | Handle
601 | #>
602 | [Alias("Winactive")]
603 | param()
604 | return [vds]::GetForegroundWindow()
605 | }
606 |
607 | function Get-Answer {
608 | <#
609 | .SYNOPSIS
610 | Opens a dialog window to ask the user a yes or no question.
611 |
612 | ALIASES
613 | Ask
614 |
615 | .DESCRIPTION
616 | This function will call upon Windows Forms to display a Information
617 | dialog asking the user a Yes or No quesiton.
618 |
619 | .PARAMETER QuestionText
620 | The question to ask the end user.
621 |
622 | .PARAMETER TitleText
623 |
624 | .EXAMPLE
625 | Get-Answer "Are the birds singing?"
626 |
627 | .EXAMPLE
628 | Get-Answer "Are the birds singing?" "About the birds"
629 |
630 | .EXAMPLE
631 | Get-Answer -TitleText "About the birds" -QuestionText "Are the birds singing?"
632 |
633 | .EXAMPLE
634 | "Are the birds singing?" | Get-Answer
635 |
636 | .INPUTS
637 | QuestionText as String, TitleText as String
638 |
639 | .OUTPUTS
640 | Yes or No as String
641 | #>
642 | [Alias("Ask")]
643 | [CmdletBinding()]
644 | param (
645 | [Parameter(Mandatory,
646 | ValueFromPipeline)]
647 | [string]$QuestionText,
648 | [string]$TitleText
649 | )
650 | $GetAnswer = [System.Windows.Forms.MessageBox]::Show($QuestionText,$TitleText,'YesNo','Info')
651 | return $GetAnswer
652 | }
653 |
654 | function Get-CurrentDirectory {
655 | <#
656 | .SYNOPSIS
657 | Returns the current directory as string
658 |
659 | ALIASES
660 | Curdir
661 |
662 | .DESCRIPTION
663 | This function returns the current directory of the application as string.
664 |
665 | .EXAMPLE
666 | Write-Host Get-CurrentDirectory
667 |
668 | .OUTPUTS
669 | String
670 | #>
671 | [Alias("Curdir")]
672 | param()
673 | return (Get-Location | Select-Object -expandproperty Path | Out-String).Trim()
674 | }
675 |
676 | function Get-MousePosition {
677 | <#
678 | .SYNOPSIS
679 | Returns the X and Y of the mouse position.
680 |
681 | ALIASES
682 | Mousepos
683 |
684 | .DESCRIPTION
685 | This function returns the X and Y of the mouse position.
686 |
687 | .EXAMPLE
688 | $mouseX = (Get-MousePosition).X
689 |
690 | .EXAMPLE
691 | $mouseY = (Get-MousePosition).Y
692 |
693 | .OUTPUTS
694 | PSCustomObject
695 | #>
696 | [Alias("Mousepos")]
697 | param()
698 | $return = [PSCustomObject] | Select-Object -Property X, Y
699 | $return.X = [System.Windows.Forms.Cursor]::Position.X
700 | $return.Y = [System.Windows.Forms.Cursor]::Position.Y
701 | return $return
702 | }
703 |
704 | function Get-WindowClass {
705 | <#
706 | .SYNOPSIS
707 | Gets the class of a window by handle
708 |
709 | ALIASES
710 | Winclass
711 |
712 | .DESCRIPTION
713 | This function gets the class of a window by handle
714 |
715 | .PARAMETER Handle
716 | The handle of the window
717 |
718 | .EXAMPLE
719 | $class = Get-WindowClass (Get-WindowExists "Untitled - Notepad")
720 |
721 | .EXAMPLE
722 | $class = Get-WindowClass -handle (Get-WindowExists "Untitled - Notepad")
723 |
724 | .EXAMPLE
725 | $class = (Get-WindowExists "Untitled - Notepad") | Get-WindowClass
726 |
727 | .INPUTS
728 | Handle as Handle
729 |
730 | .OUTPUTS
731 | String
732 | #>
733 | [Alias("winclass")]
734 | [CmdletBinding()]
735 | param (
736 | [Parameter(Mandatory,
737 | ValueFromPipeline)]
738 | [int]$Handle
739 | )
740 | $stringbuilt = New-Object System.Text.StringBuilder 256
741 | $that = [vds]::GetClassName($Handle, $stringbuilt, 256)
742 | return $($stringbuilt.ToString())
743 | }
744 |
745 | function Get-WindowFromPoint {
746 | <#
747 | .SYNOPSIS
748 | Returns the window panel from an x y point
749 |
750 | ALIASES
751 | Winatpoint
752 |
753 | .DESCRIPTION
754 | This function returns the window panel from an x y point
755 |
756 | .PARAMETER x
757 | The x point
758 |
759 | .PARAMETER y
760 | The y point
761 |
762 | .EXAMPLE
763 | $xyWindow = Get-WindowFromPoint 980 540
764 |
765 | .EXAMPLE
766 | $xyWindow = Get-WindowFromPoint -x 980 -y 540
767 |
768 | .INPUTS
769 | x as Integer, y as Integer
770 |
771 | .OUTPUTS
772 | Handle
773 | #>
774 | [Alias("Winatpoint")]
775 | [CmdletBinding()]
776 | param (
777 | [Parameter(Mandatory)]
778 | [int]$x,
779 | [Parameter(Mandatory)]
780 | [int]$y
781 | )
782 | $p = new-object system.drawing.point($x,$y)
783 | $return = [vds]::WindowFromPoint($p)
784 | return $return
785 | }
786 |
787 | function Get-WindowParent {
788 | <#
789 | .SYNOPSIS
790 | Returns the handle of a windows parent
791 |
792 | ALIASES
793 | Winparent
794 |
795 | .DESCRIPTION
796 | This function returns the handle of a windows parent
797 |
798 | .PARAMETER Handle
799 | The handle of the child window
800 |
801 | .EXAMPLE
802 | $winexists = Get-WindowParent (Get-ChildWindow "Libraries")
803 |
804 | .EXAMPLE
805 | $winexists = Get-WindowParent -handle (Get-ChildWindow "Libraries")
806 |
807 | .EXAMPLE
808 | $winexists = (Get-ChildWindow "Libraries") | Get-WindowParent
809 |
810 | .INPUTS
811 | Handle as Integer
812 |
813 | .OUTPUTS
814 | Integer
815 | #>
816 | [Alias("Winparent")]
817 | [CmdletBinding()]
818 | param (
819 | [Parameter(Mandatory,
820 | ValueFromPipeline)]
821 | [int]$Handle
822 | )
823 | return [vds]::GetParent($Handle)
824 | }
825 |
826 | function Get-WindowPosition {
827 | <#
828 | .SYNOPSIS
829 | Returns an object with Left, Top, Width and Height properties of a windows position
830 |
831 | ALIASES
832 | Winpos
833 |
834 | .DESCRIPTION
835 | This function returns an object with Left, Top, Width and Height properties of a windows position according to a handle specified
836 |
837 | .PARAMETER Handle
838 | The handle of the window to return the postion of
839 |
840 | .EXAMPLE
841 | $winpos = Get-WindowPosition (Get-WindowExists "Untitled - Notepad")
842 |
843 | .EXAMPLE
844 | $winpos = Get-WindowPosition -handle (Get-WindowExists "Untitled - Notepad")
845 |
846 | .EXAMPLE
847 | $winexists = (Get-ChildWindow "Libraries") | Get-WindowParent
848 |
849 | .INPUTS
850 | Handle as Integer
851 |
852 | .OUTPUTS
853 | Integer
854 | #>
855 | [Alias("Winpos")]
856 | [CmdletBinding()]
857 | param (
858 | [Parameter(Mandatory,
859 | ValueFromPipeline)]
860 | [int]$Handle
861 | )
862 | $return = [PSCustomObject] | Select-Object -Property Top, Left, Width, Height
863 | $Rect = New-Object RECT
864 | [vds]::GetWindowRect($Handle,[ref]$Rect) | Out-Null
865 | $return.Top = $Rect.Top
866 | $return.Left = $Rect.Left
867 | $return.Width = $Rect.Right - $Rect.Left
868 | $return.Height = $Rect.Bottom - $Rect.Top
869 | return $return
870 | }
871 |
872 | function Get-WindowText {
873 | <#
874 | .SYNOPSIS
875 | Returns the text of a window
876 |
877 | ALIASES
878 | Wintext
879 |
880 | .DESCRIPTION
881 | This function returns the text of a window
882 |
883 | .PARAMETER Handle
884 | The handle of the window to return the sibling of
885 |
886 | .EXAMPLE
887 | $wintext = Get-WindowText (Get-WindowExists "notepad")
888 |
889 | .EXAMPLE
890 | $wintext = Get-WindowText -handle (Get-WindowExists "notepad")
891 |
892 | .EXAMPLE
893 | $wintext = (Get-WindowExists "notepad") | Get-WindowText
894 |
895 | .INPUTS
896 | Handle as Integer
897 |
898 | .OUTPUTS
899 | Integer
900 | #>
901 | [Alias("Wintext")]
902 | [CmdletBinding()]
903 | param (
904 | [Parameter(Mandatory,
905 | ValueFromPipeline)]
906 | [int]$Handle
907 | )
908 | $strbld = [vds]::GetWindowTextLength($Handle)
909 | $stringbuilt = New-Object System.Text.StringBuilder $strbld+1
910 | $that = [vds]::GetWindowText($Handle, $stringbuilt, $strbld+1)
911 | return $($stringbuilt.ToString())
912 | }
913 |
914 | function Set-DPIAware {
915 | <#
916 | .SYNOPSIS
917 | Causes the dialog window to be DPI Aware.
918 | .DESCRIPTION
919 | This function will call upon the windows application programming
920 | interface to cause the window to be DPI Aware.
921 | .EXAMPLE
922 | Set-DPIAware
923 | #>
924 | $vscreen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height
925 | [vds]::SetProcessDPIAware() | out-null
926 | $screen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height
927 | $global:ctscale = ($screen/$vscreen)
928 | }
929 |
930 | function Set-EnableVisualStyle {
931 | <#
932 | .SYNOPSIS
933 | Enables modern visual styles in the dialog window.
934 | .DESCRIPTION
935 | This function will call upon the windows application programming
936 | interface to apply modern visual style to the window.
937 | .EXAMPLE
938 | Set-EnableVisualStyle
939 | #>
940 | [vds]::SetCompat() | out-null
941 | }
942 |
943 | function Set-Types {
944 |
945 | <#
946 | .SYNOPSIS
947 | Various C# calls and references
948 | #>
949 | Add-Type -AssemblyName System.Windows.Forms,presentationframework, presentationcore, Microsoft.VisualBasic
950 |
951 | Add-Type @"
952 | using System;
953 | using System.Drawing;
954 | using System.Runtime.InteropServices;
955 | using System.Windows.Forms;
956 | using System.ComponentModel;
957 | using System.Collections.Generic;
958 |
959 | public class vds {
960 |
961 | public static void SetCompat()
962 | {
963 | // SetProcessDPIAware();
964 | Application.EnableVisualStyles();
965 | Application.SetCompatibleTextRenderingDefault(false);
966 | }
967 |
968 | [System.Runtime.InteropServices.DllImport("user32.dll")]
969 | public static extern bool SetProcessDPIAware();
970 |
971 | [DllImport("user32.dll")]
972 | public static extern bool InvertRect(IntPtr hDC, [In] ref RECT lprc);
973 |
974 | [DllImport("user32.dll")]
975 | public static extern IntPtr GetDC(IntPtr hWnd);
976 |
977 | [DllImport("user32.dll")]
978 | public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
979 |
980 | [DllImport("user32.dll")]
981 | public static extern IntPtr WindowFromPoint(System.Drawing.Point p);
982 | // Now working in pwsh 7 thanks to advice from seeminglyscience#2404 on Discord
983 | [DllImport("user32.dll")]
984 | public static extern IntPtr GetParent(IntPtr hWnd);
985 | [DllImport("user32.dll")]
986 | public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
987 | [DllImport("user32.dll")]
988 | public static extern bool ShowWindow(int hWnd, WindowState nCmdShow);
989 | public enum WindowState
990 | {
991 | SW_HIDE = 0,
992 | SW_SHOW_NORMAL = 1,
993 | SW_SHOW_MINIMIZED = 2,
994 | SW_MAXIMIZE = 3,
995 | SW_SHOW_MAXIMIZED = 3,
996 | SW_SHOW_NO_ACTIVE = 4,
997 | SW_SHOW = 5,
998 | SW_MINIMIZE = 6,
999 | SW_SHOW_MIN_NO_ACTIVE = 7,
1000 | SW_SHOW_NA = 8,
1001 | SW_RESTORE = 9,
1002 | SW_SHOW_DEFAULT = 10,
1003 | SW_FORCE_MINIMIZE = 11
1004 | }
1005 |
1006 | [DllImport("user32.dll")]
1007 | private static extern bool SetCursorPos(int x, int y);
1008 |
1009 | [DllImport("User32.dll")]
1010 | public static extern bool MoveWindow(int hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
1011 | [DllImport("User32.dll")]
1012 | public static extern bool GetWindowRect(int hWnd, out RECT lpRect);
1013 |
1014 |
1015 | [DllImport("user32.dll", EntryPoint="FindWindow")]
1016 | internal static extern int FWBC(string lpClassName, int ZeroOnly);
1017 | public static int FindWindowByClass(string lpClassName) {
1018 | return FWBC(lpClassName, 0);}
1019 |
1020 | [DllImport("user32.dll", EntryPoint="FindWindow")]
1021 | internal static extern int FWBT(int ZeroOnly, string lpTitle);
1022 | public static int FindWindowByTitle(string lpTitle) {
1023 | return FWBT(0, lpTitle);}
1024 |
1025 | [DllImport("user32.dll")]
1026 | public static extern IntPtr GetForegroundWindow();
1027 |
1028 | [DllImport("user32.dll")]
1029 | public static extern IntPtr GetWindow(int hWnd, uint uCmd);
1030 |
1031 | [DllImport("user32.dll")]
1032 | public static extern int GetWindowTextLength(int hWnd);
1033 |
1034 | [DllImport("user32.dll")]
1035 | public static extern IntPtr GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
1036 |
1037 | [DllImport("user32.dll")]
1038 | public static extern IntPtr GetClassName(IntPtr hWnd, System.Text.StringBuilder text, int count);
1039 |
1040 | [DllImport("user32.dll")]
1041 | public static extern bool SetWindowPos(int hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
1042 |
1043 | [DllImport ("user32.dll")]
1044 | public static extern bool SetParent(int ChWnd, int hWnd);
1045 |
1046 | [DllImport("user32.dll")]
1047 | public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
1048 |
1049 | [DllImport("User32.dll")]
1050 | public static extern bool SetWindowText(IntPtr hWnd, string lpString);
1051 |
1052 |
1053 | //CC-BY-SA
1054 | //Adapted from script by StephenP
1055 | //https://stackoverflow.com/users/3594883/stephenp
1056 | [DllImport("User32.dll")]
1057 | extern static uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
1058 |
1059 | public struct INPUT
1060 | {
1061 | public int type; // 0 = INPUT_MOUSE,
1062 | // 1 = INPUT_KEYBOARD
1063 | // 2 = INPUT_HARDWARE
1064 | public MOUSEINPUT mi;
1065 | }
1066 |
1067 | public struct MOUSEINPUT
1068 | {
1069 | public int dx ;
1070 | public int dy ;
1071 | public int mouseData ;
1072 | public int dwFlags;
1073 | public int time;
1074 | public IntPtr dwExtraInfo;
1075 | }
1076 |
1077 | const int MOUSEEVENTF_MOVED = 0x0001 ;
1078 | const int MOUSEEVENTF_LEFTDOWN = 0x0002 ;
1079 | const int MOUSEEVENTF_LEFTUP = 0x0004 ;
1080 | const int MOUSEEVENTF_RIGHTDOWN = 0x0008 ;
1081 | const int MOUSEEVENTF_RIGHTUP = 0x0010 ;
1082 | const int MOUSEEVENTF_MIDDLEDOWN = 0x0020 ;
1083 | const int MOUSEEVENTF_MIDDLEUP = 0x0040 ;
1084 | const int MOUSEEVENTF_WHEEL = 0x0080 ;
1085 | const int MOUSEEVENTF_XDOWN = 0x0100 ;
1086 | const int MOUSEEVENTF_XUP = 0x0200 ;
1087 | const int MOUSEEVENTF_ABSOLUTE = 0x8000 ;
1088 |
1089 | const int screen_length = 0x10000 ;
1090 |
1091 | public static void LeftClickAtPoint(int x, int y, int width, int height)
1092 | {
1093 | //Move the mouse
1094 | INPUT[] input = new INPUT[3];
1095 | input[0].mi.dx = x*(65535/width);
1096 | input[0].mi.dy = y*(65535/height);
1097 | input[0].mi.dwFlags = MOUSEEVENTF_MOVED | MOUSEEVENTF_ABSOLUTE;
1098 | //Left mouse button down
1099 | input[1].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
1100 | //Left mouse button up
1101 | input[2].mi.dwFlags = MOUSEEVENTF_LEFTUP;
1102 | SendInput(3, input, Marshal.SizeOf(input[0]));
1103 | }
1104 |
1105 | public static void RightClickAtPoint(int x, int y, int width, int height)
1106 | {
1107 | //Move the mouse
1108 | INPUT[] input = new INPUT[3];
1109 | input[0].mi.dx = x*(65535/width);
1110 | input[0].mi.dy = y*(65535/height);
1111 | input[0].mi.dwFlags = MOUSEEVENTF_MOVED | MOUSEEVENTF_ABSOLUTE;
1112 | //Left mouse button down
1113 | input[1].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
1114 | //Left mouse button up
1115 | input[2].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
1116 | SendInput(3, input, Marshal.SizeOf(input[0]));
1117 | }
1118 | //End CC-SA
1119 | [DllImport("user32.dll")] public static extern int SetForegroundWindow(IntPtr hwnd);
1120 |
1121 |
1122 | }
1123 |
1124 | public struct RECT
1125 |
1126 | {
1127 | public int Left;
1128 | public int Top;
1129 | public int Right;
1130 | public int Bottom;
1131 | }
1132 | "@ -ReferencedAssemblies System.Windows.Forms, System.Drawing, System.Drawing.Primitives
1133 |
1134 | if ((get-host).version.major -eq 7) {
1135 | if ((get-host).version.minor -eq 0) {
1136 | Add-Type @"
1137 | using System;
1138 | using System.Drawing;
1139 | using System.Runtime.InteropServices;
1140 | using System.Windows.Forms;
1141 | using System.ComponentModel;
1142 | public class vdsForm:Form {
1143 | [DllImport("user32.dll")]
1144 | public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
1145 | [DllImport("user32.dll")]
1146 | public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
1147 | protected override void WndProc(ref Message m) {
1148 | base.WndProc(ref m);
1149 | if (m.Msg == 0x0312) {
1150 | int id = m.WParam.ToInt32();
1151 | foreach (Control item in this.Controls) {
1152 | if (item.Name == "hotkey") {
1153 | item.Text = id.ToString();
1154 | }
1155 | }
1156 | }
1157 | }
1158 | }
1159 | "@ -ReferencedAssemblies System.Windows.Forms,System.Drawing,System.Drawing.Primitives,System.Net.Primitives,System.ComponentModel.Primitives,Microsoft.Win32.Primitives
1160 | }
1161 | else{
1162 | Add-Type @"
1163 | using System;
1164 | using System.Drawing;
1165 | using System.Runtime.InteropServices;
1166 | using System.Windows.Forms;
1167 | using System.ComponentModel;
1168 | public class vdsForm:Form {
1169 | [DllImport("user32.dll")]
1170 | public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
1171 | [DllImport("user32.dll")]
1172 | public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
1173 | protected override void WndProc(ref Message m) {
1174 | base.WndProc(ref m);
1175 | if (m.Msg == 0x0312) {
1176 | int id = m.WParam.ToInt32();
1177 | foreach (Control item in this.Controls) {
1178 | if (item.Name == "hotkey") {
1179 | item.Text = id.ToString();
1180 | }
1181 | }
1182 | }
1183 | }
1184 | }
1185 | "@ -ReferencedAssemblies System.Windows.Forms,System.Drawing,System.Drawing.Primitives,System.Net.Primitives,System.ComponentModel.Primitives,Microsoft.Win32.Primitives,System.Windows.Forms.Primitives
1186 | }
1187 | }
1188 | else {
1189 | Add-Type @"
1190 | using System;
1191 | using System.Drawing;
1192 | using System.Runtime.InteropServices;
1193 | using System.Windows.Forms;
1194 | using System.ComponentModel;
1195 | public class vdsForm:Form {
1196 | [DllImport("user32.dll")]
1197 | public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
1198 | [DllImport("user32.dll")]
1199 | public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
1200 | protected override void WndProc(ref Message m) {
1201 | base.WndProc(ref m);
1202 | if (m.Msg == 0x0312) {
1203 | int id = m.WParam.ToInt32();
1204 | foreach (Control item in this.Controls) {
1205 | if (item.Name == "hotkey") {
1206 | item.Text = id.ToString();
1207 | }
1208 | }
1209 | }
1210 | }
1211 | }
1212 | "@ -ReferencedAssemblies System.Windows.Forms,System.Drawing
1213 | }
1214 |
1215 | <#
1216 | Function: FlashWindow
1217 | Author: Boe Prox
1218 | https://social.technet.microsoft.com/profile/boe%20prox/
1219 | Adapted to VDS: 20190212
1220 | License: Microsoft Limited Public License
1221 | #>
1222 |
1223 | Add-Type -TypeDefinition @"
1224 | //"
1225 | using System;
1226 | using System.Collections.Generic;
1227 | using System.Text;
1228 | using System.Runtime.InteropServices;
1229 |
1230 | public class Window
1231 | {
1232 | [StructLayout(LayoutKind.Sequential)]
1233 | public struct FLASHWINFO
1234 | {
1235 | public UInt32 cbSize;
1236 | public IntPtr hwnd;
1237 | public UInt32 dwFlags;
1238 | public UInt32 uCount;
1239 | public UInt32 dwTimeout;
1240 | }
1241 |
1242 | //Stop flashing. The system restores the window to its original state.
1243 | const UInt32 FLASHW_STOP = 0;
1244 | //Flash the window caption.
1245 | const UInt32 FLASHW_CAPTION = 1;
1246 | //Flash the taskbar button.
1247 | const UInt32 FLASHW_TRAY = 2;
1248 | //Flash both the window caption and taskbar button.
1249 | //This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
1250 | const UInt32 FLASHW_ALL = 3;
1251 | //Flash continuously, until the FLASHW_STOP flag is set.
1252 | const UInt32 FLASHW_TIMER = 4;
1253 | //Flash continuously until the window comes to the foreground.
1254 | const UInt32 FLASHW_TIMERNOFG = 12;
1255 |
1256 |
1257 | [DllImport("user32.dll")]
1258 | [return: MarshalAs(UnmanagedType.Bool)]
1259 | static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
1260 |
1261 | public static bool FlashWindow(IntPtr handle, UInt32 timeout, UInt32 count)
1262 | {
1263 | IntPtr hWnd = handle;
1264 | FLASHWINFO fInfo = new FLASHWINFO();
1265 |
1266 | fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
1267 | fInfo.hwnd = hWnd;
1268 | fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
1269 | fInfo.uCount = count;
1270 | fInfo.dwTimeout = timeout;
1271 |
1272 | return FlashWindowEx(ref fInfo);
1273 | }
1274 | }
1275 | "@
1276 | $global:ctscale = 1
1277 | }
1278 | Set-Types
1279 |
1280 | function Set-WindowOnTop {
1281 | <#
1282 | .SYNOPSIS
1283 | Causes a window to be on top of other windows
1284 |
1285 | ALIAS
1286 | Window-Ontop
1287 |
1288 | .DESCRIPTION
1289 | This function causes a window to be on top of other windows
1290 |
1291 | .PARAMETER Handle
1292 | The handle of the window
1293 |
1294 | .EXAMPLE
1295 | Set-WindowOnTop (Get-WindowExists "Untitled - Notepad")
1296 |
1297 | .EXAMPLE
1298 | Set-WindowOnTop -handle (Get-WindowExists "Untitled - Notepad")
1299 |
1300 | .EXAMPLE
1301 | (Get-WindowExists "Untitled - Notepad") | Set-WindowOnTop
1302 |
1303 | .INPUTS
1304 | Handle as Handle
1305 | #>
1306 | [Alias("Window-OnTop")]
1307 | [CmdletBinding()]
1308 | param (
1309 | [Parameter(Mandatory,
1310 | ValueFromPipeline)]
1311 | [int]$Handle
1312 | )
1313 | [vds]::SetWindowPos($Handle, -1, (Get-WindowPosition $Handle).Left, (Get-WindowPosition $Handle).Top, (Get-WindowPosition $Handle).Width, (Get-WindowPosition $Handle).Height, 0x0040) | out-null
1314 | }
1315 |
1316 | function Show-InformationDialog {
1317 | <#
1318 | .SYNOPSIS
1319 | Displays a information dialog with a message and title specified.
1320 |
1321 | ALIAS
1322 | Info
1323 |
1324 | .DESCRIPTION
1325 | This function displays a information dialog with a message and title specified.
1326 |
1327 | .PARAMETER Message
1328 | The message to display
1329 |
1330 | .PARAMETER Title
1331 | The title to display
1332 |
1333 | .EXAMPLE
1334 | Show-InformationDialog "Message"
1335 |
1336 | .EXAMPLE
1337 | Show-InformationDialog -message "Message" -title "Title"
1338 |
1339 | .EXAMPLE
1340 | "Message" | Show-InformationDialog -title "Title"
1341 |
1342 | .INPUTS
1343 | Message as String, Title as String
1344 |
1345 | .OUTPUTS
1346 | MessageBox
1347 | #>
1348 | [Alias("Info")]
1349 | [CmdletBinding()]
1350 | param (
1351 | [Parameter(Mandatory,
1352 | ValueFromPipeline)]
1353 | [string]$Message,
1354 | [string]$Title
1355 | )
1356 | [System.Windows.Forms.MessageBox]::Show($Message,$Title,'OK',64) | Out-Null
1357 | }
1358 |
1359 | function Update-ErrorLog {
1360 | <#
1361 | .SYNOPSIS
1362 | Logs errors to the text file 'exceptions.txt' for use in the catch
1363 | statement of a try catch.
1364 |
1365 | .DESCRIPTION
1366 | This function logs errors to the text file 'exceptions.txt' residing in
1367 | the current directory in use by powershell, for use in the catch
1368 | statement of a try catch.
1369 |
1370 | .PARAMETER ErrorRecord
1371 | The object from the pipeline represented by $_ or $PSItem
1372 |
1373 | .PARAMETER Message
1374 | The message to display to the end user.
1375 |
1376 | .PARAMETER Promote
1377 | Switch that defines to also call a throw of the ValueFromPipeline
1378 |
1379 | .EXAMPLE
1380 | Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered adding $($Xml.ToString()) to $($ParentControl.Name)"
1381 |
1382 | .EXAMPLE
1383 | Update-ErrorLog -Promote -ErrorRecord $_ -Message "Exception encountered adding $($Xml.ToString()) to $($ParentControl.Name)"
1384 |
1385 | .INPUTS
1386 | ErrorRecord as ValueFromPipeline, Message as String, Promote as Switch
1387 |
1388 | .Outputs
1389 | String || String, Throw method of ValueFromPipeline
1390 | #>
1391 | param(
1392 | [System.Management.Automation.ErrorRecord]$ErrorRecord,
1393 | [string]$Message,
1394 | [switch]$Promote
1395 | )
1396 |
1397 | if ( $Message -ne '' ) {
1398 | [void][System.Windows.Forms.MessageBox]::Show("$($Message)`r`n`r`nCheck '$(get-currentdirectory)\exceptions.txt' for details.",'Exception Occurred')
1399 | }
1400 | $date = Get-Date -Format 'yyyyMMdd HH:mm:ss'
1401 | $ErrorRecord | Out-File "$(get-currentdirectory)\tmpError.txt"
1402 | Add-Content -Path "$(get-currentdirectory)\exceptions.txt" -Value "$($date): $($(Get-Content "$(get-currentdirectory)\tmpError.txt") -replace "\s+"," ")"
1403 | Remove-Item -Path "$(get-currentdirectory)\tmpError.txt"
1404 | if ( $Promote ) {
1405 | throw $ErrorRecord
1406 | }
1407 | }
1408 |
1409 |
1410 | ConvertFrom-WinFormsXML -Reference refs -Suppress -Xml @"
1411 |
1412 | "@
1413 | #endregion VDS
1414 | #region Images
1415 | $MainForm.Icon = [System.Drawing.Icon]::FromHandle(([System.Drawing.Bitmap][System.Drawing.Image]::FromStream([System.IO.MemoryStream][System.Convert]::FromBase64String("AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAUXZUDEFqSGv///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAiZp4GG2KarSJnnf8RW5OH////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wAycqoGK22lrVWNvP+Jtd3/GF+X/////wD///8A////AP///wD///8A////AP///wD///8A////AP///wBEf7cGPHmxrWSXxf+dweT/ZpnH/x9lnev///8A////AP///wD///8A3bKPAtmuipfWqYXj06V//dCge/3NnHbkopOK3nWizP+ry+j/dqTO/zBwqOsoa6Mn////AP///wD///8A5L2bAuG4lsDoya7/9eHN//fl0//35dH/893I/9+6nP/HqJH/hq7V/0F9tes5d68n////AP///wD///8A////AOjDopft0Lf/+OjZ//XeyP/z2L3/89a7//Tbwv/35NL/37ud/52UkvdLhLwn////AP///wD///8A////AP///wDsyKjj9+fX//bhzP/028L/9NrA//PYvf/z17v/9NvC//Peyf/Nn3vn////AP///wD///8A////AP///wD///8A8M6u/fns3//138j/9d3G//Tcw//02sH/89m+//PXvf/45tP/06V//f///wD///8A////AP///wD///8A////APTTtP357eH/9uHM//Xfyf/13sf/9NzE//Tbwv/02sD/+OfW/9eqhv3///8A////AP///wD///8A////AP///wD317nj+eve//fn1v/24cz/9eDK//XeyP/13cX/9uHL//Xi0P/bsIzj////AP///wD///8A////AP///wD///8A+tu9l/jizP/67uP/9+fW//bizv/24cv/9uPQ//nq3f/sz7X/37aTl////wD///8A////AP///wD///8A////APzewAL6277A+eLN//rs3v/57uL/+e3i//jp2v/w1b3/58CfwOO8mgL///8A////AP///wD///8A////AP///wD///8A/N7BAvrcv5f52bvj9ta4/fTTtP3xz6/j7surl+vGpgL///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD/4wAA/8MAAP+DAADgBwAAwA8AAIAfAACAHwAAgB8AAIAfAACAHwAAgB8AAMA/AADgfwAA//8AAA=="))).GetHicon())
1416 |
1417 | #endregion
1418 |
1419 | $Button.add_Click({param($sender, $e);
1420 | $Button.Text = "Click on Another Window"
1421 | $winactive = (winactive)
1422 | while ($winactive -eq $MainForm.Handle)
1423 | {
1424 | start-sleep 1
1425 | $winactive = (winactive)
1426 | }
1427 | $Button.text = "Capture"
1428 | $win = $(winatpoint $(mousepos).X $(mousepos).Y)
1429 | if ($win -ne 0){
1430 | $buildstring = "
1431 | Window: $win
1432 | Window Class: $(winclass $win)
1433 | Window Text: $(wintext $win)
1434 | "
1435 | $Label1.Text = $buildstring
1436 | $ask = $(ask "Attempt to Capture parents? I may crash!")
1437 | if ($ask -eq "Yes"){
1438 | $tabstr = ""
1439 | $parent = $(winparent $win)
1440 | if ($parent -ne $null) {
1441 | while ($parent -ne 0) {
1442 | $tabstr+=$(tab)
1443 | $buildstring+= "
1444 | $tabstr Parent: $parent
1445 | $tabstr Parent Class: $(winclass $parent)
1446 | $tabstr Parent Text: $(wintext $parent)
1447 | "
1448 | $Label1.Text = $buildstring
1449 | $parent = $(winparent $parent)
1450 | }
1451 | $Label1.Text = $buildstring
1452 | $buildstring = ""
1453 | }
1454 | }
1455 | }
1456 | })
1457 |
1458 | $Button2.add_Click({param($sender, $e);
1459 | $Button2.Text = "Hover over another window."
1460 | start-sleep 1
1461 | $Button2.Text = "5"
1462 | while ($i -lt 5)
1463 | {
1464 | start-sleep 1
1465 | $i = $i+1
1466 | $button2.text = ((5-$i) | out-string).trim()
1467 | }
1468 | $Button2.text = "Countdown Capture"
1469 | $win = $(winatpoint $(mousepos).X $(mousepos).Y)
1470 | if ($win -ne 0){
1471 | $buildstring = "
1472 | Window: $win
1473 | Window Class: $(winclass $win)
1474 | Window Text: $(wintext $win)
1475 | "
1476 | $Label1.Text = $buildstring
1477 | $ask = $(ask "Attempt to Capture parents? I may crash!")
1478 | if ($ask -eq "Yes"){
1479 | $tabstr = ""
1480 | $parent = $(winparent $win)
1481 | if ($parent -ne $null) {
1482 | while ($parent -ne 0) {
1483 | $tabstr+=$(tab)
1484 | $buildstring+= "
1485 | $tabstr Parent: $parent
1486 | $tabstr Parent Class: $(winclass $parent)
1487 | $tabstr Parent Text: $(wintext $parent)
1488 | "
1489 | $Label1.Text = $buildstring
1490 | $parent = $(winparent $parent)
1491 | }
1492 | $Label1.Text = $buildstring
1493 | $buildstring = ""
1494 | }
1495 | }
1496 | }
1497 |
1498 | })
1499 | [System.Windows.Forms.Application]::Run($MainForm) | Out-Null}); $PowerShell.AddParameter('File',$args[0]) | Out-Null; $PowerShell.Invoke() | Out-Null; $PowerShell.Dispose() | Out-Null
1500 |
--------------------------------------------------------------------------------
/Examples/XAMLPad Express.fbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Examples/XAMLPad Express/Events.ps1:
--------------------------------------------------------------------------------
1 | #region Images
2 |
3 | #endregion
4 |
5 | <#
6 | The MIT License (MIT)
7 |
8 | Copyright (c) 2015 Microsoft
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | SOFTWARE.
27 | #>
28 |
29 |
30 | $page = @"
31 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
45 |
46 |
47 |
48 | Content inside of a Border
49 |
50 | ]]>
51 |
52 |
53 |
54 |
55 |
56 |
67 | ]]>
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
79 |
83 |
87 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
120 |
121 |
122 |
123 | January 2004
124 |
125 |
126 |
127 |
129 |
130 |
131 | Sun
132 | Mon
133 | Tue
134 | Wed
135 | Thu
136 | Fri
137 | Sat
138 |
139 |
140 | 1
141 | 2
142 | 3
143 | 4
144 | 5
145 | 6
146 | 7
147 | 8
148 | 9
149 | 10
150 | 11
151 | 12
152 | 13
153 | 14
154 | 15
155 | 16
156 | 17
157 | 18
158 | 19
159 | 20
160 | 21
161 | 22
162 | 23
163 | 24
164 | 25
165 | 26
166 | 27
167 | 28
168 | 29
169 | 30
170 | 31
171 |
172 | ]]>
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 | Dock = "Top"
181 |
182 |
183 | Dock = "Top"
184 |
185 |
186 | Dock = "Bottom"
187 |
188 |
189 | Dock = "Left"
190 |
191 |
192 | This content fills the remaining, unallocated space.
193 |
194 |
195 | ]]>
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 | ]]>
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 | Stacked Item #1
218 |
219 |
220 | Stacked Item #2
221 |
222 |
223 | Stacked Item #3
224 |
225 |
226 | Stacked Item #4
227 |
228 |
229 | Stacked Item #5
230 |
231 |
232 | ]]>
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 | ]]>
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 | Check Box
252 | ]]>
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 | Item1
261 | Item2
262 | Item3
263 |
264 | ]]>
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 | ]]>
274 |
275 |
276 |
277 |
278 |
279 |
280 | Navigate to MSDN
281 | ]]>
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 | ]]>
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 | Use your Mouse or Stylus to draw on the screen.
298 |
299 | ]]>
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 | Item 1
308 | Item 2
309 | Item 3
310 | Item 4
311 | Item 5
312 |
313 | ]]>
314 |
315 |
316 |
317 |
318 |
319 |
320 |
336 | ]]>
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 | ]]>
345 |
346 |
347 |
348 |
349 |
350 |
351 | Radio Button
352 |
353 | ]]>
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 | Some Content
364 |
365 |
366 |
367 | ]]>
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 | Scrolling is
377 | enabled when it is necessary.
378 |
379 |
380 |
381 | ]]>
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
394 |
398 |
402 |
406 |
407 |
408 |
409 |
410 | Canvas Overview
411 |
412 |
413 | [This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
414 | The Canvas element is used to position content according to absolute x- and y-coordinates. Canvas provides ultimate flexibility for positioning and arranging elements on the screen. Elements can be drawn in a unique location, or in the event that elements occupy the same coordinates, the order in which they appear in markup determines the order in which elements are drawn.
415 |
416 | This topic contains the following sections.
417 |
418 |
419 |
420 | What Can I Do with the Canvas?
421 | Adding a Border to a Canvas Element
422 | Order of Elements in a Canvas
423 | Creating a Canvas in "XAML"
424 | Creating a Canvas in Code
425 |
426 |
427 |
428 | What Can I Do with the Canvas?
429 | Canvas provides the most flexible layout support of any Panel element. Height and Width properties are used to define the area of the canvas, and elements inside are assigned absolute coordinates relative to the upper left corner of the parent Canvas. This allows you to position and arrange elements precisely where you want them on the screen.
430 |
431 | Adding a Border to a Canvas Element
432 | In order for a Canvas element to have a border, it must be encapsulated within a Border element.
433 |
434 |
435 | ]]>
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 | ]]>
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 | ]]>
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 | Planetary Information
482 |
483 |
484 | Planet
485 | Distance from Sun
486 | Diameter
487 | Mass
488 |
489 |
490 |
491 |
492 | The Inner Planets
493 |
494 |
495 | Mercury
496 | 57,910,000 km
497 | 4,880 km
498 | 3.30e23 kg
499 |
500 |
501 | Venus
502 | 108,200,000 km
503 | 12,103.6 km
504 | 4.869e24 kg
505 |
506 |
507 | Earth
508 | 149,600,000 km
509 | 12,756.3 km
510 | 5.972e24 kg
511 |
512 |
513 | Mars
514 | 227,940,000 km
515 | 6,794 km
516 | 6.4219e23 kg
517 |
518 |
519 | The Outer Planets
520 |
521 |
522 | Jupiter
523 | 778,330,000 km
524 | 142,984 km
525 | 1.900e27 kg
526 |
527 |
528 | Saturn
529 | 1,429,400,000 km
530 | 120,536 km
531 | 5.68e26 kg
532 |
533 |
534 | Uranus
535 | 2,870,990,000 km
536 | 51,118 km
537 | 8.683e25 kg
538 |
539 |
540 | Neptune
541 | 4,504,000,000 km
542 | 49,532 km
543 | 1.0247e26 kg
544 |
545 |
546 |
547 |
548 | Information from the Encarta web site.
550 |
551 |
552 |
553 |
554 |
555 | ]]>
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 | Hello World!
564 |
565 | ]]>
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 | Some text to select...
574 |
575 | ]]>
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 | ]]>
588 |
589 |
590 |
591 |
592 |
593 |
594 | TextBox with ToolTip
595 |
596 | useful information goes here
597 |
598 |
599 | ]]>
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
612 |
613 |
614 |
615 |
616 |
617 |
623 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 | XAMLPad Express
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 | Layout
671 |
672 |
673 |
674 |
675 |
676 | Controls
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 | "@
737 |
738 | $winhost = New-WPFWindow -Title 'XamlPad' -Height 600 -Width 800 -Grid HostGrid
739 | $winhost.Content = ConvertFrom-WPFXaml -xaml $page
740 |
741 | $LayoutListBox.add_SelectionChanged({
742 | $Details.DataContext = $LayoutListBox.DataContext
743 | })
744 |
745 | $SecondLayOutListBox.add_SelectionChanged({
746 | $Details.DataContext = $SecondLayOutListBox.DataContext
747 | })
748 |
749 | $TextBox1.add_KeyUp({
750 | $cc.Children.Clear();
751 | $cc.Children.Add([System.Windows.UIElement] (ConvertFrom-WPFXaml -xaml $TextBox1.Text))
752 | })
753 |
754 | $LayoutListBox.add_MouseUp({
755 | $cc.Children.Clear()
756 | $cc.Children.Add([System.Windows.UIElement] (ConvertFrom-WPFXaml -xaml $TextBox1.Text))
757 | })
758 |
759 | $SecondLayOutListBox.add_MouseUp({$cc.Children.Clear();
760 | $cc.Children.Add([System.Windows.UIElement] (ConvertFrom-WPFXaml -xaml $TextBox1.Text))
761 | })
762 |
763 | $rPreview.add_Click({
764 | $MainGrid.FindName('CodeRow').Height = 0
765 | $MainGrid.FindName('PreviewRow').Height = '*'
766 | })
767 |
768 | $rXaml.add_Click({
769 | $MainGrid.FindName('PreviewRow').Height = 0
770 | $MainGrid.FindName('CodeRow').Height = '*'
771 | })
772 |
773 | $rSplit.add_Click({
774 | $MainGrid.FindName('PreviewRow').Height = '*'
775 | $MainGrid.FindName('CodeRow').Height = '*'
776 | })
777 |
778 | $winhost.ShowDialog()
--------------------------------------------------------------------------------
/Examples/XAMLPad Express/Finds.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brandoncomputer/powershell-designer/95199dfd51eab1c88f9008a0ef4fbc689610c54d/Examples/XAMLPad Express/Finds.txt
--------------------------------------------------------------------------------
/FastColoredTextBox.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brandoncomputer/powershell-designer/95199dfd51eab1c88f9008a0ef4fbc689610c54d/FastColoredTextBox.dll
--------------------------------------------------------------------------------
/FastColoredTextBoxLicense.txt:
--------------------------------------------------------------------------------
1 |
2 | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
3 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
4 | IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
5 | PURPOSE.
6 |
7 | License: GNU Lesser General Public License (LGPLv3)
8 |
9 | Email: pavel_torgashov@ukr.net.
10 |
11 | Copyright (C) Pavel Torgashov, 2011-2016.
--------------------------------------------------------------------------------
/PSGetModuleInfo.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brandoncomputer/powershell-designer/95199dfd51eab1c88f9008a0ef4fbc689610c54d/PSGetModuleInfo.xml
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | install-module powershell-designer
2 |
3 | Contributing:
4 | It's better to make changes to functions.ps1, events.ps1 and designer.fbs. Changes to designer.ps1 will be lost in the next 'compile' if the changes are made there and not elsewhere.
5 |
6 | Made decision that there will not be a 'dark mode'. And that decision was wrong. I get to do that sometimes.
7 |
8 | There will be no exe compiler. It's not that I can't, it's that I can't make it NetInfoSec compliant, and it would be inferior to other listed solutions. See bottom recommendation.
9 | Best solution: Develop a custom solution using a program that is not .Net based that allows a Text embed section that is changable via Resource Hacker by Angus Johnson. AES Encrypt/decrypt text using native function in program.
10 | Next solution: Same as above but use base64
11 | Next Solution: Same as above but don't encode or encrypt
12 | Next Solution: ps12exe by steve02081504
13 | Next Solution: ps2exe by MScholtes
14 | Next Solution: vds-exe compiler by brandoncomputer
15 |
16 | My goal is not the best at everything. My goal is to be the best WinForms Designer/RAD IDE for PowerShell.
17 |
--------------------------------------------------------------------------------
/WinFormsCreatorLicense.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Benjamin Turmo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/famfamfam.md:
--------------------------------------------------------------------------------
1 | Original readme (from author of the icons)
2 | ----------
3 |
4 | Silk icon set 1.3
5 |
6 | _________________________________________
7 |
8 | Mark James
9 | http://www.famfamfam.com/lab/icons/silk/
10 |
11 | _________________________________________
12 |
13 | This work is licensed under a
14 | Creative Commons Attribution 2.5 License.
15 | [ http://creativecommons.org/licenses/by/2.5/ ]
16 |
17 | This means you may use it for any purpose,
18 | and make any changes you like.
19 | All I ask is that you include a link back
20 | to this page in your credits.
21 |
22 | Are you using this icon set? Send me an email
23 | (including a link or picture if available) to
24 | mjames@gmail.com
25 |
26 | Any other questions about this icon set please
27 | contact mjames@gmail.com
28 |
--------------------------------------------------------------------------------
/functions/Dependencies.ps1:
--------------------------------------------------------------------------------
1 | $lst_Functions.items.addrange(((((get-command -module Microsoft.PowerShell.Utility) | select -expandproperty Name) | Out-String).split((get-character 13)+(get-character 10))).Trim())
2 | $lst_Functions.items.addrange(((((get-command -module Microsoft.PowerShell.Management) | select -expandproperty Name) | Out-String).split((get-character 13)+(get-character 10))).Trim())
3 | $lst_Functions.items.addrange(((((get-command -module Microsoft.PowerShell.Core) | select -expandproperty Name) | Out-String).split((get-character 13)+(get-character 10))).Trim())
4 |
5 | $functionTimer = (New-Timer -Interval 1000)
6 |
7 | $functionTimer.Add_Tick({
8 | if ($script:debugging -eq $true) {
9 | $functionTimer.Interval = 60000
10 | }
11 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Add-Hotkey")) -eq $True) {
12 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Add-CommonControl"), $true)
13 | }
14 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Set-WindowNotOnTop")) -eq $True) {
15 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-WindowPosition"), $true)
16 | }
17 |
18 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Set-WindowOnTop")) -eq $True) {
19 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-WindowPosition"), $true)
20 | }
21 |
22 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Close-Window")) -eq $True) {
23 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("New-SendMessage"), $true)
24 | }
25 |
26 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Send-ClickToWindow")) -eq $True) {
27 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-WindowPosition"), $true)
28 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Set-ActiveWindow"), $true)
29 | }
30 |
31 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Send-RightClickToWindow")) -eq $True) {
32 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-WindowPosition"), $true)
33 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Set-ActiveWindow"), $true)
34 | }
35 |
36 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-BootTime")) -eq $True) {
37 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-SubString"), $true)
38 | }
39 |
40 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-Key")) -eq $True) {
41 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-Ascii"), $true)
42 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-Character"), $true)
43 | }
44 |
45 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-Escape")) -eq $True) {
46 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-Character"), $true)
47 | }
48 |
49 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-CarriageReturn")) -eq $True) {
50 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-Character"), $true)
51 | }
52 |
53 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-LineFeed")) -eq $True) {
54 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-Character"), $true)
55 | }
56 |
57 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Send-Window")) -eq $True) {
58 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Set-ActiveWindow"), $true)
59 | }
60 |
61 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Open-DataSourceName")) -eq $True) {
62 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-ODBC"), $true)
63 | }
64 |
65 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Close-DataSourceName")) -eq $True) {
66 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-ODBC"), $true)
67 | }
68 |
69 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-DataTables")) -eq $True) {
70 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-ODBC"), $true)
71 | }
72 |
73 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Add-ContextMenuStripItem")) -eq $True) {
74 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-ImageFromStream"), $true)
75 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-ImageFromFile"), $true)
76 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-SubString"), $true)
77 | }
78 |
79 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Add-MenuRow")) -eq $True) {
80 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-ImageFromStream"), $true)
81 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-ImageFromFile"), $true)
82 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-SubString"), $true)
83 | }
84 |
85 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Add-ToolStripItem")) -eq $True) {
86 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-ImageFromStream"), $true)
87 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-ImageFromFile"), $true)
88 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-SubString"), $true)
89 | }
90 |
91 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Show-Excel")) -eq $True) {
92 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
93 | }
94 |
95 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Hide-Excel")) -eq $True) {
96 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
97 | }
98 |
99 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Add-ExcelWorkbook")) -eq $True) {
100 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
101 | }
102 |
103 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Add-ExcelWorksheet")) -eq $True) {
104 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
105 | }
106 |
107 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Open-ExcelWorkbook")) -eq $True) {
108 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
109 | }
110 |
111 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Save-ExcelWorkbook")) -eq $True) {
112 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
113 | }
114 |
115 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Select-ExcelSheet")) -eq $True) {
116 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
117 | }
118 |
119 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Set-ExcelCell")) -eq $True) {
120 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
121 | }
122 |
123 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-ExcelCell")) -eq $True) {
124 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
125 | }
126 |
127 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Remove-ExcelColumn")) -eq $True) {
128 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
129 | }
130 |
131 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Remove-ExcelRow")) -eq $True) {
132 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
133 | }
134 |
135 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("New-ExcelColumn")) -eq $True) {
136 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
137 | }
138 |
139 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("New-ExcelRow")) -eq $True) {
140 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
141 | }
142 |
143 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-ExcelColumnCount")) -eq $True) {
144 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
145 | }
146 |
147 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-ExcelRowCount")) -eq $True) {
148 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Excel"), $true)
149 | }
150 |
151 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Remove-Font")) -eq $True) {
152 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-SubString"), $true)
153 | }
154 |
155 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL")) -eq $True) {
156 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Initialize-Selenium"), $true)
157 | }
158 |
159 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-SeleniumElementByAttribute")) -eq $True) {
160 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL"), $true)
161 | }
162 |
163 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-SeleniumElementByXPath")) -eq $True) {
164 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL"), $true)
165 | }
166 |
167 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Send-SeleniumElementByAttribute")) -eq $True) {
168 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL"), $true)
169 | }
170 |
171 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Send-SeleniumElementByXPath")) -eq $True) {
172 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL"), $true)
173 | }
174 |
175 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Send-ClickToSeleniumElementByAttribute")) -eq $True) {
176 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL"), $true)
177 | }
178 |
179 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Send-ClickToSeleniumElementByXPath")) -eq $True) {
180 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL"), $true)
181 | }
182 |
183 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Stop-Selenium")) -eq $True) {
184 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Open-SeleniumURL"), $true)
185 | }
186 |
187 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Start-WebServer")) -eq $True) {
188 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Stop-WebServer"), $true)
189 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-WebServerContext"), $true)
190 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-WebServerLocalPath"), $true)
191 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Set-WebServerResponse"), $true)
192 | }
193 |
194 | if ($lst_Functions.GetItemChecked($lst_Functions.Items.IndexOf("Get-StringRemove")) -eq $True) {
195 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-SubString"), $true)
196 | }
197 |
198 | #region These functions are needed for all projects
199 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Set-Types"), $true)
200 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Set-EnableVisualStyle"), $true)
201 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Set-DPIAware"), $true)
202 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Update-ErrorLog"), $true)
203 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("Get-CurrentDirectory"), $true)
204 | $lst_Functions.SetItemChecked($lst_Functions.Items.IndexOf("ConvertFrom-WinFormsXML"), $true)
205 | #endregion
206 | })
--------------------------------------------------------------------------------
/license.md:
--------------------------------------------------------------------------------
1 | Copyright 2022 Brandon Cunningham
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/powershell-designer.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | powershell-designer
5 | 2.7.7
6 | Brandon Cunningham
7 | Brandon Cunningham
8 | false
9 | https://github.com/brandoncomputer/powershell-designer/blob/main/license.md
10 | https://github.com/brandoncomputer/powershell-designer
11 | The best free form designer for powershell.
12 | The best free form designer for powershell.
13 | (c) Brandon Cunningham. Portions (c) Benjamin Turmo, Pavel Torgashov & Mark James
14 | PSModule PSIncludes_Function PSFunction_powershell-designer PSCommand_powershell-designer
15 |
16 |
--------------------------------------------------------------------------------
/powershell-designer.psd1:
--------------------------------------------------------------------------------
1 | #
2 | # Module manifest for module 'powershell-designer'
3 | #
4 | # Generated by: Brandon Cunningham
5 | #
6 | # Generated on: 4/8/2022
7 | #
8 |
9 | @{
10 |
11 | # Script module or binary module file associated with this manifest.
12 | RootModule = 'powershell-designer.psm1'
13 |
14 | # Version number of this module.
15 | ModuleVersion = '2.7.5'
16 |
17 | # Supported PSEditions
18 | # CompatiblePSEditions = @()
19 |
20 | # ID used to uniquely identify this module
21 | GUID = '4c2c5765-b14e-47f3-8714-233976227be1'
22 |
23 | # Author of this module
24 | Author = 'Brandon Cunningham'
25 |
26 | # Company or vendor of this module
27 | CompanyName = 'Brandon Cunningham'
28 |
29 | # Copyright statement for this module
30 | Copyright = '(c) Brandon Cunningham. Portions (c) Benjamin Turmo, Pavel Torgashov & Mark James'
31 |
32 | # Description of the functionality provided by this module
33 | Description = 'The best free form designer for powershell.'
34 |
35 | # Minimum version of the PowerShell engine required by this module
36 | # PowerShellVersion = ''
37 |
38 | # Name of the PowerShell host required by this module
39 | # PowerShellHostName = ''
40 |
41 | # Minimum version of the PowerShell host required by this module
42 | # PowerShellHostVersion = ''
43 |
44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45 | # DotNetFrameworkVersion = ''
46 |
47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48 | # ClrVersion = ''
49 |
50 | # Processor architecture (None, X86, Amd64) required by this module
51 | # ProcessorArchitecture = ''
52 |
53 | # Modules that must be imported into the global environment prior to importing this module
54 | # RequiredModules = @()
55 |
56 | # Assemblies that must be loaded prior to importing this module
57 | # RequiredAssemblies = @()
58 |
59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module.
60 | # ScriptsToProcess = @()
61 |
62 | # Type files (.ps1xml) to be loaded when importing this module
63 | # TypesToProcess = @()
64 |
65 | # Format files (.ps1xml) to be loaded when importing this module
66 | # FormatsToProcess = @()
67 |
68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69 | # NestedModules = @()
70 |
71 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72 | FunctionsToExport = '*'
73 |
74 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75 | CmdletsToExport = '*'
76 |
77 | # Variables to export from this module
78 | VariablesToExport = '*'
79 |
80 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81 | AliasesToExport = '*'
82 |
83 | # DSC resources to export from this module
84 | # DscResourcesToExport = @()
85 |
86 | # List of all modules packaged with this module
87 | # ModuleList = @()
88 |
89 | # List of all files packaged with this module
90 | # FileList = @()
91 |
92 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93 | PrivateData = @{
94 |
95 | PSData = @{
96 |
97 | # Tags applied to this module. These help with module discovery in online galleries.
98 | # Tags = @()
99 |
100 | # A URL to the license for this module.
101 | LicenseUri = 'https://github.com/brandoncomputer/powershell-designer/blob/main/license.md'
102 |
103 | # A URL to the main website for this project.
104 | ProjectUri = 'https://github.com/brandoncomputer/powershell-designer'
105 |
106 | # A URL to an icon representing this module.
107 | # IconUri = ''
108 |
109 | # ReleaseNotes of this module
110 | ReleaseNotes = 'The best free form designer for powershell.'
111 |
112 | # Prerelease string of this module
113 | # Prerelease = ''
114 |
115 | # Flag to indicate whether the module requires explicit user acceptance for install/update/save
116 | # RequireLicenseAcceptance = $false
117 |
118 | # External dependent modules of this module
119 | # ExternalModuleDependencies = @()
120 |
121 | } # End of PSData hashtable
122 |
123 | } # End of PrivateData hashtable
124 |
125 | # HelpInfo URI of this module
126 | # HelpInfoURI = ''
127 |
128 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129 | # DefaultCommandPrefix = ''
130 |
131 | }
132 |
133 |
--------------------------------------------------------------------------------
/powershell-designer.psm1:
--------------------------------------------------------------------------------
1 |
2 | function powershell-designer($a) {
3 | function path($a) {
4 | return Split-Path -Path $a
5 | }
6 | function chr($a) {
7 | $a = $a | Out-String
8 | return [char][byte]$a
9 | }
10 |
11 | $folderExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions")
12 | if ($folderExists -eq $false){
13 | New-Item -ItemType directory -Path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions")
14 | }
15 |
16 | $functionsExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\functions.psm1")
17 | if ($functionsExists -eq $false){
18 | Copy-Item -Path "$PSScriptRoot\functions\functions.psm1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\functions.psm1")
19 | }
20 |
21 | $dependenciesExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\Dependencies.ps1")
22 | if ($dependenciesExists -eq $false){
23 | Copy-Item -Path "$PSScriptRoot\functions\Dependencies.ps1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\Dependencies.ps1")
24 | }
25 |
26 | $designerExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\designer\designer.ps1")
27 | if ($designerExists -eq $false){
28 | New-Item -ItemType directory -Path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
29 | Copy-Item -Path "$PSScriptRoot\Designer.fbs" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer")
30 | Copy-Item -Path "$PSScriptRoot\Designer\Designer.ps1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
31 | Copy-Item -Path "$PSScriptRoot\Designer\Events.ps1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
32 | Copy-Item -Path "$PSScriptRoot\Designer\finds.txt" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
33 | }
34 |
35 | $ExamplesExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Examples")
36 | if ($ExamplesExists -eq $false){
37 | Copy-Item -Path "$PSScriptRoot\Examples" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Examples") -recurse
38 | }
39 |
40 | if ($a) {
41 | if ((get-host).version.major -eq 7) {
42 | if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
43 | start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)","$($a)"
44 | }
45 | else {
46 | start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)","$($a)"
47 | }
48 | }
49 | else {
50 | if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
51 | start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)","$($a)"
52 | }
53 | else {
54 | start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)","$($a)"
55 | }
56 | }
57 | }
58 | else{
59 | if ((get-host).version.major -eq 7) {
60 | if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
61 | start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)"
62 | }
63 | else {
64 | start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)"
65 | }
66 | }
67 | else {
68 | if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
69 | start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)"
70 | }
71 | else {
72 | start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)"
73 | }
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------