This will block the LMB in the SysTray.
HOWEVER, there may possibly be unforeseen consequences, ie. how do you propose to use any tray icon menu item if it appears within the SysTray area?Disable left mouse click on windows taskbar only at the most right icons
The Exit menu item for BTLMB falls within the area covered by the SysTray, since the LMB is blocked there is no way to choose the menu item and exit the program.
This is why it has a hotkey of Ctrl+Shift+Alt+f
to exit it
Ideally you'd check to see what is under the mouse and process depending on what's there, (menu, etc), but since I'm lazy ... the source is there to get you started
You could probably fudge it by subtracting the number of pixels covered by what you don't want affected, (which will be static because the size of the Clock, etc aren't dynamic).
Only tested on Win10Pro x64.BTLMB.au3
- Block Tray LMB
#include "MouseOnEvent.au3" ; MouseOnEvent UDF
HotKeySet("^!+f", "_Exit") ; Ctrl + Shift + Alt + f
OnAutoItExitRegister("_Exit") ; Call the _Exit routine when the program is terminated somehow
; Set up tray icon menu/tooltip
; Display area
; Hook into Primary Mouse Button down event
;~ Twiddle twiddle
; Release the event hooks and Exit
_PrimaryDown() ; PMB pressed
; Get taskbar size and position, it should be visible if we're clicking on it
;~ $aTaskbar_Pos = x
;~ $aTaskbar_Pos = y
;~ $aTaskbar_Pos = width
;~ $aTaskbar_Pos = height
; Get location of Notification area but only interested in the width/height
; X/Y position returned is incorrect if Taskbar is Bottom or Right
;~ $aTray_Pos = x
;~ $aTray_Pos = y
;~ $aTray_Pos = width
;~ $aTray_Pos = height
; Check if Taskbar is visible
$aMouse_Pos = MouseGetPos() ; Get current mouse position
;~ $aMouse_Pos = x
;~ $aMouse_Pos = y
If $aTaskbar_Pos = 0 Then ; Top If ($aMouse_Pos >= 0) And ($aMouse_Pos <= $aTray_Pos) Then If $aTaskbar_Pos = 0 Then ; Left If ($aMouse_Pos <= $aTray_Pos) And ($aMouse_Pos >= 0) Then
;~ ConsoleWrite("Mouse X: " & $aMouse_Pos & " Mouse Y: " & $aMouse_Pos & @CRLF)
;~ ConsoleWrite("SysTray click X: " & $aMouse_Pos & " Mouse Y: " & $aMouse_Pos & @CRLF)
Return 1 ; Block the default processing
BTW, the reason I'm grabbing coords for the Taskbar and Tray on LMB click is because you can move the Taskbar around while the program is still running and it'll be happy.
The If...Then statements could probably be consolidated a bit better too, (did I mention I'm lazy?).
Might give someone an idea or two.UPDATE:
- Check if an array is returned for Taskbar position/size (Win 10 doesn't return array for second click on Start)