static WorldGenerator() { squaresHitboxesList = new List<Hitbox>(); squaresHitboxesPool = new ObjectPool<Hitbox>(CreateSquareHitbox, RecycleSquareHitbox, RABBIT_BOX_POOL_SIZE); getVisiblesWindowsAsSquaresHitboxes = new EnumWindowsProc(GetVisiblesWindowsAsSquaresHitboxes_EnumWindowsProc); }
static void Main(string[] args) { Enumerator en = new Enumerator(); EnumWindowsProc ewc = new EnumWindowsProc(en.VisitWindow); WindowsAPIWrapper.EnumWindows(ewc, (IntPtr)0); Console.ReadKey(); }
/// <summary> /// Функция находит дочернее окно в данной точке. /// </summary> /// <param name="pt">Точка в абсолютных координатах</param> /// <returns>Возвращает дескриптор окна</returns> public IntPtr FindWindowAtPos(System.Drawing.Point pt) { FindedHandle = IntPtr.Zero; POINT APIpt = new POINT(); APIpt.X = pt.X; APIpt.Y = pt.Y; GCHandle GCPoint = GCHandle.Alloc(APIpt); EnumWindowsProc cbFinder = new EnumWindowsProc(FindNextLevelWindowAtPos); EnumChildWindows(ParentHandle,FindNextLevelWindowAtPos, GCHandle.ToIntPtr(GCPoint)); return FindedHandle; }
public bool EnumWindows(System.Object ReturnObject) { System.Runtime.InteropServices.GCHandle gch = System.Runtime.InteropServices.GCHandle.Alloc(new CarverLabUtility.Win32Wrapper.InternalCallbackParams(this,ReturnObject)); EnumWindowsProc cewp = new EnumWindowsProc(CaptureEnumWindowsProc); // Platform invoke prevents the delegate from being garbage // collected before the call ends. bool bReturn = Win32Wrapper.EnumWindows(cewp, (IntPtr)gch); gch.Free(); return bReturn; }
public static int[] Run() { if (blocker) return new int[0]; blocker = true; if (list != null) list.Clear(); else list = new List<int>(); EnumWindowsProc enumWindowsProc = new EnumWindowsProc(EnumHandles.Hadd); EnumWindows(enumWindowsProc, IntPtr.Zero); int[] ret = list.ToArray(); list.Clear(); blocker = false; return ret; }
/// <summary> /// Returns a list of child windows /// </summary> /// <param name="parent">Parent of the windows to return</param> /// <returns>List of child windows</returns> public static List<IntPtr> GetWindows() { List<IntPtr> result = new List<IntPtr>(); GCHandle listHandle = GCHandle.Alloc(result); try { EnumWindowsProc childProc = new EnumWindowsProc(EnumWindow); EnumWindows(childProc, GCHandle.ToIntPtr(listHandle)); } finally { if (listHandle.IsAllocated) listHandle.Free(); } return result; }
public IntPtr GetFlashObjectHandle(WebBrowser webBrowser) { List<IntPtr> result = new List<IntPtr>(); GCHandle listHandle = GCHandle.Alloc(result); EnumWindowsProc childProc = new EnumWindowsProc(EnumWindow); EnumChildWindows(webBrowser.Handle, childProc, GCHandle.ToIntPtr(listHandle)); foreach (IntPtr ptr in result) { //only one of the handles will be correct and its class name will be "Internet Explorer_Server" //all other handles will ignore input or at least not forward it to the game if (IsIEServerWindow(ptr)) { return ptr; } } return IntPtr.Zero; }
/// <summary> Find all windows that match the given filter </summary> /// <param name="filter"> A delegate that returns true for windows /// that should be returned and false for windows that should /// not be returned </param> public static IEnumerable<IntPtr> FindWindows(EnumWindowsProc filter) { IntPtr found = IntPtr.Zero; List<IntPtr> windows = new List<IntPtr>(); Extern.EnumWindows(delegate(IntPtr wnd, IntPtr param) { if (filter(wnd, param)) { // only add the windows that pass the filter windows.Add(wnd); } // but return true here so that we iterate all windows return true; }, IntPtr.Zero); return windows; }
static extern bool EnumChildWindows( IntPtr window, EnumWindowsProc callback, int i);
private static extern int EnumWindows(EnumWindowsProc x, int y);
internal static extern bool EnumChildWindows(IntPtr hWnd, EnumWindowsProc callback, IntPtr i);
public static extern bool EnumChildWindows(IntPtr hWndParent, EnumWindowsProc enumProc, IntPtr lParam);
internal static extern bool EnumWindows(EnumWindowsProc callback, IntPtr extraData);
private static extern bool EnumChildWindows(IntPtr hWndStart, EnumWindowsProc callback, IntPtr lParam);
private static extern bool EnumWindows(EnumWindowsProc callback, IntPtr extraData);
static extern bool EnumWindows(EnumWindowsProc callback, int i);
private static extern bool EnumChildWindows(IntPtr hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
private static extern bool EnumThreadWindows(uint dwThreadId, EnumWindowsProc lpEnumFunc, IntPtr lParam);
static extern bool EnumWindows(EnumWindowsProc proc, IntPtr lParam);
static extern bool EnumThreadWindows( int threadId, EnumWindowsProc callback, int i);
public static extern int EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
protected static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, ref SearchData data);
internal static extern int EnumWindows(EnumWindowsProc ewp, int lParam);
public extern static int EnumWindows( EnumWindowsProc lpEnumFunc, int lParam);
public static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumWindowsProc lpfn, IntPtr lParam);
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, ref string windowMark);
private static extern int EnumWindows( EnumWindowsProc ewp, IntPtr lParam);
internal static extern bool EnumWindows(EnumWindowsProc numFunc, IntPtr lParam);
public WindowFinder() { ewp = new EnumWindowsProc(EnumWindowFunction); }
public extern static int EnumChildWindows( IntPtr hWndParent, EnumWindowsProc lpEnumFunc, int lParam);
static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, uint lParam);
public static extern bool EnumThreadWindows(uint dwThreadId, EnumWindowsProc lpfn, IntPtr lParam);
private static extern int EnumWindows(EnumWindowsProc ewp, int lParam);
public static bool EnumWindows(EnumWindowsProc filter) { return(EnumWindows(filter, IntPtr.Zero)); }
/// <summary> /// Enumerates all windows by calling the supplied delegate for each window. /// </summary> /// <param name="ewp">Delegate to call for each window.</param> /// <param name="lParam">Used to identify this enumeration session.</param> /// <returns>Number of windows.</returns> public static int EnumerateWindows(EnumWindowsProc ewp, IntPtr lParam) { return EnumWindows(ewp, lParam); }
public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, ref SearchData data);
private static extern bool EnumWindows(EnumWindowsProc enumFunc, int callbackVal);
private static extern bool EnumWindows(EnumWindowsProc enumFunc, int lParam);
public static extern int EnumChildWindows(IntPtr hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
static extern bool EnumWindows(EnumWindowsProc enumFunc, int lParam);
public static extern bool EnumChildWindows(IntPtr parentHandle, EnumWindowsProc lpEnumFunc, IntPtr lParam);
private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
public static extern int EnumWindows(EnumWindowsProc ewp, int lParam);
public static extern int EnumWindows(EnumWindowsProc lpfn, int lParam);
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, int dummy);
public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
public static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
internal static extern bool EnumThreadWindows(int threadId, EnumWindowsProc callback, IntPtr lParam);