{ "name": "GetChildWindows as a List", "language": 0, "code": "using System;\r\nusing System.Drawing;\r\nusing System.Collections.Generic;\r\nusing System.Runtime.InteropServices;\r\n\r\n// The 'windowHandle' parameter will contain the window handle for the:\r\n// - Active window when run by hotkey\r\n// - Trigger target when run by a Trigger rule\r\n// - TitleBar Button owner when run by a TitleBar Button\r\n// - Jump List owner when run from a Taskbar Jump List\r\n// - Currently focused window if none of these match\r\npublic static class DisplayFusionFunction\r\n{\r\n [DllImport(\"User32.dll\")]\r\n [return: MarshalAs(UnmanagedType.Bool)]\r\n private static extern bool EnumChildWindows(IntPtr hWndParent, WNDENUMPROC lpEnumFunc, IntPtr lParam);\r\n private delegate bool WNDENUMPROC(IntPtr hwnd, IntPtr lParam);\r\n \r\n\tpublic static void Run(IntPtr windowHandle)\r\n\t{\r\n // Get all of the combo boxes from the window\r\n\t\tList comboboxes = GetChildWindows(windowHandle, \"combobox\");\r\n\t\t\r\n\t\t// Display how many we found\r\n BFS.Dialog.ShowMessageInfo(\"There are \" + comboboxes.Count + \" combo boxes\");\r\n\t}\r\n\t\r\n\tprivate static List GetChildWindows(IntPtr parent, string childWindowClass)\r\n\t{\r\n // Create a list to store our results\r\n List windows = new List();\r\n \r\n // Enumerate the child windows\r\n EnumChildWindows(parent, delegate(IntPtr hwnd, IntPtr lParam)\r\n {\r\n // If we run into a null window, end the enumeration\r\n if(hwnd == IntPtr.Zero)\r\n return false;\r\n \r\n // If the child window class doesn't match, continue the enumeration\r\n if(BFS.Window.GetClass(hwnd).IndexOf(childWindowClass, StringComparison.OrdinalIgnoreCase) == -1)\r\n return true;\r\n \r\n // If we got this far, the window class matches what we want. Add it to the list\r\n windows.Add(hwnd);\r\n return true;\r\n }, IntPtr.Zero);\r\n \r\n // Return our results\r\n return windows;\r\n\t}\r\n}", "description": "", "references": "System.Core.dll | System.Data.dll | System.dll | System.Drawing.dll | System.Management.dll | System.Web.dll | System.Windows.Forms.dll | System.Xml.dll" }