Beispiel #1
0
        public Main()
        {
            Instance = this;
            trayIcon = new Class.TrayIcon();
            pointTrayIcon = trayIcon.trayIcon;

            Hook = new KeyboardHook();
            ReAttachKeyboardHook();

            if (!File.Exists(Path.GetTempPath() + "/UploadLog.xml"))
            {
                XDocument xmlFile = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
                xmlFile.Add(new XElement("UploadList"));
                xmlFile.Save(Path.GetTempPath() + "/UploadLog.xml");
            }
        }
Beispiel #2
0
        public void ReAttachKeyboardHook()
        {
            try
            {
                Hook.Dispose();
                Hook = new KeyboardHook();

                if (!String.IsNullOrEmpty(settings.KeyDefined))
                {
                    KeyDefined = (Keys)Enum.Parse(typeof(Keys), settings.KeyDefined);
                    ModifierDefined = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), settings.ModifierDefined);
                    Hook.RegisterHotKey(ModifierDefined, KeyDefined);
                }
               
                if (!String.IsNullOrEmpty(settings.KeyFull))
                {
                    KeyFull = (Keys)Enum.Parse(typeof(Keys), settings.KeyFull);
                    ModifierFull = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), settings.ModifierFull);
                    Hook.RegisterHotKey(ModifierFull, KeyFull);
                }

                if (!String.IsNullOrEmpty(settings.KeyActive))
                {
                    KeyActive = (Keys)Enum.Parse(typeof(Keys), settings.KeyActive);
                    ModifierActive = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), settings.ModifierActive);
                    Hook.RegisterHotKey(ModifierActive, KeyActive);
                }

                Hook.KeyPressed += HandleKeyPressed;
            }
            catch (Exception ex)
            {
                trayIcon.ShowError(ex.Message);
            }

        }