Example #1
0
        private IntPtr clipboardViewerNext;     // store next clipboard viewer

        public GlobalEventHook(MainWindow mainWindow) : base()
        {
            // store and hook onto MainWindow instance
            this.mainWindow = mainWindow;
            this.mainWindow.HandleCreated += (sender, e) =>
            {
                base.AssignHandle(mainWindow.Handle);
            };
            this.mainWindow.HandleDestroyed += (sender, e) =>
            {
                base.ReleaseHandle();
            };

            // store next clipboard viewer after establishing this
            this.clipboardViewerNext = GlobalEventHook.SetClipboardViewer(this.mainWindow.Handle);

            // fsModifiers: ALT = 1, CTRL = 2; 1 + 2 = 3
            GlobalEventHook.RegisterHotKey(this.mainWindow.Handle, DISP_ID, 3, (int)Keys.V);
        }
Example #2
0
        private const string SEARCH_DEFAULT = "Search for an item..."; // store searchTextBox's default text

        public MainWindow()
        {
            // required method for Designer support
            this.InitializeComponent();

            // hand this instance to the static classes that utilize MainWindow
            MsgLabel.MainWindow       = this;
            Config.MainWindow         = this;
            LocalClipboard.MainWindow = this;

            // read from CONFIG file and update items accordingly
            Config.FromFile();

            // read from CLIPBOARD file and write to local clipboard
            LocalClipboard.FromFile();

            // init WndProc event hook
            _ = new GlobalEventHook(this);

            wnd = new PopupWindow();
        }