MilesAhead Posted October 16, 2012 Posted October 16, 2012 I'm trying to figure out how Vista and Windows Seven handle Explorer Context Menu underline keys. The code below is a gui that allows the user to add or remove my MD5Hash program to File and Folder Context Menu of Explorer. It works as far as it goes. But I want to know how to pick a letter of the Key as the underlined character. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=hash.ico #AutoIt3Wrapper_outfile=MD5Context.exe #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Description=MD5Context #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=2010 www.FavesSoft.com #AutoIt3Wrapper_Res_Field=Productname|MD5Context #AutoIt3Wrapper_Res_Field=Productversion|1.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $width = 285 $height = 85 $left = (@DesktopWidth - $width) / 2 $top = (@DesktopHeight - $height) / 2 #Region ### START Koda GUI section ### Form=c:program files (x86)autoit3scitekodaformsmd5hashform.kxf $Form1 = GUICreate("MD5Hash Context Menu Tool", 285, 85, $left, $top, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION, $WS_VISIBLE, $WS_CLIPSIBLINGS)) $Button1 = GUICtrlCreateButton("Add", 45, 30, 75, 25) $Button2 = GUICtrlCreateButton("Remove", 157, 30, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If MD5ContextAdd() Then MsgBox(0x1040, "MD5Hash Context Tool", "MD5Hash Added to Context Menu", 2) ElseIf @error = 1 Then MsgBox(0x1010, "MD5Hash Context Tool", "MD5Hash.exe Not Found!", 2) Else MsgBox(0x1010, "MD5Hash Context Tool", "MD5Hash Context Menu Add Failed!", 2) EndIf Exit Case $Button2 If MD5ContextRemove() Then MsgBox(0x1040, "MD5Hash Context Tool", "MD5Hash Removed from Context Menu", 2) Else MsgBox(0x1010, "MD5Hash Context Tool", "MD5Hash Context Menu Removal Failed!", 2) EndIf Exit EndSwitch WEnd Func MD5ContextAdd() Local $Md5Root = "" Local $FileRegKey = "" Local $FolderRegKey = "" Local $Md5RegPath = @ScriptDir & "MD5Hash.exe" & " %1" If FileExists(@WindowsDir & "SysWow64") Then $Md5Root = "HKCR64" Else $Md5Root = "HKCR" EndIf If Not FileExists(@ScriptDir & "MD5Hash.exe") Then Return SetError(1, 0, False) EndIf $FileRegKey = $Md5Root & "*shellMD5Hashcommand" If Not RegWrite($FileRegKey, "", "REG_SZ", $Md5RegPath) Then Return SetError(2, 0, False) EndIf $FolderRegKey = $Md5Root & "DirectoryshellMD5Hashcommand" If Not RegWrite($FolderRegKey, "", "REG_SZ", $Md5RegPath) Then Return SetError(3, 0, False) EndIf Return True EndFunc ;==>MD5ContextAdd Func MD5ContextRemove() Local $Md5Root = "" Local $FileRegKey = "" Local $FolderRegKey = "" If FileExists(@WindowsDir & "SysWow64") Then $Md5Root = "HKCR64" Else $Md5Root = "HKCR" EndIf $FileRegKey = $Md5Root & "*shellMD5Hash" If Not RegDelete($FileRegKey) Then Return SetError(1, 0, False) EndIf $FolderRegKey = $Md5Root & "DirectoryshellMD5Hash" If Not RegDelete($FolderRegKey) Then Return SetError(1, 0, False) EndIf Return True EndFunc ;==>MD5ContextRemove As it is, in Vista 64 bit if I hold down the Shift key when I right click a folder, it shows MD5Hash with the 'M' underlined and it reacts when I press 'M'. But I can't figure out how to change this to say the '5' key. My Freeware Page
MilesAhead Posted October 17, 2012 Author Posted October 17, 2012 (edited) Now that I think of it, it may not be possible for static context menu entries. COM Explorer Shell Extensions could insert an item in the menu with an underlined character using the IContextMenu interface. I can force the menu to underline a character but it won't respond to the key press. Oh well. I learned how to turn on the underlines by default for Vista and W7 anyway. Now I know which key to press when looking at the menu without having the hold the shift key. Edited October 17, 2012 by MilesAhead My Freeware Page
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