如何在 System.Windows.Forms.TextBox powershell 中获得焦点?

how to get focus in System.Windows.Forms.TextBox powershell?

我使用 powershell 制作了一个 window 表单。

我有一个文本框,我想重点关注。

如何为 TextBox 添加焦点并使其更易于使用?

这是我的代码

...

    # TextBox
    $textbox = New-Object System.Windows.Forms.TextBox
    $textbox.AutoSize = $true
    $textbox.Location = New-Object System.Drawing.Point(150,125)
    $textbox.Name = 'textbox_sw'
    $textbox.Size = New-Object System.Drawing.Size(220,20)
    $textbox.Text = "Nom de la clef USB ici"
    #$textbox.Focused

...

终于从这个postHow to set keyboard focus to a TextBox in Powershell找到了 所以它给出

$form.Add_Shown({$form.Activate(); $textbox.Focus()}).

现在我专注于我的文本框