Beispiel #1
0
        private void follower_Tick(object sender, EventArgs e)
        {
            txtDebug.Text = WindowMonitor.ForegroundProcessName + " " + _followTarget;
            if (WindowMonitor.IsForeground(_followTarget))
            {
                if (!this.TopMost)
                {
                    this.TopMost = true;
                }
                _fgRect          = WindowMonitor.GetForegroundRect();
                _newDesktopLoc.X = _fgRect.X + settings._opOsdPoint.X;
                _newDesktopLoc.Y = _fgRect.Y + settings._opOsdPoint.Y;

                if (_newDesktopLoc != this.DesktopLocation)
                {
                    this.SetDesktopLocation(_newDesktopLoc.X, _newDesktopLoc.Y);
                }
            }
            else
            {
                if (this.TopMost)
                {
                    this.TopMost = false;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Make sure your foreground window checker is running.
        /// </summary>
        public bool CanTrigger(bool isMouseButtonDown, int x, int y, MouseButtons button, ModifierKey modifiers)
        {
            //button/modifier check

            /* System.Diagnostics.Debug.WriteLine(this.triggeredBy.ToString () + ": "+isMouseButtonDown.ToString()+", " +
             *   "Source - " + button.ToString() + " Dest - " +( (MouseButtons)vk).ToString()
             *   );*/
            if (this.vk == (int)button && this.modifiers == modifiers)
            {
                //foreground name check
                // System.Diagnostics.Debug.WriteLine(WindowMonitor.ForegroundProcessName);
                if (processName.Contains(WindowMonitor.ForegroundProcessName))
                {
                    //foreground rect check
                    Point fgLoc = WindowMonitor.GetWindowLocation();
                    x -= fgLoc.X; y -= fgLoc.Y;
                }
                else if (processName.Any())
                {
                    return(false);
                }
                //so we just checked the name. the name was non null. this means it wasnt the universal identifier, so we return false.

                /* System.Diagnostics.Debug.WriteLine(
                 * "Point: " + x + " " + y + " -- " + winRect.ToString()
                 *
                 * );*/

                if (winRect != Rectangle.Empty && !winRect.Contains(x, y))
                {
                    return(false);
                }
                //mouse check heh Aids Enjoi!

                if (isMouseButtonDown)
                {
                    return(this.triggeredBy == TriggerType.MouseDown);
                }
                else
                {
                    return(this.triggeredBy == TriggerType.MouseUp);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        public DialogResult ShowDialog(IEnumerable <string> procName, Rectangle?target)
        {
            if (procName != null)
            {
                BaseLocation = WindowMonitor.GetWindowLocation(procName.ToArray()).GetValueOrDefault(Point.Empty);
            }
            else
            {
                BaseLocation = Point.Empty;
            }
            tmpRect = target;
            var result = ShowDialog();


            return(result);
        }
Beispiel #4
0
        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (hooked)
            {
                t.Abort();
                Hooker.UnhookKeyboard();
                Hooker.UnhookMouse();
                //pressDelay.Close();//DEBUG
                //nextKeyDelay.Close();
                hooked = false;

                WindowMonitor.StopMonitorForeground();

                InputEventDispatcher.DisposeIt();
                Application.Exit();
            }
        }
Beispiel #5
0
 private void frmOSD_MouseUp(object sender, MouseEventArgs e)
 {
     if (_locked)
     {
         return;
     }
     if (e.Button == MouseButtons.Left)
     {
         mouseDown = false;
         Point?_targetPos = WindowMonitor.GetWindowLocation(_followTarget);
         if (_targetPos.HasValue)
         {
             settings._opOsdPoint = new Point(
                 this.DesktopLocation.X - _targetPos.Value.X,
                 this.DesktopLocation.Y - _targetPos.Value.Y);
         }
     }
 }
Beispiel #6
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            LoadAllSettings(); //settings only.

            validCondition = (newName) => { return(!_macroPages.Any((page) => page.name.Equals(newName))); };

            _macroPages = new List <MacroPage>();
            _macroPages.Add(new MacroPage("Default", new List <Macro>()));

            LoadMacros();
            CompileAll();
            DisplayCurrentMacroPage();

            UpdateOSD(_macroPages[0].name, 0);
            if (settings._opOSDEnable)
            {
                ShowOSD();
            }


            _frmOsd.FollowTarget = settings._opOSDTarget;
            SetOSDLocked(settings._opOSDLock);

            WindowMonitor.BeginMonitorForeground();

            //trayIcon.ShowBalloonTip(3000, "KeyReplace", "KeyReplace is now running.", ToolTipIcon.Info);

            t = new Thread((ThreadStart) delegate
            {
                Hooker.s_KeyDown += _keyDown;
                Hooker.s_KeyUp   += _keyUp;
                Hooker.HookKeyboard();
                Application.Run();
            }); //we run the keyboard thread on a seperate thread with a message loop
                // courtesy: https://stackoverflow.com/questions/25502960/install-low-level-mouse-hook-in-different-thread


            t.Start();

            Hooker.s_MouseDown += _mouseDown;
            Hooker.s_MouseUp   += _mouseUp;
            Hooker.HookMouse();
            hooked = true;
        }