| |
[May. 24th, 2007|11:24 pm] |
|
|
|
|
| Comments: |
под виндовозом что-ли программа?
ага, под виндовозом. причём под последним.
покажи исходник, пожалуйста
вся работа выполняется вот этим классом:
using System; using System.IO; using System.Diagnostics; using System.Windows.Automation;
namespace VoiceOperativeMode { public class Supervisor { static desktop: AutomationElement = AutomationElement.RootElement;
//[PermissionSet(SecurityAction.Demand, Name="FullTrust")] public Watch(): void { CreateWatcher("*.tex", FileUpdated); CreateWatcher("*.dvi", FileUpdated); } CreateWatcher(filter: string, handler: FileSystemEventHandler): void { def watcher = FileSystemWatcher(@"D:\Mathematics", filter); watcher.IncludeSubdirectories = true; watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Changed += handler; watcher.EnableRaisingEvents = true; }
FileUpdated(_: object, arguments: FileSystemEventArgs): void { def extension = Path.GetExtension(arguments.FullPath); def handler = match (extension) { | ".tex" => CompileLatex; | ".dvi" => ShowDviInYap; | _ => throw ArgumentException($"Unknown extension: $extension"); } _ = handler(arguments.FullPath); } CompileLatex(path: string): bool { assert(path.EndsWith(".tex")); def info = ProcessStartInfo("latex", path); info.WindowStyle = ProcessWindowStyle.Hidden; info.WorkingDirectory = Path.GetDirectoryName(path); def process = Process.Start(info); _ = process.WaitForExit(2500); def success = process.HasExited; unless(success) { process.Kill(); Speaker.Say("Error"); } success }
ShowDviInYap(path: string): bool { assert(path.EndsWith(".dvi")); // assume this shit is already in yap, just focus it and back def children = desktop.FindAll(TreeScope.Children, Condition.TrueCondition).ToList(); def yaps = children.Filter(child => child.Current.Name.StartsWith("Yap")); def editors = children.Filter(child => child.Current.Name.TrimStart().StartsWith("WinEdt")); Console.WriteLine(editors.Length); Console.WriteLine(editors.Map(e => e.Current.Name)); if (yaps.IsEmpty) false else { yaps.Head.SetFocus(); unless (editors.IsEmpty) editors.Head.SetFocus(); true } } } }
Немерле однако хуяк - отсюда позырь. | |