kosamja Posted November 20, 2015 Share Posted November 20, 2015 (edited) I tried this, but it doesnt disable Toolbars, View, Sort by, Group by...; www.autoitscript.com/forum/topic/124460-how-to-disable-context-menu-item-in-windows-7/#NoTrayIcon#Include <SendMessage.au3>#include <File.au3>Opt("SendKeyDelay", 0) ;Opt("SendKeyDownDelay", 0) ;Opt("WinWaitDelay", 0) ;Local $iCountLines = _FileCountLines("Disable.txt")Global Const $MF_BYPOSITION = 0x0400Global Const $MF_GRAYED = 0x1while 1 $wnd = WinWait('[CLASS:#32768]') $hwnd = _SendMessage($wnd, 0x01E1) $MenuCount = GetMenuItemCount($hwnd) Local $i = 0 Do $i = $i + 1 Local $itemtext = FileReadLine("Disable.txt", $i) For $x = 0 To $MenuCount $text = _GUICtrlMenuGetString($hwnd, GetMenuItemID($hwnd, $x)) IF StringReplace($text, '&', '') == $itemtext Then DllCall("User32.dll", "Int", "EnableMenuItem", "HWND", $hwnd, "UInt", $x, "UInt", BitOR($MF_BYPOSITION, $MF_GRAYED)) Next Until $i = $iCountLinesWEndFunc GetMenuItemCount($hMenu) Local $nCount = DllCall('user32.dll', "int", "GetMenuItemCount", "hwnd", $hMenu) Return $nCount[0]EndFuncFunc GetMenuItemID($hMenu, $nPos) Local $nID = DllCall('user32.dll', "int", "GetMenuItemID", "hwnd", $hMenu, "int", $nPos) Return $nID[0]EndFunc;http://my-autoit.googlecode.com/svn-history/r29/trunk/Scripts/MkCabSFX/Includes/GuiMenu1.au3Func _GUICtrlMenuGetString($GMS_hWnd, $GMS_id, $GMS_Opt=0) If $GMS_hWnd <= 0 Or $GMS_id < 0 Then Return 0 Local $MF_BYCOMMAND = 0x00000000 Local $MF_BYPOSITION = 0x00000400 If $GMS_Opt = 0 Then $GMS_Opt = $MF_BYCOMMAND Else $GMS_Opt = $MF_BYPOSITION EndIf Local $GMS_r = DllCall("user32.dll","int","GetMenuString", _ "hwnd",$GMS_hWnd, _ "int",$GMS_id, _ "str","","int",0, _ "int",$GMS_Opt) If @error Then Return 0 $GMS_r = DllCall("user32.dll","int","GetMenuString", _ "hwnd",$GMS_hWnd, _ "int",$GMS_id, _ "str","","int",$GMS_r[0]+1, _ "int",$GMS_Opt) If @error Then Return 0 Return $GMS_r[3]EndFuncDisable Context Menu Items.au3Disable.txt Edited November 20, 2015 by kosamja Link to comment Share on other sites More sharing options...
AutoBert Posted November 20, 2015 Share Posted November 20, 2015 Try the examples for IE in: https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ Link to comment Share on other sites More sharing options...
kosamja Posted November 20, 2015 Author Share Posted November 20, 2015 what example should i see on that link? any idea what in script i use should be changed so that it also disables windows explorer context menu items that have submenus? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now