0
因此,我正在制作一个脚本来监视应用程序来的文件夹,我希望他们使用控制台SDK部署,控制台SDK有它自己的命令,所以我必须输入它们。Windows输入模拟器或发送密钥将无法在控制台应用程序,打开另一个控制台
监视器在它看到文件夹中的某些内容后打开了SDK,但输入模拟器或发送键命令不起作用。
while (path == null)
{
Run();
}
if (path != null)
{
toOpen();
}
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public static void Run()
{
Console.WriteLine("Usage: Watcher.exe (Test Scanner)");
string args = @"E:\Test Scanner";
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = args;
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
// Begin watching.
watcher.EnableRaisingEvents = true;
Console.WriteLine(path);
// Wait for the software to quit the program.
//Console.WriteLine("Wait for System String Deploy to procede");
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
//Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
path = e.FullPath.ToString();
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
}
private static void toOpen() {
string toOpen = @"C:\Program Files (x86)\Microsoft Durango XDK\xdk\Command Prompts\Xbox One XDK Visual Studio 2015 Command Prompt";
System.Diagnostics.Process.Start(toOpen);
System.Threading.Thread.Sleep(5000);
InputSimulator.SimulateTextEntry("xbconnect" + "127.0.0.1");
System.Threading.Thread.Sleep(500);
InputSimulator.SimulateTextEntry("xbapp deploy" + path);
Console.ReadLine();
}
发送键。例如:
System.Diagnostics.Process.Start(toOpen);
System.Threading.Thread.Sleep(5000);
SendKeys.SendWait("xbconnect 127.0.0.1");
System.Threading.Thread.Sleep(500);
SendKeys.SendWait("xbapp deploy" + path);
Console.ReadLine();
任何想法,为什么它可能无法正常工作。
注意:可能有括号关闭,因为这不是完整的脚本,我只是复制粘贴一块。