public ProcessWatcher(string ConfigPath) { this.ConfigPath = ConfigPath; this.firstLevelProcessHashes = new IndexedList(); this.secondLevelProcessHashes = ConfigLoader.LoadSecondHashConfig(ConfigPath); this.processExeNames = new Dictionary <string, App>(); StartWatch = new ManagementEventWatcher(new WqlEventQuery("SELECT * FROM Win32_ProcessStartTrace")); StartWatch.EventArrived += new EventArrivedEventHandler(startWatch_ProcessCreated); StartWatch.Start(); }
public WIN() { InitializeComponent(); ConfigPath = $"{PropsPath}\\SmartWIN"; this.lastStartedApps = ConfigLoader.LoadHistoryConfig(ConfigPath); this.Width = SystemInformation.PrimaryMonitorSize.Width; this.MaximumSize = this.MinimumSize = new Size(this.Width, 22); this.BackColor = Theme.FormBackColor; this.Shown += delegate { this.Hide(); Process shellStart = new Process(); shellStart.StartInfo.FileName = "explorer"; shellStart.Start(); WINFix.HideWinBtn(); }; //Spawn controls searchBox.Location = new Point(50, 1); searchBox.Font = Theme.TextFont; searchBox.ForeColor = Theme.TextColor; searchBox.BackColor = Theme.BackColor; for (int posX = 280; posX + 202 < this.Width - 30; posX += tileWidth) { Label temp = new Label(); temp.Location = new Point(posX, 0); temp.Size = new Size(tileWidth, 25); temp.TextAlign = ContentAlignment.MiddleCenter; temp.Font = Theme.TextFont; temp.BackColor = Theme.BackColor; temp.ForeColor = Theme.TextColor; this.Controls.Add(temp); dataControls.Add(temp); } ControlsCount = dataControls.Count; //Start KeyHook keyHook = new KeyHook(this); keyHook.LeftArrowEvent += LeftArrClick; keyHook.RightArrowEvent += RightArrClick; keyHook.EnterClickEvent += EnterClick; keyHook.OpenCloseEvent += ShowHideEvent; keyHook.KeyClickEvent += KeyClick; keyHook.ShutdownClickEvent += ShutdownClick; //TODO: Finder by standard folders finders = new IFinder[] { new StartMenuHandler(ConfigPath, StartMenuPathes) }; }
public StartMenuHandler(string ConfigPath, string[] StartMenuPathes) : base(ConfigPath) { IndexedList firstSaved = ConfigLoader.LoadFirstHashConfig(ConfigPath); //Scan Menu Folder foreach (string menu_path in StartMenuPathes) { foreach (string symlink_path in Directory.GetFiles(menu_path, "*.lnk", SearchOption.AllDirectories)) { string name = Path.GetFileNameWithoutExtension(symlink_path).ToLower(); var link = Symlink.GetRealPath(symlink_path); if (Path.GetExtension(link.TargetPath) != ".exe") { continue; } App output = firstSaved.TryToGetApp(name); if (output != null) { firstLevelProcessHashes.TryToAdd(name, link.TargetPath, output.lastStart, ref output, link.Arguments); } else { firstLevelProcessHashes.TryToAdd(name, link.TargetPath, ref output, link.Arguments); } if (!processExeNames.ContainsKey(link.TargetPath)) { processExeNames.Add(link.TargetPath, output); } } } //Start watching StartUp folder foreach (string menu_path in StartMenuPathes) { FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = menu_path; watcher.IncludeSubdirectories = true; watcher.Filter = "*.lnk"; watcher.Created += new FileSystemEventHandler(OnCreated); watcher.Deleted += new FileSystemEventHandler(OnDeleted); watcher.Renamed += new RenamedEventHandler(OnRenamed); watcher.EnableRaisingEvents = true; watchers.Add(watcher); } }
private void ShutdownClick() { data = new List <App>() { new App("shutdown", "hibernation", "/h /t 0", DateTime.Now), new App("shutdown", "reboot", "/r /t 0", DateTime.Now), new App("shutdown", "shutdown", "/s /t 0", DateTime.Now) }; DrawApps(); if (!this.Visible) { this.Show(); } ConfigLoader.SaveLastStartedConfig(ConfigPath, lastStartedApps); foreach (IFinder finder in finders) { finder.Save(); } }
public void Save() { ConfigLoader.SaveFirstHashConfig(ConfigPath, firstLevelProcessHashes); ConfigLoader.SaveSecondHashConfig(ConfigPath, secondLevelProcessHashes); }