protected SettingsSingleton()
 {
     loadCommands();
     keyboardHook = new Hook("Global Action Hook");
     loadSettings();
     saveSettings();
 }
Esempio n. 2
0
        public KeyEventHandler(Action p_fireOnMatch)
        {
            _fireOnKeyMatch = p_fireOnMatch;

            _keyboardHook = new Hook("Global Action Hook");
            _keyboardHook.KeyDownEvent -= KeyDown;
            _keyboardHook.KeyDownEvent += KeyDown;
        }
Esempio n. 3
0
        private void InitLogic()
        {
            LgPersistor.Init();
            LgPersistor.GetAllConfigs().ForEach((c) => configs.Add(c));
            listBox.ItemsSource = configs;

            KeyboardHook = new Hook("Global Action Hook");
            KeyboardHook.KeyUpEvent = ShortCutHandler;
        }
Esempio n. 4
0
        private static void Main()
        {
            Trace.Listeners.Add(new ReportListener());

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;

            //todo: It's reccomended that this be set in the manifest, but I can't figure out how to do that successfully with clickonce
            Windowing.SetProcessDPIAware();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.Name = "Main UI " + Thread.CurrentThread.ManagedThreadId;
            Update.CheckForUpdate();

            History = new List<ExtendedScreenshot>();

            Preview = new PeekPreview();
            Trace.WriteLine("Forcing the creation of PeekPreview by accessing its handle on the Main UI thread: " + Preview.Handle, string.Format("Program [{0}]", Thread.CurrentThread.Name));

            KeyboardHook = new Hook("Global Action Hook");
            KeyboardHook.KeyDownEvent += KeyDown;
            KeyboardHook.KeyUpEvent += KeyUp;

            TrayIcon = new NotifyIcon()
            {
                Icon = ProSnap.Properties.Resources.camera_16x16_icon,
                Text = "ProSnap",
                Visible = true,
                ContextMenuStrip = new ContextMenuStrip()
            };

            //TrayIcon.ContextMenuStrip.Items.Add("Take Screenshot", null, new EventHandler((o, e) => { Thread.Sleep(3000); SpawnActionChain(ActiveShortcutProfile.Shortcuts.FirstOrDefault(s => s.Actions.ActionItems.FirstOrDefault().ActionType == ActionTypes.TakeForegroundScreenshot)); }));

            TrayIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("History", null, (o, e) => (o as ToolStripMenuItem).ShowDropDown()) { Name = "tsmiHistory" });
            TrayIcon.ContextMenuStrip.Items.Add("Options", null, (o, e) => Options.Options.ShowOrActivate());
            TrayIcon.ContextMenuStrip.Items.Add("Exit", null, (o, e) =>
                {
                    Application.Exit();
                    DumpTraceReport();
                });

            TrayIcon.MouseDown += TrayIcon_MouseDown;

            ShowPreviewEvent += Program_ShowPreviewEvent;

            IconAnimation.WorkerSupportsCancellation = true;
            IconAnimation.DoWork += IconAnimation_DoWork;

            AppDomain.CurrentDomain.ProcessExit += (o, e) => KeyboardHook.isPaused = true;
            Application.Run();

            TrayIcon.Visible = false;
        }
Esempio n. 5
0
        public formHotkey()
        {
            InitializeComponent();

            txtCombo.Text = ImgyazurIcon.Instance.keyComboSettings.ToKeyCombo().ToString();

            this.ShortcutHook = new Hook("Shortcut Capture Hook");
            this.ShortcutHook.KeyDownEvent += e =>
            {
                if (txtCombo.Focused)
                {
                    CurrentKeyCombo = KeyCombo.FromKeyboardHookEventArgs(e);
                    UpdateShortcutDisplay();
                }
            };
        }
        public ShortcutItemConfiguration()
        {
            InitializeComponent();

            this.MinimumSize = this.Size;

            this.ShortcutHook = new Hook("Shortcut Capture Hook");
            this.ShortcutHook.KeyDownEvent += e =>
                {
                    if (tbShortcut.Focused)
                    {
                        CurrentKeyCombo = KeyCombo.FromKeyboardHookEventArgs(e);
                        UpdateShortcutDisplay();
                    }
                };

            lvActions.Select();
        }
