Method WindowTriggers.SimulateActiveNew
Overload
Simulates event "activated new window" as if the the specified window is that window.
public void SimulateActiveNew(wnd w)
Parameters
w (wnd) |
Exceptions
InvalidOperationException
Cannot be before or after ActionTriggers.Run. |
Remarks
This function usually is used to run ActiveNew triggers for a window created before calling ActionTriggers.Run. Here "run triggers" means "compare window properties etc with those specified in triggers and run actions of triggers that match". Normally such triggers don't run because the window is considered old. This function runs triggers as it was a new window. Triggers like ActiveNew and ActiveOnce will run once, as usually. This function must be called while the main triggers thread is in ActionTriggers.Run, for example from another trigger action. It is asynchronous (does not wait). If you call this function from another trigger action (hotkey etc), make sure the window trigger action runs in another thread or can be queued. Else both actions cannot run simultaneously. See example.
Examples
Note: the Triggers in examples is a field or property like readonly ActionTriggers Triggers = new();
.
Triggers.Options.ThreadNew(true);
Triggers.Window[TWEvent.ActiveNew, "* Notepad"] = o => o.Window.Resize(500, 200);
Triggers.Hotkey["Ctrl+T"] = o => Triggers.Window.SimulateActiveNew(wnd.active);
Triggers.Hotkey["Ctrl+Alt+T"] = o => Triggers.Stop();
Triggers.Run();