Ejemplo n.º 1
0
        public SettingsFormController(IConfig config, GestureParser parser,
                                      Win32MousePathTracker2 pathTracker, JsonGestureIntentStore intentStore,
                                      CanvasWindowGestureView gestureView, GlobalHotKeyManager hotkeyMgr)
        {
            _config      = config;
            _parser      = parser;
            _pathTracker = pathTracker;
            _intentStore = intentStore;
            _gestureView = gestureView;
            _hotkeyMgr   = hotkeyMgr;

            #region 初始化支持的命令和命令视图
            //Add Command Types
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(DoNothingCommand)), typeof(DoNothingCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(HotKeyCommand)), typeof(HotKeyCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WebSearchCommand)), typeof(WebSearchCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WindowControlCommand)), typeof(WindowControlCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(TaskSwitcherCommand)), typeof(TaskSwitcherCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(OpenFileCommand)), typeof(OpenFileCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(SendTextCommand)), typeof(SendTextCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(GotoUrlCommand)), typeof(GotoUrlCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(CmdCommand)), typeof(CmdCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(ScriptCommand)), typeof(ScriptCommand));

            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(PauseWGesturesCommand)), typeof(PauseWGesturesCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(ChangeAudioVolumeCommand)), typeof(ChangeAudioVolumeCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(AddToBacklistCommand)), typeof(AddToBacklistCommand));

            CommandViewFactory.Register <AddToBacklistCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <OpenFileCommand, OpenFileCommandView>();
            CommandViewFactory.Register <DoNothingCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <HotKeyCommand, HotKeyCommandView>();
            CommandViewFactory.Register <GotoUrlCommand, GotoUrlCommandView>();
            CommandViewFactory.Register <PauseWGesturesCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <WebSearchCommand, WebSearchCommandView>();
            CommandViewFactory.Register <WindowControlCommand, WindowControlCommandView>();
            CommandViewFactory.Register <CmdCommand, CmdCommandView>();
            CommandViewFactory.Register <SendTextCommand, SendTextCommandView>();
            CommandViewFactory.Register <TaskSwitcherCommand, TaskSwitcherCommandView>();
            CommandViewFactory.Register <ScriptCommand, ScriptCommandView>();
            CommandViewFactory.Register <ChangeAudioVolumeCommand, GeneralNoParameterCommandView>();
            #endregion

            #region Hotcorner
            SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(DoNothingCommand)), typeof(DoNothingCommand));
            SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(HotKeyCommand)), typeof(HotKeyCommand));
            SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(CmdCommand)), typeof(CmdCommand));

            HotCornerCommandViewFactory.Register <DoNothingCommand, GeneralNoParameterCommandView>();
            HotCornerCommandViewFactory.Register <HotKeyCommand, HotKeyCommandView>();
            HotCornerCommandViewFactory.Register <CmdCommand, CmdCommandView>();
            #endregion

            _form = new SettingsForm(this);
        }
Ejemplo n.º 2
0
        static bool HotkeyMgr_HotKeyPreview(GlobalHotKeyManager mgr, string id, GlobalHotKeyManager.HotKey hk)
        {
            if (id == ConfigKeys.PauseResumeHotKey)
            {
                Debug.WriteLine("HotKey Pressed: " + hk);
                TogglePause();
                //menuItem_pause.Text = string.Format("{0} ({1})", gestureParser.IsPaused ? "继续" : "暂停" ,hk.ToString());

                return(true); //Handled
            }

            return(false);
        }
Ejemplo n.º 3
0
        static void AppWideInit()
        {
            Application.EnableVisualStyles();
            Native.SetProcessDPIAware();

            Thread.CurrentThread.IsBackground = false;
            Thread.CurrentThread.Name         = "入口线程";

            using (var proc = Process.GetCurrentProcess())
            {
                //高优先级
                proc.PriorityClass = ProcessPriorityClass.High;
            }

            hotkeyMgr = new GlobalHotKeyManager();
        }
        private void OnHotKeyChanged(object sender, EventArgs e)
        {
            HotKey hotKey = (sender as HotKeyMimicTextBox).HotKey;

            Runtime.Instance.Settings.HotKeys[hotKey.Function] = hotKey;
            if (this.flagHotKeysAsChanged)
            {
                return;
            }

            this.flagHotKeysAsChanged    = true;
            this.ParentForm.FormClosing += (s, e1) =>
            {
                GlobalHotKeyManager.UnregisterAll();
                GlobalHotKeyManager.RegisterAll();
            };
        }
Ejemplo n.º 5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // This is pretty much the simplest possible example of how to install a HotKey and do something.
            // It is not an AutoZilla plugin, it is just a self contained program.
            // Form1 has had no modifications, so it is visible which is not what you want in most cases.

            // n.b. You should create a Windows Forms application, not a console application, because the
            // hot key hooking will not work with console apps (they don't have a message loop).

            // n.b. This simple demo will throw an exception if some other application has registered CA-L as
            // a HotKey.
            using (GlobalHotKeyManager HotKeyManager = new GlobalHotKeyManager())
            {
                HotKeyManager.Register(Modifiers.Ctrl | Modifiers.Alt, Keys.L, MyCallback);

                Application.Run(new Form1());

                // Try this if you want a no-GUI program.
                //Application.Run(new InvisibleForm());
            }
        }
Ejemplo n.º 6
0
 public PluginManager()
 {
     HotKeyManager = new GlobalHotKeyManager();
 }
Ejemplo n.º 7
0
 internal AutoTemplateManager()
 {
     HotKeyManager      = new GlobalHotKeyManager();
     ActiveTemplates    = new List <TextTemplate>();
     AutoTemplateFolder = Path.Combine(AutoZillaVariables.ExeFolder, "AutoTemplates");
 }