-
Nov 30th, 2017, 11:31 AM
#1
Thread Starter
Lively Member
Windows10: Is the window under Mouse Cursor = Desktop?
Hi,
I'm using Win10. I have two Virtual Desktops open.
In Win10 I can switch between the two desktops with (Ctrl + Win + rightArrow) and (Ctrl + Win + leftArrow)
I want to check if the window under the mouse cursor is the
DesktopWindow. -Unfortunely the following Code does not work, because
the WindowFromPoint function returns: 65852
and the GetDesktopWindow function returns 65552
(The two values do not match). How can I fix this ?
Code:
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Dim Pt As POINTAPI
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Form_Load()
Timer1.Interval = 999
Form1.AutoRedraw = True
Move 0, 0
End Sub
Private Sub Timer1_Timer()
GetCursorPos Pt
If CurrentY > 2500 Then Cls: CurrentY = 0
Print WindowFromPoint(Pt.x, Pt.y) & Space(11) & GetDesktopWindow & Space(11) & Time
End Sub
Last edited by vb_elmar; Jan 16th, 2020 at 11:10 AM.
-
Dec 6th, 2017, 06:31 AM
#2
Thread Starter
Lively Member
Re: Windows10: Is the window under Mouse Cursor = Desktop?
-
Dec 6th, 2017, 06:55 AM
#3
Addicted Member
Re: Windows10: Is the window under Mouse Cursor = Desktop?
I suspect your getting the handle to a listview thats on the desktop (SysListView32). You can check this by using a tool called Spy++ (And if i'm correct that was aready there in vb6)
Any way if so, you will have to track down the parent of it to find the desktop handle.
Utterly useless, but always willing to help
As a finishing touch god created the dutch
-
Dec 6th, 2017, 07:42 AM
#4
Re: Windows10: Is the window under Mouse Cursor = Desktop?
-
Dec 6th, 2017, 09:12 AM
#5
Re: Windows10: Is the window under Mouse Cursor = Desktop?
There is a new shell interface in Windows 10 called IVirtualDesktopManager. It provides helpful methods like "GetWindowDesktopId" and "IsWindowOnCurrentVirtualDesktop".
I first read about it here, where there's a nice C# walkthrough. Someone would need to hack together a TLB to make it easily usable in VB. (Unfortunately, I don't know of any API fallbacks that provide the same feature, at least not in the current Windows 10 builds.)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|