Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
This script will add the window below the mouse cursor to the ignored app list, using the EXE name. This is a risky script because if something is not right, it could lead to S+ crashing since the UI checks things and ensures the object has all of the correct properties, etc. But I have tested this and it works fine as it is. Also, you should only execute this while the Settings window is not open, or the ignored app could be removed when you click Apply or OK since the Settings windows copies the config at the time it is opened. Code:var fileName = clr.System.IO.Path.GetFileName(sp.WindowFromPoint(sp.GetCurrentMousePoint(), false).Process.MainModule.FileName);
var title = sp.ForegroundWindow().Title;
//If no title, use exe name
if (!title) title = fileName;
//Add a number to the end of the title if there's an existing ignored item with same name
var i = 1;
var newTitle = title;
while(sp_config.IgnoredApplications.Where(a => a.Description == newTitle).Count() > 0) {
newTitle = title + ' ' + i;
i++;
}
//Create new ignored app and assign base properties
var ignoredApp = new IgnoredApplication();
ignoredApp.Description = newTitle;
ignoredApp.Active = true;
var oClsNameMC = new MatchCriteria();
oClsNameMC.Value = "";
ignoredApp.OwnerClassName = oClsNameMC;
var rClsNameMC = new MatchCriteria();
rClsNameMC.Value = "";
ignoredApp.RootClassName= rClsNameMC;
var pClsNameMC = new MatchCriteria();
pClsNameMC.Value = "";
ignoredApp.ParentClassName = pClsNameMC;
var cClsNameMC = new MatchCriteria();
cClsNameMC.Value = "";
ignoredApp.ControlClassName = cClsNameMC;
var oTextMC = new MatchCriteria();
oTextMC.Value = "";
ignoredApp.OwnerWindowText = oTextMC;
var rTextMC = new MatchCriteria();
rTextMC.Value = "";
ignoredApp.RootWindowText = rTextMC;
var pTextMC = new MatchCriteria();
pTextMC.Value = "";
ignoredApp.ParentWindowText = pTextMC;
var cTextMC = new MatchCriteria();
cTextMC.Value = "";
ignoredApp.ControlWindowText = cTextMC;
var fPathMC = new MatchCriteria();
fPathMC.Value = "";
ignoredApp.FilePath = fPathMC;
//Set the file name as the qualifier
var fNameMC = new MatchCriteria();
fNameMC.Value = fileName;
ignoredApp.FileName = fNameMC;
//Add the ignored app to the list and save
sp_config.IgnoredApplications.Add(ignoredApp);
sp_config.Save();
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Also, the MatchCriteria class only has two properties: Value IsRegex IsRegex is a boolean, true means the Value contains a Regular Expression, false means it's an exact match. Edited by user Saturday, August 17, 2019 9:09:49 PM(UTC)
| Reason: Not specified
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close