Guest User

Untitled

a guest
Jul 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. $installDir = Split-Path -Path $myinvocation.mycommand.path
  2. & $env:SystemRootsystem32WindowsPowerShellv1.0powershell.exe -sta (Join-Path $installDir "TestDrop.ps1")
  3.  
  4. ## TestDrop.ps1 for testing drag & drop
  5.  
  6. function DragNDrop {
  7. #region Import the Assemblies
  8. [reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") | Out-Null
  9. [reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
  10. [reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") | Out-Null
  11. [reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") | Out-Null
  12.  
  13. #endregion
  14.  
  15. [System.Windows.Forms.Application]::EnableVisualStyles()
  16. $objForm = New-Object System.Windows.Forms.Form
  17. $objTextBox = New-Object System.Windows.Forms.TextBox
  18.  
  19. $handler_DragEnter={
  20. write-host "$Event Enter"
  21. $Event.Effect = "Copy" # not sure about this ...
  22. }
  23.  
  24. $objForm.Text = "Test Drag & Drop"
  25. $objForm.Size = New-Object System.Drawing.Size(200,200)
  26. $objForm.StartPosition = "CenterScreen"
  27. $objForm.KeyPreview = $True
  28. $objForm.SizeGripStyle = 'Hide'
  29. $objForm.FormBorderStyle = 'Fixed3D'
  30.  
  31. $objTextBox.AllowDrop = $true
  32. $objTextBox.Location = New-Object System.Drawing.Size(10,25)
  33. $objTextBox.Size = New-Object System.Drawing.Size(120,120)
  34. $objTextBox.Multiline = $true
  35. $objTextBox.TabIndex = 1
  36. $objTextBox.Text = "Try to Drag & Drop File Here..."
  37. $objTextBox.Add_DragEnter({ write-host "Event Enter" })
  38. $objTextBox.Add_DragDrop({ write-host "Event Drop" })
  39. $objForm.Controls.Add($objTextBox)
  40. $objForm.Topmost = $True
  41.  
  42. return $objForm.ShowDialog()
  43.  
  44. } #End Function
  45.  
  46. DragNDrop | Out-Null
  47.  
  48. $objTextBox.Add_DragEnter({
  49. write-host "Event Enter"
  50. $_.Effect = 'Copy'
  51. })
Add Comment
Please, Sign In to add comment