public bool Gestured(PointInfo actionPoint)
        {
            Stopwatch sw = Stopwatch.StartNew();

            do
            {
                if (_settings.IsRegEx)
                {
                    CallBackEnumWindowsProc ewp = EnumWindowsProc;
                    EnumWindows(ewp, 0);
                    if (_isFound) return true;
                }
                else
                {
                    string className = String.IsNullOrWhiteSpace(_settings.ClassName) ? null : _settings.ClassName;
                    string caption = String.IsNullOrWhiteSpace(_settings.Caption) ? null : _settings.Caption;
                    IntPtr hWnd = FindWindow(className, caption);
                    if (hWnd != IntPtr.Zero)
                    {
                        SystemWindow.ForegroundWindow = new SystemWindow(hWnd);
                        sw.Stop();
                        return true;
                    }
                }
                Thread.Sleep(10);
            } while (sw.ElapsedMilliseconds < _settings.Timeout);
            sw.Stop();
            return false;
        }
        public bool Gestured(PointInfo ActionPoint)
        {
            Thread newThread = new Thread(new ParameterizedThreadStart(ExecuteCommand));
            newThread.Start(_Settings);

            return true;
        }
 public bool Gestured(PointInfo ActionPoint)
 {
     try
     {
         SystemWindow.ForegroundWindow = SystemWindow.AllToplevelWindows.Where
                                         (w => w.Visible &&	// Must be a visible windows
                                             //w.WindowState != FormWindowState.Minimized &&
                                          w.Title != "" &&	// Must have a window title
                                             //(w.Style & WindowStyleFlags.POPUPWINDOW)
                                             //	!= WindowStyleFlags.POPUPWINDOW &&
                                         (w.ExtendedStyle & WindowExStyleFlags.TOOLWINDOW)
                                             != WindowExStyleFlags.TOOLWINDOW	// Must not be a tool window
                                         ).Last();
     }
     catch (InvalidOperationException)
     {
         // Do nothing here, no other window open..
     }
     catch (Exception)
     {
         //MessageBox.Show("Oops! - "+ex.Message);
     }
     finally { }
     return true;
 }
Exemple #4
0
        public bool Gestured(PointInfo actionPoint)
        {
            if (AppInfo.Key == null) return false;
            ApplicationActivationManager appActiveManager = new ApplicationActivationManager();
            try
            {
                uint pid;
                appActiveManager.ActivateApplication(AppInfo.Key, null, ActivateOptions.None, out pid);
            }
            catch
            {
                // ignored
            }
            //IShellItemArray array = GetShellItemArray(@"C:\temp\somefile.xyz");
            //appActiveManager.ActivateForFile("2c123c17-8b21-4eb8-8b7f-fdc35c8b7718_n2533ggrncqjt!App", array, "Open",
            //    out pid);


            //Process explorer = new Process();
            //explorer.StartInfo.FileName = "explorer.exe";
            //explorer.StartInfo.Arguments = @"shell:AppsFolder\" + AppInfo.Key;
            //explorer.Start();

            return true;
        }
        public bool Gestured(PointInfo actionPoint)
        {
            if (actionPoint.WindowHandle.ToInt64() != ManagedWinapi.Windows.SystemWindow.ForegroundWindow.HWnd.ToInt64())
                ManagedWinapi.Windows.SystemWindow.ForegroundWindow = actionPoint.Window;

            actionPoint.Window.TopMost = !actionPoint.Window.TopMost;

            return true;
        }
        public bool Gestured(PointInfo ActionPoint)
        {
            // Extract default browser path from registery
            string defaultBrowserPath = GetDefaultBrowserPath();

            // If path is incorrect or empty and exception will be thrown, catch it and return false
            try { Process.Start(defaultBrowserPath); }
            catch { return false; }

            return true;
        }
