Get by class name and parent window handle. For example: grab the handle of the start button using win32api. First, you know the class name of the parent window using the spyxx tool.
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr handleParent, IntPtr handleChild, string className, string WindowName);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string className, string windowTitle);
Using:
IntPtr handle = FindWindowEx(FindWindow("Shell_TrayWnd",null), new IntPtr(0), "Button", null);
source
share