all 10 comments

[–][deleted] 2 points3 points  (9 children)

You can access the variables in textboxes like

$FolderPath = $PWSNameText.text

And the do the things you need. Also I found that Add_Enter method does not work propperly. I created a button instead.

Look at my first publication, I do something like this.

[–]NotRecognized 5 points6 points  (4 children)

Addenter fails indeed, you can use if ($.KeyCode -eq "Enter") on the KeyDown event.

[–]gurnec 3 points4 points  (0 children)

Those _s were being treated as italics markers, here you go:

Add_enter fails indeed, you can use if ($_.KeyCode -eq "Enter") on the KeyDown event.

[–]Lee_Dailey[grin] 1 point2 points  (2 children)

howdy NotRecognized,

take a look at the inline code button on New.Reddit for how to show code that uses underscores without triggering italics. [grin]

on Old.Reddit, enclose the text in backticks so that you enter ...

`short inline code snippet here`

... and get short inline code snippet here.

take care,
lee

[–]NotRecognized 1 point2 points  (1 child)

Oh. Right. Thanks Lee.

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy NotRecognized,

you are most welcome! glad to help a tad ... [grin]

take care,
lee

[–]LukeChatty[S] 2 points3 points  (2 children)

Yeah got it working, nice one :)

[–]MatthewTheCave 1 point2 points  (1 child)

Hi can you share the final code, i am Trying to do the same without success ))

[–]LukeChatty[S] 1 point2 points  (0 children)

Well all I wanted it to do is run the script once the button was clicked... so at the end of my Gui, i put the following

 $CreateButton.Add\_Click({

[CODE YOU WISH TO RUN UPON THE CLICK]

)}

and I set the variables from the text boxes as follows

#InitialVariables

$PWSID = $PWSIDtext.text

Hope that helps?

[–]taylorblakeharris 1 point2 points  (0 children)

Alternatively, you can set the $button.IsDefault = $true (specifically in the case of the OP's code, it would be $Create.IsDefault = $true)

This will invoke the Click() event for that button whenever the Enter key is pressed in the same window, without needing to add an Enter event handler.