Exemple #7
0
 public bool Gestured(PointInfo ActionPoint)
 {
     try
     {
         System.Threading.Thread.Sleep(_timeout);
         return true;
     }
     catch
     {
         return false;
     }
 }
        public bool Gestured(PointInfo actionPoint)
        {
            if (_settings == null)
                return false;

            InputSimulator simulator = new InputSimulator();
            try
            {
                var referencePoint = GetReferencePoint(_settings.ClickPosition, actionPoint);
                switch (_settings.MouseAction)
                {
                    case MouseActions.HorizontalScroll:
                        simulator.Mouse.HorizontalScroll(_settings.ScrollAmount);
                        return true;
                    case MouseActions.VerticalScroll:
                        simulator.Mouse.VerticalScroll(_settings.ScrollAmount);
                        return true;
                    case MouseActions.MoveMouseTo:
                        MoveMouse(simulator, _settings.MovePoint);
                        return true;
                    case MouseActions.MoveMouseBy:
                        referencePoint.Offset(_settings.MovePoint);
                        MoveMouse(simulator, referencePoint);
                        break;
                    default:
                        {
                            MoveMouse(simulator, referencePoint);

                            MethodInfo clickMethod = typeof(IMouseSimulator).GetMethod(_settings.MouseAction.ToString());
                            clickMethod.Invoke(simulator.Mouse, null);
                            break;
                        }
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
 public bool Gestured(PointInfo ActionPoint)
 {
     if (_settings.IsSpecificWindow)
     {
         if (_settings.IsRegEx)
         {
             CallBackEnumWindowsProc ewp = EnumWindowsProc;
             EnumWindows(ewp, 0);
             return _isFound;
         }
         string className = String.IsNullOrWhiteSpace(_settings.ClassName) ? null : _settings.ClassName;
         string title = String.IsNullOrWhiteSpace(_settings.Title) ? null : _settings.Title;
         IntPtr hWnd = FindWindow(className, title);
         if (hWnd != IntPtr.Zero)
         {
             Send(hWnd);
             return true;
         }
     }
     else Send(ActionPoint.WindowHandle);
     return false;
 }
 public bool Gestured(PointInfo ActionPoint)
 {
     try
     {
         if (ActionPoint.WindowHandle.ToInt64() !=
             ManagedWinapi.Windows.SystemWindow.ForegroundWindow.HWnd.ToInt64())
             ManagedWinapi.Windows.SystemWindow.ForegroundWindow = ActionPoint.Window;
         if (_useSendInput)
         {
             InputSimulator simulator = new InputSimulator();
             simulator.Keyboard.TextEntry(_keystrokes);
         }
         else
         {
             System.Windows.Forms.SendKeys.SendWait(_keystrokes);
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #11
0
        public void ExecuteAction(List <IAction> executableActions, CaptureMode mode, Devices devices, List <int> contactIdentifiers, List <Point> firstCapturedPoints, List <List <Point> > points)
        {
            // Exit if we're teaching
            if (mode == CaptureMode.Training)
            {
                return;
            }
            var pointInfo = new PointInfo(firstCapturedPoints, points, _mainContext);
            var action    = new Action <object>(o =>
            {
                foreach (IAction executableAction in executableActions)
                {
                    // Exit if there is no action configured
                    if ((executableAction.IgnoredDevices & devices) != 0 || executableAction?.Commands == null || !Compute(executableAction.Condition, points, contactIdentifiers))
                    {
                        continue;
                    }

                    var commandList = executableAction.Commands.Where(command => command != null && command.IsEnabled).ToList();
                    foreach (var command in commandList)
                    {
                        if (mode == CaptureMode.UserDisabled && !"GestureSign.CorePlugins.ToggleDisableGestures".Equals(command.PluginClass))
                        {
                            continue;
                        }

                        pointInfo.Window.WaitForIdle(200);

                        // Locate the plugin associated with this action
                        IPluginInfo pluginInfo = FindPluginByClassAndFilename(command.PluginClass, command.PluginFilename);

                        // Exit if there is no plugin available for action
                        if (pluginInfo == null)
                        {
                            continue;
                        }

                        if (commandList.IndexOf(command) == 0)
                        {
                            if (executableAction.ActivateWindow == null && pluginInfo.Plugin.ActivateWindowDefault ||
                                executableAction.ActivateWindow.HasValue && executableAction.ActivateWindow.Value)
                            {
                                if (pointInfo.Window?.HWnd.ToInt64() != SystemWindow.ForegroundWindow?.HWnd.ToInt64())
                                {
                                    SystemWindow.ForegroundWindow = pointInfo.Window;
                                }
                            }
                        }

                        // Load action settings into plugin
                        pluginInfo.Plugin.Deserialize(command.CommandSettings);
                        // Execute plugin process
                        pluginInfo.Plugin.Gestured(pointInfo);
                    }
                }
            });

            var observeExceptions = new Action <Task>(t =>
            {
                Logging.LogException(t.Exception.InnerException);
            });

            if (_lastActionTask == null)
            {
                _lastActionTask = Task.Factory.StartNew(action, null);
                _lastActionTask.ContinueWith(observeExceptions, TaskContinuationOptions.OnlyOnFaulted);
            }
            else
            {
                _lastActionTask = _lastActionTask.ContinueWith(action);
                _lastActionTask.ContinueWith(observeExceptions, TaskContinuationOptions.OnlyOnFaulted);
            }
        }
 public bool Gestured(PointInfo ActionPoint)
 {
     return AdjustBrightness(_Settings);
 }
 public bool Gestured(PointInfo ActionPoint)
 {
     _HostControl.TrayManager.ToggleDisableGestures();
     return true;
 }
        public bool Gestured(PointInfo ActionPoint)
        {
            if (_showKeyboard.HasValue)
            {
                return _showKeyboard.Value ? ShowKeyboard() : HideKeyboard();
            }
            else
            {
                var keyboardHwnd = FindWindow("IPTip_Main_Window", null);
                if (keyboardHwnd == IntPtr.Zero) return false;

                var taptipWindow = new SystemWindow(keyboardHwnd);
                return taptipWindow.Visible && taptipWindow.Enabled ? HideKeyboard() : ShowKeyboard();
            }
        }
        public bool Gestured(PointInfo ActionPoint)
        {
            if (_settings == null) return false;

            InputSimulator simulator = new InputSimulator();

            if (_settings.KeyCode != null)
                foreach (var k in _settings.KeyCode)
                {
                    if (!Enum.IsDefined(typeof(VirtualKeyCode), k.GetHashCode())) continue;

                    var key = (VirtualKeyCode)k;
                    if (_settings.IsKeyDown)
                        simulator.Keyboard.KeyDown(key);
                    else simulator.Keyboard.KeyUp(key);
                }

            return true;
        }
 private Point GetReferencePoint(ClickPositions position, PointInfo actionPoint)
 {
     Point referencePoint;
     switch (position)
     {
         case ClickPositions.LastUp:
             referencePoint = actionPoint.Points.Last().Last();
             break;
         case ClickPositions.LastDown:
             referencePoint = actionPoint.Points.Last().First();
             break;
         case ClickPositions.FirstUp:
             referencePoint = actionPoint.Points.First().Last();
             break;
         case ClickPositions.FirstDown:
             referencePoint = actionPoint.Points.First().First();
             break;
         default:
             referencePoint = Point.Empty;
             break;
     }
     return referencePoint;
 }
Exemple #17
0
 public bool Gestured(PointInfo ActionPoint)
 {
     return true;
 }
 public bool Gestured(PointInfo ActionPoint)
 {
     _HostControl.TouchCapture.TemporarilyDisableCapture = true;
     _HostControl.TrayManager.ToggleDisableGestures();
     return true;
 }
 public bool Gestured(PointInfo ActionPoint)
 {
     if (ActionPoint.WindowHandle.ToInt64() != SystemWindow.ForegroundWindow.HWnd.ToInt64() &&
         ActionPoint.Window != null)
         SystemWindow.ForegroundWindow = ActionPoint.Window;
     try
     {
         SendShortcutKeys(_Settings);
     }
     catch (Exception exception)
     {
         throw new UnauthorizedAccessException(LocalizationProvider.Instance.GetTextValue("CorePlugins.HotKey.UnauthorizedAccessException"), exception);
     }
     return true;
 }