#include <GuiMenu.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>
Opt('MustDeclareVars', 1)
Opt('TrayAutoPause', 0)
Global $hLowLevelMouseProc, $hMod, $hHookEx, $fRButtonDown, $iIDTimer, $iCount, $tPoint, $fLButtonDown
$hLowLevelMouseProc = DllCallbackRegister('_LowLevelMouseProc', 'int', 'int;wparam;lparam')
If Not $hLowLevelMouseProc Then Exit 1
$hMod = _WinAPI_GetModuleHandle('')
If Not $hMod Then Exit 2
$tPoint = DllStructCreate($tagPOINT)
$hHookEx = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hLowLevelMouseProc), $hMod)
If Not $hHookEx Then Exit 3
$hMod = 0
OnAutoItExitRegister('_OnExit')
HotKeySet('{ESC}', '_Exit')
While 1
Sleep(1000)
WEnd
Func _LowLevelMouseProc($iCode, $wParam, $lParam)
If $iCode < 0 Then
Return _WinAPI_CallNextHookEx($hHookEx, $iCode, $wParam, $lParam)
EndIf
Switch $wParam
Case $WM_MOUSEMOVE
If $fLButtonDown Then
If _DisableStart() Then
;~ здесь, по идее, надо еще проверять, есть ли выделенные документы(папки)
MouseUp('Main')
EndIf
$fLButtonDown = False
EndIf
Case $WM_LBUTTONDOWN
$fLButtonDown = True
Case $WM_LBUTTONUP
$fLButtonDown = False
Case $WM_RBUTTONDOWN
$fRButtonDown = _DisableStart()
Case $WM_RBUTTONUP
If $fRButtonDown Then
$iIDTimer = _Timer_SetTimer(0, 50, '_Disable')
$fRButtonDown = False
EndIf
EndSwitch
Return _WinAPI_CallNextHookEx($hHookEx, $iCode, $wParam, $lParam)
EndFunc ;==>_LowLevelMouseProc
Func _Disable($hWnd, $Msg, $iIDTimer, $dwTime)
Local $h_Wnd, $h_Menu, $s_Txt
$iCount += 1
If $iCount = 3 Then
_Timer_KillTimer(0, $iIDTimer)
$iIDTimer = 0
$iCount = 0
Return
EndIf
$h_Wnd = WinGetHandle('[CLASS:#32768]')
If Not $h_Wnd Then Return
$h_Menu = _SendMessage($h_Wnd, $MN_GETHMENU)
If Not $h_Menu Then Return
For $i = 0 To _GUICtrlMenu_GetItemCount($h_Menu) - 1
$s_Txt = StringReplace(_GUICtrlMenu_GetItemText($h_Menu, $i), '&', '')
;~ ConsoleWrite('$s_Txt: ' & $s_Txt & @LF)
If StringRegExp($s_Txt, '^(Отправить|Вырезать|Копировать|Удалить|Переименовать)$') Then
_GUICtrlMenu_SetItemEnabled($h_Menu, $i, False)
;~ ConsoleWrite('Disable -> ' & $s_Txt & @LF)
EndIf
Next
_Timer_KillTimer(0, $iIDTimer)
$iIDTimer = 0
$iCount = 0
EndFunc ;==>_Disable
Func _DisableStart()
Local $h_Hwd, $h_Win, $s_Class
If Not _WinAPI_GetCursorPos($tPoint) Then Return 0
$h_Hwd = _WinAPI_WindowFromPoint($tPoint)
If Not $h_Hwd Then Return 0
$h_Win = _WinAPI_GetAncestor($h_Hwd, $GA_ROOT)
If Not $h_Win Then Return 0
IF $h_Win = $h_Hwd Then Return 0
$s_Class = _WinAPI_GetClassName($h_Win)
;~ ConsoleWrite('$s_Class: ' & $s_Class & @LF)
Return StringRegExp($s_Class, '^(Progman|CabinetWClass|ExploreWClass)$');ExploreWClass - WinXP
EndFunc ;==>_DisableStart
Func _WinAPI_GetCursorPos(ByRef $t_Point)
Local $a_Res = DllCall('user32.dll', 'int', 'GetCursorPos', 'struct*', $t_Point)
If (@error) Or (Not $a_Res[0]) Then Return 0
Return 1
EndFunc ;==>_WinAPI_GetCursorPos
Func _OnExit()
If $iIDTimer Then _Timer_KillTimer(0, $iIDTimer)
_WinAPI_UnhookWindowsHookEx($hHookEx)
DllCallbackFree($hLowLevelMouseProc)
EndFunc ;==>_OnExit
Func _Exit()
Exit
EndFunc ;==>_Exit