YellowOnline

WTFOMG

May 29th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # YellowOnline's entry for OMGWTF
  2. #
  3. # Instructions:
  4. #  Save as OMG-WTF.ps1 (or any other name) and run with PowerShell. Make sure to set the script execution policy right first.
  5. # Comments:
  6. # 1) Everything you dislike is on purpose ^^
  7. # 2) Most flexers can't properly highlight this code because of an annoying variable.
  8. #    Congrats to Pastebin who also have trouble with it, but only for that line :)
  9. # 3) In a scripting language like PoSh it is hard to compete with a real programming language when it comes to writing bad code. Injecting, say, C# or VB.NET, would be a bit cheating.
  10. #
  11.  
  12. Function Randomize-Output($Input){$myResult = Get-Random -Minimum $([decimal]$($AllPossibilitys[0]."0")) -Maximum $($([decimal]$($($AllPossibilitys[1]."1")))+1);Return $([math]::truncate($myResult));}
  13. Function Calculate-TheThing()
  14.     {
  15.     [int]$Zero="0"
  16.     [int]$One="1"
  17.     If($Zero -EQ 0){$One="1"}
  18.     ElseIf ($One -EQ 1){$Zero="0"} Else{$One="1";$Zero="0"}
  19.     $Array = @($Zero,$One)
  20.     $TextInfo = [System.Threading.Thread]::CurrentThread.CurrentCulture.TextInfo  
  21.     $AllPossibilitys=@()
  22.     ForEach ($Object in $Array) {$NewObject = New-Object System.Object;$NewObject|Add-Member -MemberType Noteproperty -Name "$Object" -Value "$Object";$AllPossibilitys += $NewObject}
  23.     ${²&|é@"#'(§^è!!ç`{à`})°}=Randomize-Output $Null
  24.     Switch (${²&|é@"#'(§^è!!ç`{à`})°}){0{$a = $TextInfo.ToTitleCase($("YES").ToLower())};1{$a = $TextInfo.ToTitleCase($("NO").ToLower())}}
  25.     Return $a;
  26.     }
  27.    
  28. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  29. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  30. $Form = New-Object System.Windows.Forms.Form
  31. $Form.Text = "TDWTF Management"
  32. $Form.Size = New-Object System.Drawing.Size(300,200)
  33. $Form.StartPosition = "CenterScreen"
  34. $Form.KeyPreview = $True
  35. $Form.Add_KeyDown({if ($_.KeyCode -eq "Enter"){$Form.Close()}})
  36. $Form.Add_KeyDown({if ($_.KeyCode -eq "Escape"){$Form.Close()}})
  37. $OutputBox = New-Object System.Windows.Forms.Label
  38. $OutputBox.Location = New-Object System.Drawing.Size(25,40)
  39. $OutputBox.Size = New-Object System.Drawing.Size(110,20)
  40. $OutputBox.Text = ""
  41. $Form.Controls.Add($OutputBox)
  42. $GenerateButton = New-Object System.Windows.Forms.Button
  43. $GenerateButton.Location = New-Object System.Drawing.Size(25,120)
  44. $GenerateButton.Size = New-Object System.Drawing.Size(75,23)
  45. $GenerateButton.Text = "Generate"
  46. $GenerateButton.Add_Click({
  47.                             $12 = Calculate-TheThing
  48.                             $OutputBox.Text = "Our advice is: `"$12`""
  49.                             })
  50. $Form.Controls.Add($GenerateButton)
  51. $OKButton = New-Object System.Windows.Forms.Button
  52. $OKButton.Location = New-Object System.Drawing.Size(100,120)
  53. $OKButton.Size = New-Object System.Drawing.Size(75,23)
  54. $OKButton.Text = "OK"
  55. $OKButton.Add_Click({$Form.Close()})
  56. $Form.Controls.Add($OKButton)
  57. $CancelButton = New-Object System.Windows.Forms.Button
  58. $CancelButton.Location = New-Object System.Drawing.Size(175,120)
  59. $CancelButton.Size = New-Object System.Drawing.Size(75,23)
  60. $CancelButton.Text = "Cancel"
  61. $CancelButton.Add_Click({$Form.Close()})
  62. $Form.Controls.Add($CancelButton)
  63. $Form.Controls.Add($objLabel)
  64. $ListBox = New-Object System.Windows.Forms.ListBox
  65. $ListBox.Location = New-Object System.Drawing.Size(10,40)
  66. $ListBox.Size = New-Object System.Drawing.Size(260,20)
  67. $ListBox.Height = 80
  68. $Form.Topmost = $True
  69. $Form.Add_Shown({$Form.Activate()})
  70. [void] $Form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment