Send Keystorkes

I want to send keystrokes like Alt+F4.

Solution

This is possible with a coded solution:

  1. Add an Assembly Reference to System.Windows.Forms.
  2. Add a coded step to the test.

Here is the full code-behind file, excluding the standard using/Imports statements and the Dynamic Pages Reference region:

using System.Windows.Forms;

namespace TestProject8
{     
    public class SendKeystrokes : BaseWebAiiTest    {  


        [CodedStep(@"New Coded Step")]
         public void Keystrokes()
        {
            Manager.Desktop.KeyBoard.SendString("%{F4}");
        }
    }
}
Imports System.Windows.Forms

Namespace TestProject8
    Public Class SendKeystrokes
        Inherits BaseWebAiiTest

        <CodedStep("New Coded Step")> _
        Public Sub KeyStrokes()

        Manager.Desktop.KeyBoard.SendString("%{F4}")

        End Sub
    End Class
End Namespace

Here you can find the list with key codes.

I want to perform multi-select while holding down the Ctrl key.

Solution

This is possible with a coded solution:

  1. Add an Assembly Reference to System.Windows.Forms.
  2. Add a coded step to the test.

Here is the full code-behind file, excluding the standard using/Imports statements and the Dynamic Pages Reference region:

using System.Windows.Forms;

namespace TestProject8
{     
    public class SendKeystrokes : BaseWebAiiTest    {  


        [CodedStep(@"New Coded Step")]
         public void Keystrokes()
        {


                Manager.Desktop.KeyBoard.KeyDown(Keys.Control);

                //You can put the click steps HERE

                Manager.Desktop.KeyBoard.KeyUp(Keys.Control);
        }
    }
}
Imports System.Windows.Forms

Namespace TestProject8
    Public Class SendKeystrokes
        Inherits BaseWebAiiTest

        <CodedStep("New Coded Step")> _
        Public Sub KeyStrokes()

            Manager.Desktop.KeyBoard.KeyDown(Keys.Control)

            'You can put the click steps HERE

            Manager.Desktop.KeyBoard.KeyUp(Keys.Control)


        End Sub
    End Class
End Namespace