Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_ShellAll() - Create an entry in the shell contextmenu when selecting a file and folder, includes the program icon as well.


  • Please log in to reply
5 replies to this topic

#1 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,711 posts

Posted 15 October 2011 - 09:54 PM

I created this after I developed _ShellFile() and _ShellFolder() because I wanted to add an entry to the contextmenu when selecting any file or folder.

The entry will pass the file/folder name to your program via a commandline argument, so you'll have to use $CmdLine/$CmdLineRaw to access the file/folder that was selected.

Any problems or suggestions then please post below. Thanks.

UDF:
AutoIt         
#include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _ShellAll ; AutoIt Version : v3.2.12.1 or higher ; Language ......: English ; Description ...: Create an entry in the shell contextmenu when selecting a file and folder, includes the program icon as well. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: Special thanks to KaFu for EnumRegKeys2Array() which I used as inspiration for enumerating the Registry Keys. ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= ; None ; #GLOBAL VARIABLES# ================================================================================================= ; None ; #CURRENT# ===================================================================================================================== ; _ShellAll_Install: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a file and folder. ; _ShellAll_Uninstall: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __ShellAll_RegistryGet ......; Retrieve an array of registry entries for a specific key. ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellAll_Install ; Description ...: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a file and folder. ; Syntax ........: _ShellAll_Install($sText[, $sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sIconPath = @ScriptFullPath[, ;                  $iIcon = 0[, $fAllUsers = False[, $fExtended = False]]]]]]) ; Parameters ....: $sText               - Text to be shown in the contextmenu. ;                  $sName               - [optional] Name of the program. Default is @ScriptName. ;                  $sFilePath           - [optional] Location of the program executable. Default is @ScriptFullPath. ;                  $sIconPath           - [optional] Location of the icon e.g. program executable or dll file. Default is @ScriptFullPath. ;                  $iIcon               - [optional] Index of icon to be used. Default is 0. ;                  $fAllUsers           - [optional] Add to Current Users (False) or All Users (True) Default is False. ;                  $fExtended           - [optional] Show in the Extended contextmenu using Shift + Right click. Default is False. ; Return values .: Success - RegWrite() Return code. ;                  Failure - none ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellAll_Install($sText, $sName = @ScriptName, $sFilePath = @ScriptFullPath, $sIconPath = @ScriptFullPath, $iIcon = 0, $fAllUsers = False, $fExtended = False)     Local $aArray[3] = [2, '*', 'Directory'], $i64Bit = ''     If $iIcon = Default Then         $iIcon = 0     EndIf     If $sFilePath = Default Then         $sFilePath = @ScriptFullPath     EndIf     If $sIconPath = Default Then         $sIconPath = @ScriptFullPath     EndIf     If $sName = Default Then         $sName = @ScriptName     EndIf     If @OSArch = 'X64' Then         $i64Bit = '64'     EndIf     For $i = 1 To $aArray[0]         If $fAllUsers Then             $aArray[$i] = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell'         Else             $aArray[$i] = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell'         EndIf     Next     $sName = StringRegExpReplace($sName, '.[^./]*$', '')     If StringStripWS($sName, 8) = '' Or FileExists($sFilePath) = 0 Then         Return SetError(1, 0, 0)     EndIf     _ShellAll_Uninstall($sName, $fAllUsers)     For $i = 1 To $aArray[0]         RegWrite($aArray[$i] & $sName, '', 'REG_SZ', $sText)         RegWrite($aArray[$i] & $sName, 'Icon', 'REG_EXPAND_SZ', $sIconPath & ',' & $iIcon)         RegWrite($aArray[$i] & $sName & 'command', '', 'REG_SZ', '"' & $sFilePath & '" "%1"')         If $fExtended Then             RegWrite($aArray[$i], 'Extended', 'REG_SZ', '')         EndIf     Next     Return SetError(@error, 0, @error) EndFunc   ;==>_ShellAll_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellAll_Uninstall ; Description ...: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; Syntax ........: _ShellAll_Uninstall([$sName = @ScriptName[, $fAllUsers = False]]) ; Parameters ....: $sName               - [optional] Name of the Program. Default is @ScriptName. ;                  $fAllUsers           - [optional] Was it added to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - Returns 2D Array of registry entries. ;                  Failure - Returns 0 and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellAll_Uninstall($sName = @ScriptName, $fAllUsers = False)     Local $aArray[3] = [2, '*', 'Directory'], $i64Bit = ''     If $sName = Default Then         $sName = @ScriptName     EndIf     If @OSArch = 'X64' Then         $i64Bit = '64'     EndIf     For $i = 1 To $aArray[0]         If $fAllUsers Then             $aArray[$i] = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell'         Else             $aArray[$i] = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClasses' & $aArray[$i] & 'shell'         EndIf     Next     $sName = StringRegExpReplace($sName, '.[^./]*$', '')     If StringStripWS($sName, 8) = '' Then         Return SetError(1, 0, 0)     EndIf     Local $aFinal[1][5] = [[0, 5]], $aReturn = 0, $sDelete = ''     For $i = 1 To $aArray[0]         $aReturn = __ShellAll_RegistryGet($aArray[$i])         If $aReturn[0][0] > 0 Then             For $j = 1 To $aReturn[0][0]                 If $aReturn[$j][0] = $sName And $sDelete <> $aReturn[$j][1] Then                     $sDelete = $aReturn[$j][1]                     RegDelete($sDelete)                 EndIf             Next             ReDim $aFinal[$aFinal[0][0] + $aReturn[0][0] + 1][$aReturn[0][1]]             For $j = 1 To $aReturn[0][0]                 $aFinal[0][0] += 1                 For $k = 0 To $aReturn[0][1] - 1                     $aFinal[$aFinal[0][0]][$k] = $aReturn[$j][$k]                 Next             Next             $aFinal[0][1] = $aReturn[0][1]         EndIf     Next     Return $aFinal EndFunc   ;==>_ShellAll_Uninstall ; #INTERNAL_USE_ONLY#============================================================================================================ Func __ShellAll_RegistryGet($sRegistryKey)     Local $aArray[1][5] = [[0, 5]], $iCount_1 = 0, $iCount_2 = 0, $iDimension = 0, $iError = 0, $sRegistryKey_All = '', $sRegistryKey_Main = '', $sRegistryKey_Name = '', _             $sRegistryKey_Value = ''     While 1         If $iError Then             ExitLoop         EndIf         $sRegistryKey_Main = RegEnumKey($sRegistryKey, $iCount_1 + 1)         If @error Then             $sRegistryKey_All = $sRegistryKey             $iError = 1         Else             $sRegistryKey_All = $sRegistryKey & $sRegistryKey_Main         EndIf         $iCount_2 = 0         While 1             $sRegistryKey_Name = RegEnumVal($sRegistryKey_All, $iCount_2 + 1)             If @error Then                 ExitLoop             EndIf             If ($aArray[0][0] + 1) >= $iDimension Then                 $iDimension = ($aArray[0][0] + 1) * 2                 ReDim $aArray[$iDimension][$aArray[0][1]]             EndIf             $sRegistryKey_Value = RegRead($sRegistryKey_All, $sRegistryKey_Name)             $aArray[$aArray[0][0] + 1][0] = $sRegistryKey_Main             $aArray[$aArray[0][0] + 1][1] = $sRegistryKey_All             $aArray[$aArray[0][0] + 1][2] = $sRegistryKey & $sRegistryKey_Main & '' & $sRegistryKey_Name             $aArray[$aArray[0][0] + 1][3] = $sRegistryKey_Name             $aArray[$aArray[0][0] + 1][4] = $sRegistryKey_Value             $aArray[0][0] += 1             $iCount_2 += 1         WEnd         $iCount_1 += 1     WEnd     ReDim $aArray[$aArray[0][0] + 1][$aArray[0][1]]     Return $aArray EndFunc   ;==>__ShellAll_RegistryGet

