Jump to content

Checking if the mouse pointer is not on top of any open window


Go to solution Solved by Melba23,

Recommended Posts

I imagine it would be a CPU intensive process of finding all windows, getting their current state, if they are visible then getting their dimensions, if the current mouse location is within the start and end position of the horizontal and vertical areas then it is on a window and should be ignored.

Link to comment
Share on other sites

  • Moderators
  • Solution

power1power1,

I would use MouseGetPos to get the mouse coordinates and then call _WinAPI_WindowFromPoint to see what is underneath that point. If it is the desktop then you have your answer. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi Melba23, Thanks for the tip. I looked at the help page for _WinAPI_WindowFromPoint and there is an example code there that does exactly this. I added ConsoleWrite(WinGetTitle($hWnd)&@CRLF) to the loop to get the window title. When mouse pointer is on top of desktop, the window title I am getting is "FolderView", which I didn't expect. When the mouse pointer is on top of the taskbar, I get "Runing applications". What do you think?

Maybe I tell you what I am ultimately planning to do and see if you have any other suggestions to do it: I want to use the wheel on my mouse to control the sound volume when the mouse pointer is on top of the taskbar and when it is on top of desktop but not on top of any open windows. Volumouse stopped working when I switched to Windows 8.1: It adjusts the volume when the pointer is on top of takbar but when on top of the desktop, it doesn't do it anymore.

Link to comment
Share on other sites

  • Moderators

power1power1,

 

What do you think?

As long as you can identify that fact that you are over the desktop/taskbar what does it matter what is actually returned? You can now identify the 2 occasions when you want your mousewheel to react. :)

M23

P.S. I get the same titles when i run the script. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...