[DllImport("user32.dll")]
static extern IntPtr WindowFromPoint(POINT Point);
[DllImport("user32.dll")]
static extern IntPtr WindowFromPoint(int xPoint, int yPoint);
<DllImport("user32.dll")> _
Private Shared Function WindowFromPoint(ByVal Point As POINT) As IntPtr
End Function
<DllImport("user32.dll")> _
Private Shared Function WindowFromPoint(ByVal xPoint As int, ByVal yPointAs int) As IntPtr
End Function
The WindowFromPoint function retrieves a handle to the window that contains the specified point.
Please add some!
[DllImport("user32.dll")]
static extern IntPtr WindowFromPoint(POINT Point);
[DllImport("user32.dll")]
static extern IntPtr WindowFromPoint(int xPoint, int yPoint);
[DllImport("user32.dll")]
static extern bool GetCursorPos(out Point lpPoint);
[DllImport("user32.dll")]
static extern bool SetWindowText(IntPtr hWnd, string lpString);
Point p;
if (GetCursorPos(out p))
{
//IntPtr hWnd = WindowFromPoint(p);
IntPtr hWnd = WindowFromPoint(Cursor.Position.X, Cursor.Position.Y);
SetWindowText(hWnd, "Window Found");
}
Do you know one? Please contribute it!
Imports System.Runtime.InteropServices
Module test
<DllImport("user32.dll")> _
Function WindowFromPoint(ByVal xyPoint As POINT) As Long
End Function
end module
xPoint, yPoint
The WindowFromPoint function retrieves a handle to the window that contains the specified point.
WindowFromPoint API is unable to return correct window handle under 64bit Application Process, if any body has done it..please post.
Windows7 (vs2010)
- IntPtr WindowFromPoint(POINT Point) always return 0 in both 32/64 bit process.
- IntPtr WindowFromPoint(int x, int y) works in 32-bit but fails in 64-bit process.
Please add some!
Dim tPA As Point
Dim lhWnd As Long
tPA = Cursor.Position
' Get window handle from point
lhWnd = WindowFromPoint(tPA)
Do you know one? Please contribute it!