Combreal

imgButton.ps1

Apr 3rd, 2021
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
  2. [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
  3.  
  4. $handler_GetButton_Click=
  5. {
  6.     $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
  7.         InitialDirectory = [Environment]::GetFolderPath('Desktop')
  8.         #Filter = 'Documents (*.docx)|*.docx|SpreadSheet (*.xlsx)|*.xlsx'
  9.     }
  10.     $null = $FileBrowser.ShowDialog()
  11.     [System.Windows.Forms.MessageBox]::Show($FileBrowser.FileName, "Bitlocker key :", "OK")
  12. }
  13.  
  14. $testGUI = New-Object System.Windows.Forms.Form
  15. $testGUI.Text = "GUITest"
  16. $testGUI.Name = "GT"
  17. $testGUI.DataBindings.DefaultDataSourceUpdateMode = 0
  18. $System_Drawing_Size = New-Object System.Drawing.Size
  19. $System_Drawing_Size.Width = 330
  20. $System_Drawing_Size.Height = 252
  21. $testGUI.ClientSize = $System_Drawing_Size
  22. $iconBase64 = 'AAABAAEAMDAAAAEAIACBBgAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAwAAAAMAgGAAAAVwL5hwAABkhJREFUaIHtWHtME3cc//zu2mspbQFRfE1Fo6DZhGnUMZSpY4mTMJzZZA8zYpw6F7NodBMZowbxvUlmFudzik73wC0qIpvJnIpBjRINasQHZg1MrWIZ0FKuj7vf/sCitgdc4aos2eePpvk+P5/73e91BApgwY2zTFTy3B6ilhupqre/xbhciSwlI5ocTVoACNWF8gKhlSLHnfaE639leNfl+8e2122KSRC72pt0NjE3bjyWXypD1pikoTqzZQFjc0xj3O7BRHzEiTwsT0FbbZRhIKrVf4kG3SFHdN9Na8pLq/LixyOnouzpCEhPT8fYknP4zG5G7vMvz+dumtcQtxAOSjtOfqIzgahm64WY6KycK2e2fKmPxvmUcSgsLAysTCDBJ06cwKRJk/Dh8ix2wI5D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QGmlOkgKcPM/4rs3PEgQETicvyVXSGOD3haeCtjgFeR+g7bRWBtLXIgUgsAy0PcLtAMDX1etZocsf4SSh+AhQQuA26I7ULpoZtaT2umFJ7XVD3ZIPotwG3RFKlJ9XCo8Ahat3j5+XW66/iw35mI6WF2jD+q9qAaTm9on9SWOxvtOFL5p+UHQERI3GCY7LBIBPp6ThAICDD/8DADguU9RonEr2VFQAq2Jv6QjbCABfHS1qtXv/6wjbyKrYW0r2VFSAIFJts8OBnMkpfr6cySlodjggiFSrZE9FBRCXawjtGTE473gJCgoKWu0FBQXIO14C2jNiMHG5hijZU1kBggBSYykCgFmzZrXavf9JjaWICIJUaqeh8DJKwNnt/Q9TGuHrOUxpBGe391dyBQKCshMTMIDfrtViU34f+M9fKf8X8KwRFAFSRYP1pIJS98zuHUY5NiUQlOM0t3B18cYxyZv1Wi0BADvPU9vC1R8Ho1cQBBCoGmxxzeUVmx2tFm+jbn+c9oI89htcSM4BFcOS7nQvpmjhJOWTFGCM6mXpXld7CmNUr7tSHkkBV8fF7PJoOJ50AxEEFB4Nx1cmxO6S8vsJWBqfiN179zbYIo0TXGEGczDusXJBCYErzGC2RRonFOz5vjEzPtEv5l8G7kH5AsusdAAAAABJRU5ErkJggg=='
  23. $iconBytes = [Convert]::FromBase64String($iconBase64)
  24. $stream = New-Object IO.MemoryStream($iconBytes, 0, $iconBytes.Length)
  25. $stream.Write($iconBytes, 0, $iconBytes.Length);
  26. $iconImage = [System.Drawing.Image]::FromStream($stream, $true)
  27. $testGUI.Icon = [System.Drawing.Icon]::FromHandle((New-Object System.Drawing.Bitmap -Argument $stream).GetHIcon())
  28.  
  29. $getButton = New-Object System.Windows.Forms.Button
  30. $getButton.TabIndex = 0
  31. $getButton.Name = "button"
  32. $System_Drawing_Size = New-Object System.Drawing.Size
  33. $System_Drawing_Size.Width = 310
  34. $System_Drawing_Size.Height = 232
  35. $getButton.Size = $System_Drawing_Size
  36. $getButton.UseVisualStyleBackColor = $True  
  37. #$getButton.Text = "OK"  
  38. $System_Drawing_Point = New-Object System.Drawing.Point
  39. $System_Drawing_Point.X = 10
  40. $System_Drawing_Point.Y = 10
  41. $getButton.Location = $System_Drawing_Point
  42. $getButton.DataBindings.DefaultDataSourceUpdateMode = 0
  43. $getButton.add_Click($handler_GetButton_Click)
  44. $image = [System.Drawing.Image]::FromFile("D:\Pictures\misc\Magnifying_Glass_Photo.jpg")
  45. $getButton.Image = $image
  46. $testGUI.Controls.Add($getButton)
  47.  
  48. $testGUI.ShowDialog()| Out-Null  
Add Comment
Please, Sign In to add comment