Getting HWND off of CoreWindow object in UWP

This COM interface is only directly accessible to C++ code. In C# you have to declare it yourself and make it match the interface declaration in C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\winrt\CoreWindow.idl. Like this: using System.Runtime.InteropServices; … [ComImport, Guid(“45D64A29-A63E-4CB6-B498-5781D298CB4F”)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface ICoreWindowInterop { IntPtr WindowHandle { get; } bool MessageHandled { set; } } Obtaining the interface … Read more

In Java Swing how do you get a Win32 window handle (hwnd) reference to a window?

You don’t have write any C/JNI code. From Java: import sun.awt.windows.WComponentPeer; public static long getHWnd(Frame f) { return f.getPeer() != null ? ((WComponentPeer) f.getPeer()).getHWnd() : 0; } Caveats: This uses a sun.* package. Obviously this is not public API. But it is unlikely to change (and I think less likely to break than the solutions … Read more

Get HWND of each Window?

You mixed up ctypes and win32gui. The hwnd you’ve got is obtained via ctypes and is a LP_c_long object. That’s why win32gui.MoveWindow didn’t accept it. You should pass it to ctypes.windll.user32.MoveWindow(titles[5][0], 0, 0, 760, 500, True) If you want to use win32gui.MoveWindow, you can use python function as callback directly. For example, import win32gui def … Read more

GetDlgCtrlID for top-level window with menu bar – return value

It is not inaccurate. You create a top-level window with CreateWindowEx(). Which looks like this: HWND WINAPI CreateWindowEx( _In_ DWORD dwExStyle, _In_opt_ LPCTSTR lpClassName, _In_opt_ LPCTSTR lpWindowName, _In_ DWORD dwStyle, _In_ int x, _In_ int y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam ); … Read more