Advertisement

06.27.2008 at 12:57PM PDT, ID: 23522852
[x]
Attachment Details

Web Service opens Notepad.exe - now how to send keystrokes?

Asked by knowlton in Programming for ASP.NET

I have a nonsensical web service (just playing around -- having fun, learning how it works) that opens Notepad.exe

Once I open Notepad.exe -- how do I send keystrokes programmatically?  Web services / web apps don't seem to know about SendKeys.



using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

namespace WebService1
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
        public string ReturnSomeString()
        {

            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("C:\\Windows\\System32\\notepad.exe");


           
            System.Diagnostics.Process pp = new System.Diagnostics.Process();

            pp.StartInfo = psi;

            pp.Start();
           
//generate a delay so i can "notice" that Notepad opened...

            for(int i = 0;i < 20000; i++)
            {
                for(int j = 0;j < 20000; j++)
                {
                   
                }

            }

            pp.Kill();

           

            string sc = "blah";

            return sc;
        }
    }
}

Start Free Trial
 
Loading Advertisement...
 
[+][-]06.27.2008 at 01:36PM PDT, ID: 21887385

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 07:52AM PDT, ID: 21899634

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 12:45PM PDT, ID: 21976734

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Sign Up Now!
Solution Provided By: tedbilly
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906