Example 1:
#include '_ShellAll.au3' Example() Func Example()     _ShellAll_Install('Start ShellAll') ; Add the running EXE to the Shell ContextMenu. This will only display when selecting a file and folder.     Sleep(10000)     _ShellAll_Uninstall() ; Remove the running EXE from the Shell ContextMenu. EndFunc   ;==>Example

All of the above has been included in a ZIP file. Attached File  ShellAll.zip   2.35KB   299 downloads

Extended: A working example.

Edited by guinness, 08 October 2012 - 01:07 PM.

  • BinaryBrother likes this

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasswordValidPasteBinPosts Per DayPreExpandQueue()SciTE JumpSHELLHOOKShunting-YardSignature CreatorStack()StringAddLF()/StringStripLF()StringEOLToCRLF()WM_COPYDATAMore Examples...
Updated: 12/04/2014








#2 TheSaint

TheSaint

    *** Knight Templar ***

  • MVPs
  • 5,170 posts

Posted 24 November 2011 - 12:25 PM

As always, thanks for sharing!

Make sure brain is in gear before opening mouth! Ignoring those who try to divert conversation with irrelevancies. If I put effort into communication, I expect you to read properly & fully, or just not comment. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox


#3 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,711 posts

Posted 24 November 2011 - 10:30 PM

Thanks. I have a couple more of these explorer 'ContextMenu' addition UDF's in the pipeline.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasswordValidPasteBinPosts Per DayPreExpandQueue()SciTE JumpSHELLHOOKShunting-YardSignature CreatorStack()StringAddLF()/StringStripLF()StringEOLToCRLF()WM_COPYDATAMore Examples...
Updated: 12/04/2014


#4 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,711 posts

Posted 08 October 2012 - 01:08 PM

I've updated the syntax of the UDF and fixed a bug when checking whether or not an entry existed (though not critical.) Please see the original post for more details. Additionally the Default keyword is now supported. Thanks.

Edited by guinness, 08 October 2012 - 02:32 PM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasswordValidPasteBinPosts Per DayPreExpandQueue()SciTE JumpSHELLHOOKShunting-YardSignature CreatorStack()StringAddLF()/StringStripLF()StringEOLToCRLF()WM_COPYDATAMore Examples...
Updated: 12/04/2014


#5 mpower

mpower

    Seeker

  • Active Members
  • 46 posts

Posted 23 October 2012 - 12:32 AM

hi guinness, thanks for this great UDF, it's exactly what I am after.

One question: how do I set up a context menu item with the sole function of simply getting the full file path of the selected file(s) and pass to array?

E.g. I highlight several files in explorer and right click and select "Get Path" and I get an array with each individual file path

Really appreciate your work and help!

#6 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,711 posts

Posted 23 October 2012 - 07:11 AM

This requires a little bit more work, there is an example in the forum I created. Just search for 'ShellFile' in the General Support Forum.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasswordValidPasteBinPosts Per DayPreExpandQueue()SciTE JumpSHELLHOOKShunting-YardSignature CreatorStack()StringAddLF()/StringStripLF()StringEOLToCRLF()WM_COPYDATAMore Examples...
Updated: 12/04/2014





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users