[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 Integer, ByVal yPoint As Integer) As IntPtr
End Function
[DllImport("user32.dll")]
class method WindowFromPoint(aPoint: System.Drawing.Point): IntPtr; external;
Public Declare Function WindowFromPoint Lib "user32" _
(ByVal Point As POINT) As Long
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.
Had the issues described below but found a way that worked for me:
WindowFromPoint(POINT Point) always returned 0 in both 32/64 bit process when I used long(Int64) for x and y in POINT struct.
When I use int(Int32) it works fine !
struct POINT {
int x;
int y;
}
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)
VB.net express edition 2013
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Int32, ByVal yPoint As Int32) As Long
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
Dim pntX As Int32 = MousePosition.X
Dim pntY As Int32 = MousePosition.Y
Dim lhWnd As Long
lhWnd = WindowFromPoint(pntX, pntY)
Label1.Text = lhWnd.ToString
End Sub
Do you know one? Please contribute it!