PeekMessage

[DllImport("user32.dll", SetLastError = true)]
public static extern bool PeekMessage(
   out MSG lpMsg,
   IntPtr hWnd,
   uint wMsgFilterMin,
   uint wMsgFilterMax,
   uint wRemoveMsg
);

Microsoft documentation: Link

Last updated