Windows Input Box not working for me RRS feed

  • Question

  • I have copied the script referenced here: http://technet.microsoft.com/en-us/library/ff730941.aspx directly into ISE. When I execute the script, nothing is getting set into $x. If I type $objTextBox.Text, I can see the value entered, but $x contains nothing. I assume neither:

    $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")



    Are actually setting the variable $x as they should, but I am unclear as to why. Can someone please help?


    Monday, January 5, 2015 9:37 PM


All replies

  • Hi,

    See this:


    This has come up many times before, I wish someone over at Microsoft would update those scripts.

    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    • Marked as answer by mpleaf Monday, January 5, 2015 10:42 PM
    Monday, January 5, 2015 9:47 PM
  • Beautiful! Thanks so much. "MY" script was a bit more complicated, but when I couldn't get this basic one to work, no way would mine. With the suggestions above, I was able to get mine working as well, and better!

    Thanks much!


    Monday, January 5, 2015 10:43 PM
  • If you set a buttons DialogResult it will close the form withuot adding code.  If you want to access form data after a foorm is closed declare the form variable as global:

    $global:MyForm=New-Object System.Windows.Forms.Form

    Now you have access to all of the forrms variables after the formm closes.


    You must name all ontrols yuo want to access in this way. Just set the "Name" property as needed.

    This is how dialogs are designed to work n WIndows.


    Monday, January 5, 2015 10:52 PM
  • Please check my article at codeproject for extensive journey of using all core Windows Forms, WPF, Selenium with Powershell for tasks which often require various option prompts.


    You find there over 40 common Windows form patterns  ( prompts, grids, check/radio boxes, progress bars of many forms, tree views, item lists, passwords, tool tips, system tray widgets, browser controls, examples of using p/invoke, hosting custom controls, dealing with selenium webdriver, dealing with selenium-unfriendly file upload dialogs etc. ) all covered there - working code for every example is provided, and the code is hosted on github.
    Sunday, January 18, 2015 10:35 PM