Send Keys to Application Programmatically using C#

Posted By:Jean PaulPosted Date:November 30, 2013Points:200
Category: SharePointURL:http://www.dotnetspark.com
In this article we have explored a Send Key scenario with Windows API as the solution. You can comment on better ideas for the problem.

In this article we can explore a scenario I have encountered while working with SharePoint.

Scenario

My client had a Production issue where the Request Tracking report is too huge in size and cannot be downloaded. Although the problem is fixed, we need to test this in our UAT environment.

To test this we need 1000 requests logged in the SharePoint site. How to create the 1000 requests?

Open a browser and browse to our SharePoint site. Ensure you have logged in correctly.

Now execute our application and enter the title of the Browser in the application. In this case it is: "Reports - All Documents - Windows Internet Explorer"

Enter the Key value. For F5 key, it is ASCII 116. Set the Interval as 4 seconds which will create around 900 requests per hour.

After setting the values click theStartbutton. You will see that the browser is made as foreground window and the Refresh process starts repeating every 4 seconds. (Observe the Refresh of browser status bar)