2017-09-06 5 views
0

Je crée donc un script qui surveille un dossier où les applications arrivent, et je veux qu'elles soient déployées à l'aide d'un SDK de console, Le SDK de la console a ses propres commandes, donc je dois les entrer.Windows Input Simulator ou Send Keys ne fonctionnera pas sur une application console qui ouvre une autre console

Le moniteur fonctionne, après avoir vu quelque chose dans le dossier, il ouvre le SDK, mais les commandes de simulateur d'entrée ou de touche d'envoi ne font rien.

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(); 

    } 

Envoyer Clés exemple:

 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(); 

Toute idée pourquoi il ne fonctionne pas.

Remarque: Il peut y avoir des parenthèses fermées, car ce n'est pas le script complet et j'ai juste copié un morceau.

Répondre

0

L'application Console n'était pas exécutée sous des privilèges d'administrateur. Ainsi, je ne pouvais pas écrire dans XDK qui était en cours d'administration.

Cela a été résolu en ajoutant un App.manifest