static void perform(int action, Keys key) { if (!Working) { return; } if (ExcludedKeys.Contains(key)) { return; } var fore = Win32ApiWrapper.GetForegroundWindow(); if (!MainWindows.Any(w => w.SameOrBelongTo(fore))) { return; } WorkingNotice?.BeginInvoke(fore, null, null); for (var i = AllWindows.Count - 1; i >= 0; i--) { var item = AllWindows[i]; var w = item.Key; if (w.SameOrBelongTo(fore)) { continue; } var r = Win32ApiWrapper.PostMessage(w, action, (int)key, 0); if (r == 0) { AllWindows.Remove(item); WindowLost?.BeginInvoke(w, null, null); } } }
public bool FindStringValueByKeys(List <string> keys, Dictionary <string, dynamic> currentTree) { bool didSomething = false; foreach (var key in keys) { if (ExcludedKeys.Contains(key)) { continue; } var value = currentTree[key]; TypeConverter converter = TypeDescriptor.GetConverter(value); if (converter.CanConvertTo(typeof(IDictionary <string, dynamic>))) { // This looks weird, but to edit the config object we need to not loop thru config itself (this would break the // loop when we edit something). So we keep track with a copy of the keys collection. But we also need to be able // to set value in sub keys. hence we keep track of the current branch of the config tree we are in. var treeToFollow = (Dictionary <string, dynamic>)converter.ConvertTo(currentTree[key], typeof(IDictionary <string, dynamic>)); if (FindStringValueByKeys(treeToFollow.Keys.ToList(), treeToFollow)) { currentTree[key] = treeToFollow; } continue; } if (Action(currentTree, key, value, converter)) { didSomething = true; } } return(didSomething); }