There's a problem, and a question. Thanks in advance for your time!
Basics:
Windows Vista Ultimate, Microsoft Visual Basic 2008 (current build)
Problem:
I have the following, simple code, in a test program:
Public Class Form1
Private Declare Function WindowFromPoint Lib "user32" (ByVal xpoint As Long, ByVal ypoint As Long) As Long
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Text = WindowFromPoint(Cursor.Pos
ition.X.To
String, Cursor.Position.Y.ToString
)
End Sub
End Class
For sake of ease, let's say all I have open is Visual Basic and my form (running after pressing play). Now, when I highlight my form (which is located in the middle of the screen) with the mouse, the caption displays the hWnd of Visual Basic (NOT the form).
If I click and drag the form to the top of my screen, once the forms top most edge touches the top of the screen, the caption changes to the applications hWnd.
Essentially, it's acting as though it's only searching the top most horizontal row of pixels for windows. Once I move my form to the top, if I move the mouse horizontally between the two title bars, the caption changes appropriately. Quite obviously this is not supposed to be the case. What could be missing?
That's a lot of text for a simple question, but the reason for the hefty sum of points is largely focused on the following question:
Supposing I get the above issue resolved, I intend to send a copy message to miscellaneous browsers. I have already tested the following code with Notepad, successfully:
Call PostMessage(hWnd&, &H301, 0&, 0&)
Assuming 'WindowFromPoint' works, if I get the hWnd of the editable section of notepad, I can easily copy any selected text. Modern browsers, however, seem to fail. I have tried everything from the ancestor window (firefox's hWnd, as a host), to the individual, tab based, hWnds (tab windows).
My absolute last resort is sendkeys (highly unwanted, unless you can sendkeys to hWnds), but I've already tried it and "^(C)" causes firefox to extract the current tab into it's own window (something seems wrong there, because manually performing this just copies selected text).
So, to surmise, I need to resolve my issue with WindowFromPoint so I can then get the hWnd of a window to send a copy command (via api or sendkeys) to either that window or it's parents window (basically whichever window is the command interpreter).
Also, you'd be a great help if you could assist in identifying which window for firefox interprets said command (or how to implement it via getting hWnd->getting hWnd's ancestor->getting title of the ancestor, then sendkeys via appactivate; which I could really figure out if the WindowFromPoint function worked).
Thank you for your time!
Start Free Trial