#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive ahk_class Shell_TrayWnd
$LButton::
return

Hi MilesAhead,
This blocks all left mouse clicks, I would only like to disable it on the far left icons, in this screenshot I have marked the area in yellow that I would like to disable the lefts mouse click for.
[attachment 1 not found]

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive ahk_class Shell_TrayWnd
$LButton::
MouseGetPos,X,Y,Win,Contr
If (Contr != "ToolBarWindow321")
Send, {LButton}
returnEdit: If you are on Windows 10 the control name may be ToolBarWindow322.Confirmed: ToolBarWindow322 when on Win10.


#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
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)
TraySetToolTip(StringLeft(@ScriptName, StringLen(@ScriptName) - 4))
TrayCreateItem('Exit',-1,-1,0)
TrayItemSetOnEvent(-1,'_Exit')
; Display area
; Hook into Primary Mouse Button down event
_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_PrimaryDown")
While Sleep(100)
;~ Twiddle twiddle
WEnd
Func _Exit()
; Release the event hooks and Exit
_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)
OnAutoItExitUnRegister("_Exit")
Exit
EndFunc
Func _PrimaryDown() ; PMB pressed
Local $bBlock = False
; Get taskbar size and position, it should be visible if we're clicking on it
Local $aTaskbar_Pos = WinGetPos( "[Class:Shell_TrayWnd]")
;~ $aTaskbar_Pos[0] = x
;~ $aTaskbar_Pos[1] = y
;~ $aTaskbar_Pos[2] = width
;~ $aTaskbar_Pos[3] = height
If IsArray($aTaskbar_Pos) Then ; Check if array is returned
; Get location of Notification area but only interested in the width/height
; X/Y position returned is incorrect if Taskbar is Bottom or Right
Local $aTray_Pos = ControlGetPos(WinGetHandle("[CLASS:Shell_TrayWnd]"), "", "[CLASS:TrayNotifyWnd]")
;~ $aTray_Pos[0] = x
;~ $aTray_Pos[1] = y
;~ $aTray_Pos[2] = width
;~ $aTray_Pos[3] = height
; Check if Taskbar is visible
If ( $aTaskbar_Pos[0] > -3) And ( $aTaskbar_Pos[1] > -3) And ( $aTaskbar_Pos[0] < ( @DesktopWidth - 5)) And ( $aTaskbar_Pos[1] < ( @DesktopHeight - 5)) Then
$aMouse_Pos = MouseGetPos() ; Get current mouse position
;~ $aMouse_Pos[0] = x
;~ $aMouse_Pos[1] = y
Select
Case $aTaskbar_Pos[2] = @DesktopWidth ; Taskbar at Top or Bottom
If $aTaskbar_Pos[1] = 0 Then ; Top
If ($aMouse_Pos[0] >= (@DesktopWidth - $aTray_Pos[2])) And ($aMouse_Pos[0] <= @DesktopWidth) Then
If ($aMouse_Pos[1] >= 0) And ($aMouse_Pos[1] <= $aTray_Pos[3]) Then
$bBlock = True
EndIf
EndIf
Else ; Bottom
If ($aMouse_Pos[0] >= (@DesktopWidth - $aTray_Pos[2])) And ($aMouse_Pos[0] <= @DesktopWidth) Then
If ($aMouse_Pos[1] >= (@DesktopHeight - $aTray_Pos[3])) And ($aMouse_Pos[1] <= @DesktopHeight) Then
$bBlock = True
EndIf
EndIf
EndIf
Case $aTaskbar_Pos[3] = @DesktopHeight ; Taskbar at Left or Right
If $aTaskbar_Pos[0] = 0 Then ; Left
If ($aMouse_Pos[0] <= $aTray_Pos[2]) And ($aMouse_Pos[0] >= 0) Then
If ($aMouse_Pos[1] >= (@DesktopHeight - $aTray_Pos[3])) And ($aMouse_Pos[1] <= @DesktopHeight) Then
$bBlock = True
EndIf
EndIf
Else ; Right
If ($aMouse_Pos[0] >= (@DesktopWidth - $aTray_Pos[2])) And ($aMouse_Pos[0] <= @DesktopWidth) Then
If ($aMouse_Pos[1] >= @DesktopHeight - ($aTray_Pos[3])) And ($aMouse_Pos[1] <= @DesktopHeight) Then
$bBlock = True
EndIf
EndIf
EndIf
Case Else
;~ ConsoleWrite("Mouse X: " & $aMouse_Pos[0] & " Mouse Y: " & $aMouse_Pos[1] & @CRLF)
EndSelect
EndIf
EndIf
If $bBlock Then
;~ ConsoleWrite("SysTray click X: " & $aMouse_Pos[0] & " Mouse Y: " & $aMouse_Pos[1] & @CRLF)
Return 1 ; Block the default processing
EndIf
EndFunc ;==>_PrimaryDown#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
$LButton::
MouseGetPos,X,Y,Win,Contr
If (Contr != "ToolBarWindow321")
Send, {LButton}
return

The script from 4wd worked only I got an error when I was double clicking the start menu button.



Hi MilesAhead,
Thanks for your effort but this still doesn't work, I can still click on the systray clock icon with the left mouse button.
The script from 4wd worked only I got an error when I was double clicking the start menu button.
Is there a way of disabling the left mous click based on the mouse position x and Y area ?
br
Huub
What part/line did you change ?
If IsArray($aTaskbar_Pos) Then ; Check if array is returnedYou simply need to use the Window Spy to get the name of the control/window under the mouse cursor and add to the If statement. It will vary with version of Windows etc..


If IsArray($aTaskbar_Pos) Then ; Check if array is returned


#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
$LButton::
MouseGetPos,X,Y,Win,Contr
If (Contr != "TrayClockWClass1")
Send, {LButton}
returnOriginal address: https://www.donationcoder.com/forum/index.php?topic=42800.0