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.Protoc
ols;
using System.Xml.Linq;
namespace WebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "
http://tempuri.org/")]
[WebServiceBinding(Conform
sTo = 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.Service
s.ScriptSe
rvice]
public class Service1 : System.Web.Services.WebSer
vice
{
[WebMethod]
public string ReturnSomeString()
{
System.Diagnostics.Process
StartInfo psi = new System.Diagnostics.Process
StartInfo(
"C:\\Windo
ws\\System
32\\notepa
d.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