riteshtechie Posted January 20, 2011 Share Posted January 20, 2011 (edited) I used the following code to disable "Rename" Right click context menu in Windows 7 in Autohotkey. But I would like to do the same in Autoit, as am new to it, I don't know, can anyone help. expandcollapse popup#SingleInstance Force #NoTrayIcon #NoEnv MF_BYPOSITION := 0x0400, MF_GRAYED := 0x01 Loop { WinWait, ahk_class #32770 WinGetClass, class, A If class in Progman,CabinetWClass,ExploreWClass { SendMessage, 0x01E1 MenuID := ErrorLevel Loop, % DllCall("GetMenuItemCount", UInt, MenuID) { if RegExReplace(GetMenuItemText(MenuID, A_Index-1), "&")="Rename" DllCall("EnableMenuItem", "UInt", MenuID, "UInt", A_Index-1, "UInt", MF_BYPOSITION | MF_GRAYED) } } WinWaitClose } GetMenuItemText(ByRef MenuID, i, MenuStrlen=0){ global MF_BYPOSITION VarSetCapacity(MenuStr, MenuStrLen) Len := DllCall("GetMenuString", "UInt", MenuID, "UInt", i, "str", MenuStr, "UInt", MenuStrLen, "UInt", MF_BYPOSITION) if(MenuStrLen=0 and Len!=0) return GetMenuItemText(MenuID, i, Len+1) Else return MenuStr } #F8::ExitApp Also if any one can tell me similar functions for #NoTrayIcon it hides tray icon. Edited January 20, 2011 by riteshtechie Link to comment Share on other sites More sharing options...
funkey Posted January 20, 2011 Share Posted January 20, 2011 I just can say that #NoTrayIcon is the same in AutoIt. AutoHotKey is confusing to me! Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
JFX Posted January 22, 2011 Share Posted January 22, 2011 AutoHotKey is confusing to me!Yeah and your annoying avatar deserves a line in my urlfilter.ini. @riteshtechie Explorer right click menu does (always) have Class #32768 for me, so you may need to change it back to your #32770. expandcollapse popup#NoTrayIcon #Include <SendMessage.au3> Global Const $MF_BYPOSITION = 0x0400 Global Const $MF_GRAYED = 0x1 HotKeySet("{F8}", "Terminate") $itemtext = 'Rename' while 1 $wnd = WinWait('[CLASS:#32768]') $hwnd = _SendMessage($wnd, 0x01E1) $MenuCount = GetMenuItemCount($hwnd) 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 WEnd Func Terminate() Exit 0 EndFunc Func GetMenuItemCount($hMenu) Local $nCount = DllCall('user32.dll', "int", "GetMenuItemCount", "hwnd", $hMenu) Return $nCount[0] EndFunc Func 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.au3 Func _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] EndFunc 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