Esempio n. 7
0
        private ImgyazurIcon()
        {
            contextMenuStrip = new ContextMenuStrip();
            contextMenuStrip.SuspendLayout();

            exitMenuItem = new ToolStripMenuItem();
            exitMenuItem.Name = "exitMenuItem";
            exitMenuItem.Text = "Exit";
            exitMenuItem.Click += new EventHandler(exitMenuItem_Click);

            startOnBootMenuItem = new ToolStripMenuItem();
            startOnBootMenuItem.Name = "startOnBootMenuItem";
            startOnBootMenuItem.Text = "Start On Boot";
            startOnBootMenuItem.CheckOnClick = true;
            if (rkApp.GetValue("imgyazur") == null)
                startOnBootMenuItem.Checked = false;
            else
                startOnBootMenuItem.Checked = true;
            startOnBootMenuItem.CheckedChanged += new EventHandler(startOnBootMenuItem_CheckedChanged);

            copyAfterUploadMenuItem = new ToolStripMenuItem();
            copyAfterUploadMenuItem.Name = "copyAfterUploadMenuItem";
            copyAfterUploadMenuItem.Text = "Copy URL After Upload";
            copyAfterUploadMenuItem.CheckOnClick = true;
            copyAfterUploadMenuItem.Checked = Properties.Settings.Default.copyToClipboard;
            copyAfterUploadMenuItem.CheckedChanged += new EventHandler(copyAfterUploadMenuItem_CheckedChanged);

            openAfterUploadMenuItem = new ToolStripMenuItem();
            openAfterUploadMenuItem.Name = "openAfterUploadMenuItem";
            openAfterUploadMenuItem.Text = "Open URL After Upload";
            openAfterUploadMenuItem.CheckOnClick = true;
            openAfterUploadMenuItem.Checked = Properties.Settings.Default.openAfterUpload;
            openAfterUploadMenuItem.CheckedChanged += new EventHandler(openAfterUploadMenuItem_CheckedChanged);

            changeHotkeyMenuItem = new ToolStripMenuItem();
            changeHotkeyMenuItem.Name = "changeHotkeyMenuItem";
            changeHotkeyMenuItem.Text = "Change Hotkey";
            changeHotkeyMenuItem.Click += new EventHandler(changeHotkeyMenuItem_Click);

            contextMenuStrip.Items.AddRange(new ToolStripItem[] { startOnBootMenuItem, copyAfterUploadMenuItem, openAfterUploadMenuItem, changeHotkeyMenuItem, exitMenuItem });
            contextMenuStrip.Name = "contextMenuStrip";

            contextMenuStrip.ResumeLayout(false);

            notifyIcon = new NotifyIcon();
            notifyIcon.BalloonTipText = "imgyazur";
            notifyIcon.Text = defaultText;
            notifyIcon.Visible = true;
            notifyIcon.Icon = Properties.Resources.imgur;
            notifyIcon.ContextMenuStrip = contextMenuStrip;
            notifyIcon.MouseClick += new MouseEventHandler(notifyIcon_MouseClick);
            notifyIcon.ShowBalloonTip(10000, "imgyazur is now running", "Press " + keyComboSettings.ToKeyCombo().ToString() + " or click this icon to start capturing.", ToolTipIcon.Info);

            Hook KeyboardHook = new Hook("imgyazur keyboard hook");
            KeyboardHook.KeyDownEvent += GlobalKeyDown;
        }
Esempio n. 8
0
        internal KeyboardHookEventArgs(Hook.KBDLLHOOKSTRUCT lParam)
        {
            this.Key = KeyInterop.KeyFromVirtualKey((int) lParam.vkCode);

            //Control.ModifierKeys doesn't capture alt/win, and doesn't have r/l granularity
            this.isLAltPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_LALT) & KEY_PRESSED) || this.Key == Key.LeftAlt;
            this.isRAltPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_RALT) & KEY_PRESSED) || this.Key == Key.RightAlt;

            this.isLCtrlPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_LCONTROL) & KEY_PRESSED) || this.Key == Key.LeftCtrl;
            this.isRCtrlPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_RCONTROL) & KEY_PRESSED) || this.Key == Key.RightCtrl;

            this.isLShiftPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_LSHIFT) & KEY_PRESSED) || this.Key == Key.LeftShift;
            this.isRShiftPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_RSHIFT) & KEY_PRESSED) || this.Key == Key.RightShift;

            this.isLWinPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_LWIN) & KEY_PRESSED) || this.Key == Key.LWin;
            this.isRWinPressed = Convert.ToBoolean(GetKeyState(VirtualKeyStates.VK_RWIN) & KEY_PRESSED) || this.Key == Key.RWin;

            if (new[] { Key.LeftAlt, Key.RightAlt, Key.LeftCtrl, Key.RightCtrl, Key.LeftShift, Key.RightShift, Key.LWin, Key.RWin }.Contains(this.Key))
                this.Key = Key.None;
        }
Esempio n. 9
0
 private void InitKeyboardHook()
 {
     KeyboardHook = new Hook("Global Action Hook");
     KeyboardHook.KeyUpEvent = ShortCutHandler;
 }