Exemplo n.º 1
0
 internal WindowTrigger(ActionTriggers triggers, Action <WindowTriggerArgs> action, TWEvent ev, AWnd.Finder finder, TWFlags flags, TWLater later) : base(triggers, action, false)
 {
     this.ev     = ev;
     this.finder = finder;
     this.flags  = flags;
     this.later  = later;
 }
Exemplo n.º 2
0
 TriggerScope _Add(bool not, AWnd.Finder f)
 {
     if (f == null)
     {
         throw new ArgumentNullException();
     }
     Used = true;
     return(Current = new TriggerScope(f, not));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a window trigger and its action.
        /// </summary>
        /// <exception cref="InvalidOperationException">Cannot add triggers after <c>Triggers.Run</c> was called, until it returns.</exception>
        public Action <WindowTriggerArgs> this[TWEvent winEvent, AWnd.Finder f, TWFlags flags = 0, TWLater later = 0] {
            set {
                _triggers.ThrowIfRunning_();
                if (f.Props.contains.Value is AWinImage.Finder)
                {
                    AWarning.Write("Window triggers with 'contains image' are unreliable.");
                }

                var     t    = new WindowTrigger(_triggers, value, winEvent, f, flags, later);
                ref var last = ref _tActive; if (t.IsVisible)
Exemplo n.º 4
0
 /// <summary>
 /// Adds a window trigger and its action.
 /// </summary>
 /// <param name="winEvent">Trigger event.</param>
 /// <param name="name">See <see cref="AWnd.Find"/>.</param>
 /// <param name="cn">See <see cref="AWnd.Find"/>.</param>
 /// <param name="of">See <see cref="AWnd.Find"/>.</param>
 /// <param name="also">See <see cref="AWnd.Find"/>.</param>
 /// <param name="contains">See <see cref="AWnd.Find"/>.</param>
 /// <param name="flags">Trigger flags.</param>
 /// <param name="later">
 /// Can optionally specify one or more additional events.
 /// This starts to work when the primary trigger is activated, and works only for that window.
 /// For example, to be notified when the window is closed or renamed, specify <c>later: TWLater.Destroyed | TWLater.Name</c>.
 /// When a "later" event occurs, the trigger action is executed. The <see cref="WindowTriggerArgs.Later"/> property then is that event; it is 0 when it is the primary trigger.
 /// The "later" trigers are not disabled when primary triggers are disabled.
 /// </param>
 /// <exception cref="InvalidOperationException">Cannot add triggers after <c>Triggers.Run</c> was called, until it returns.</exception>
 /// <exception cref="ArgumentException">See <see cref="AWnd.Find"/>.</exception>
 /// <seealso cref="Last"/>
 public Action <WindowTriggerArgs> this[TWEvent winEvent,
                                        [ParamString(PSFormat.AWildex)] string name = null,
                                        [ParamString(PSFormat.AWildex)] string cn = null,
                                        [ParamString(PSFormat.AWildex)] WOwner of = default,
                                        Func <AWnd, bool> also = null, WContains contains = default,
                                        TWFlags flags = 0, TWLater later = 0
 ] {
     set {
         var f = new AWnd.Finder(name, cn, of, 0, also, contains);
         this[winEvent, f, flags, later] = value;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sets scope "not this window". Hotkey, autotext and mouse triggers added afterwards will not work when the specified window is active.
 /// </summary>
 /// <returns>Returns an object that can be later passed to <see cref="Again"/> to reuse this scope.</returns>
 public TriggerScope NotWindow(AWnd.Finder f)
 => _Add(true, f);
Exemplo n.º 6
0
 /// <summary>
 /// Sets scope "only this window". Hotkey, autotext and mouse triggers added afterwards will work only when the specified window is active.
 /// </summary>
 /// <returns>Returns an object that can be later passed to <see cref="Again"/> to reuse this scope.</returns>
 public TriggerScope Window(AWnd.Finder f)
 => _Add(false, f);