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

_ContextMenu() - Create an entry in the desktop contextmenu, with the program icon as well.


  • Please log in to reply
30 replies to this topic

#1 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,633 posts

Posted 13 June 2011 - 11:47 PM

I created this after GEOSoft asked a question about adding an entry to the desktop contextmenu with an icon. I therefore thought it would be useful to create for those who would like to add an entry, but wouldn't know where to begin. :huh2:

UDF:
AutoIt         
#include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# ======================================================================================================================= ; Title .........: _ContextMenu ; AutoIt Version : v3.2.12.1 or higher ; Language ......: English ; Description ...: Create an entry in the desktop contextmenu, with the program icon as well. ; Note ..........: Thanks to GEOSoft for the initial idea & LaCastiglione for the link on how to add an icon to the desktop contextmenu. ;                  Link: http://www.autoitscript.com/forum/topic/129677-need-an-answer-to-a-simple-problem/ ; Author(s) .....: guinness ; Remarks .......: Special thanks to KaFu for EnumRegKeys2Array() which I used as inspiration for enumerating the Registry Keys. ; Warning .......: This has been tested on Windows 7 only. ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= ; None ; #GLOBAL VARIABLES# ================================================================================================= ; None ; #CURRENT# ===================================================================================================================== ; _ContextMenu_Install: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the desktop shell contextmenu. ; _ContextMenu_Uninstall: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the desktop shell contextmenu. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __ContextMenu_RegistryGet ......; Retrieve an array of registry entries for a specific key. ; =============================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _ContextMenu_Install() ; Description ...: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the desktop shell contextmenu. ; Syntax.........: _ContextMenu_Install($sText, [$sName = @ScriptName, [$sFilePath = @ScriptFullPath, [$sIconPath = @ScriptFullPath, [$iIcon = 0, [$iAllUsers = 0, [$iExtended = 0]]]]]]) ; Parameters ....: $sText - Text to be shown in the contextmenu. ;                  $sName - [Optional] Name of the program. [Default = Script name] ;                  $sFilePath - [Optional] Location of the program executable. [Default = Full script location] ;                  $sIconPath - [Optional] Location of the icon e.g. program executable or dll file. [Default = Full script location] ;                  $$iIcon - [Optional] Index of icon to be used. [Default = 0 - Main icon] ;                  $iAllUsers - [Optional] Add to Current Users (0) or All Users (1) [Default = 0 - Current user] ;                  $iExtended - [Optional] Show in the Extended contextmenu using Shift + Right click. [Default = 0 - Show in main contextmeu.] ; Requirement(s).: v3.2.12.1 or higher ; Return values .: Success - RegWrite() Return code. ;                  Failure - none ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _ContextMenu_Install($sText, $sName = @ScriptName, $sFilePath = @ScriptFullPath, $sIconPath = @ScriptFullPath, $iIcon = 0, $iAllUsers = 0, $iExtended = 0)     Local $i64Bit = "", $sRegistryKey = ""     If @OSArch = "X64" Then         $i64Bit = "64"     EndIf     If $iAllUsers Then         $sRegistryKey = "HKEY_LOCAL_MACHINE" & $i64Bit & "\SOFTWARE\Classes\Directory\Background\shell\"     Else         $sRegistryKey = "HKEY_CURRENT_USER" & $i64Bit & "\SOFTWARE\Classes\Directory\Background\shell\"     EndIf     $sName = StringLower(StringReplace($sName, ".exe", ""))     If $sName = "" Or $sFilePath = "" Then         Return SetError(1, 0, 0)     EndIf     _ContextMenu_Uninstall($sName, $iAllUsers)     RegWrite($sRegistryKey & $sName, "", "REG_SZ", $sText)     RegWrite($sRegistryKey & $sName, "Icon", "REG_EXPAND_SZ", $sIconPath & "," & $iIcon)     RegWrite($sRegistryKey & $sName & "\command", "", "REG_SZ", $sFilePath)     If $iExtended Then         RegWrite($sRegistryKey & $sName, "Extended", "REG_SZ", "")     EndIf     Return SetError(@error, 0, @error) EndFunc   ;==>_ContextMenu_Install ; #FUNCTION# ========================================================================================================= ; Name...........: _ContextMenu_Uninstall() ; Description ...: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the desktop shell contextmenu. ; Syntax.........: _ContextMenu_Uninstall([$sName = @ScriptName, [$iAllUsers = 0]]) ; Parameters ....: $sName - [Optional] Name of the Program [Default = Script name.] ;                  $iAllUsers - [Optional] Was it added to Current Users (0) or All Users (1). [Default = 0 - Current user] ; Requirement(s).: v3.2.12.1 or higher ; Return values .: Success - Returns 2D Array of registry entries. ;                  Failure - Returns 0 and sets @error to 1. ; Author ........: guinness ; Example........; Yes ;===================================================================================================================== Func _ContextMenu_Uninstall($sName = @ScriptName, $iAllUsers = 0)     Local $aArray, $i64Bit = "", $sDelete, $sRegistryKey = ""     If @OSArch = "X64" Then         $i64Bit = "64"     EndIf     If $iAllUsers Then         $sRegistryKey = "HKEY_LOCAL_MACHINE" & $i64Bit & "\SOFTWARE\Classes\Directory\Background\shell\"     Else         $sRegistryKey = "HKEY_CURRENT_USER" & $i64Bit & "\SOFTWARE\Classes\Directory\Background\shell\"     EndIf     $sName = StringLower(StringReplace($sName, ".exe", ""))     If $sName = "" Then         Return SetError(1, 0, 0)     EndIf     $aArray = __ContextMenu_RegistryGet($sRegistryKey)     If $aArray[0][0] > 0 Then         For $A = 1 To $aArray[0][0]             If $aArray[$A][0] = $sName And $sDelete <> $aArray[$A][1] Then                 $sDelete = $aArray[$A][1]                 RegDelete($sDelete)             EndIf         Next     EndIf     Return $aArray EndFunc   ;==>_ContextMenu_Uninstall ; #INTERNAL_USE_ONLY#============================================================================================================ Func __ContextMenu_RegistryGet($sRegistryKey)     Local $aArray[1][5] = [[0, 5]], $iCount_1 = 0, $iCount_2 = 0, $iDimension, $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   ;==>__ContextMenu_RegistryGet

Example 1:
#include "_ContextMenu.au3" _Main() Func _Main()     _ContextMenu_Install("Start ContextMenu") ; Add the running EXE to the desktop contextmenu.     Sleep(10000)     _ContextMenu_Uninstall() ; Remove the running EXE from the desktop contextmenu. EndFunc   ;==>_Main

All of the above has been included in a ZIP file. Attached File  ContextMenu.zip   2.31KB   640 downloads
Warning: This has been tested on Windows 7 only.

Edited by guinness, 15 October 2011 - 11:12 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








#2 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,250 posts

Posted 14 June 2011 - 12:15 AM

Only tested on Windows 7.

Yep, not working on Win XP (SP3) :huh2:.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#3 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,633 posts

Posted 14 June 2011 - 12:22 AM

Is it even possible as I found this "how to" in XP >> http://www.askvg.com/add-your-favorite-program-shortcut-in-desktop-context-menu-in-windows-xp/

Edited by guinness, 14 June 2011 - 12:22 AM.

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 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 9,521 posts

Posted 14 June 2011 - 12:22 AM

Not working on Vista either, but then these 2 are on their way out anyways. :huh2:

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#5 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,326 posts

Posted 14 June 2011 - 12:57 AM

Yep, Win7 only. I use this technique in ICU, but sadly you either have to have UAC disabled or run the script as Admin, because you need access to the HKEY_LOCAL_MACHINE reg-hive, which is restricted. Thanks for the appreciation :huh2:...

#6 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,250 posts

Posted 14 June 2011 - 01:08 AM

these 2 are on their way out anyways. :huh2:

I have to disagree.

Well, the first one (XP) definitly will not go out at least for next 5 years, and the second one (Vista)... hm, as far as i know/feel, it's never have been "in" ;)
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#7 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 9,521 posts

Posted 14 June 2011 - 01:13 AM

Just because people are still using Windows 95 doesn't mean it's still "in", same thing for XP in the next couple of years IMHO. But that's neither here nor there as far as the UDF goes, and no need to derail this any further.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#8 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,250 posts

Posted 14 June 2011 - 01:34 AM

Just because people are still using Windows 95 doesn't mean it's still "in", same thing for XP

You can't be serious really? :huh2:
Windows XP used by ~50% of all windows users, that's more than other systems all togheter, so make the math ;)

Edited by MrCreatoR, 14 June 2011 - 01:34 AM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#9 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,389 posts

Posted 14 June 2011 - 02:22 AM

Oldie but goodie! You should allow for the possibility to use another EXE's icon or a DLL or an ICO file (all should work). Currently you're forcing the target app for the icon. Also you need to allow for command line params, otherwise it's pretty useless as a context menu entry.

Edited by wraithdu, 14 June 2011 - 02:23 AM.


#10 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,633 posts

Posted 14 June 2011 - 10:27 AM

Currently you're forcing the target app for the icon.

Try this perhaps? >>

_ContextMenu_Install("Open md5hash", "md5hash", "C:\Program Files\Internet Explorer\iexplore.exe", 0)

Also you need to allow for command line params, otherwise it's pretty useless as a context menu entry.

Correct me if I'm wrong (which I could be sometimes) but I think this is a little different than adding to the entry "HKCR\md5hash\shell\open\command\" as this will only be shown when right clicking directly on the desktop/blank area of explorer or if you use the Extended parameter it will be shown when using Shift + Right Click. I found out the hard way yesterday by doing a little test and adding "%1" to the end of the FilePath :huh2: It didn't work, but I thought I would try it. Thanks wraithdu for testing too.

Global $sFilePath = "C:\Program Files\Internet Explorer\iexplore.exe" MsgBox(64, "Replace using %1 as the passed File.", StringReplace($sFilePath, '.exe', '.exe "%1"'))


Also KaFu I know/knew about ICU but I didn't copy from you scouts honour ;)

Edited by guinness, 14 June 2011 - 10:33 AM.

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


#11 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,389 posts

Posted 14 June 2011 - 01:41 PM

Aw crap, ur right. I forgot these shortcuts can't have params, my bad. But I still think you need a separate param for an icon that's not the target exe.

Although this page could just be missing something from your reply... I'm on my phone in a meeting right now.

#12 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,633 posts

Posted 14 June 2011 - 01:53 PM

But I still think you need a separate param for an icon that's not the target exe.

Do do you mean have Internet Explorer as the Icon?

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


#13 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,389 posts

Posted 15 June 2011 - 04:07 AM

I mean the icon registry key can be ANY exe, dll, or ico. It does not need to be the target exe's icon. So you should allow that the icon parameter to your function be a full path to another exe, ico, or dll (with index).

#14 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,633 posts

Posted 15 June 2011 - 08:12 AM

But I thought thats what I had already, I'm really confused as to why this doesn't work for you? >> From my previous post, this will change the icon to IE on my system.

_ContextMenu_Install("Open md5hash", "md5hash", "C:\Program Files\Internet Explorer\iexplore.exe", 0)

Edited by guinness, 15 June 2011 - 08:12 AM.

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


#15 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,389 posts

Posted 15 June 2011 - 01:24 PM

But doesn't this command open IE, while naming the entry 'Open md5hash'? It still uses the icon of whatever program you're opening. What if I want to open IE with a random shell32.dll icon?

Edited by wraithdu, 15 June 2011 - 01:25 PM.


#16 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,326 posts

Posted 15 June 2011 - 02:02 PM

Definitely possible, take a look at the ICU source. Heres the MSDN documentation ("In Windows 7 and later, cascading menu implementation is supported through registry settings."):
http://msdn.microsoft.com/en-us/library/cc144171%28VS.85%29.aspx#static_cascading

"Prior to Windows 7, the creation of cascading menus was possible only through the implementation of the IContextMenu interface." Maybe that's something for our AutoItObject team :huh2: ;)...
http://msdn.microsoft.com/en-us/library/bb776095%28v=VS.85%29.aspx

Edited by KaFu, 15 June 2011 - 02:07 PM.


#17 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,633 posts

Posted 15 June 2011 - 05:47 PM

wraithdu please except my apologies I wasn't thinking logically, perhaps tiredness was a huge factor?! I felt a little stupid when I was testing, it was an "of course!!" moment. I have updated the OP with your request.

Example of what you requested:
_ContextMenu_Install("Open md5hash", "md5hash", @ScriptDir & "\md5hash.exe", "C:\Program Files\Internet Explorer\iexplore.exe", 0)

Edited by guinness, 15 June 2011 - 05:49 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


#18 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,389 posts

Posted 15 June 2011 - 05:52 PM

No problem! You could also leave the icon as a single param, then check the passed type: if it's an integer, use the target exe for the icon with the integer as the index; if it's a string, assume it is a path to another exe, dll, or ico, and use that explicitly. It would require the user to manually append any index though.

#19 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,633 posts

Posted 15 June 2011 - 05:56 PM

It's another idea true, I will leave if for today and see what others think as well.

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


#20 coffeeturtle

coffeeturtle

    Wayfarer

  • Active Members
  • Pip
  • 90 posts

Posted 16 September 2011 - 04:08 PM

Thanks Guinness! This is just what I've been looking for.

In the last few months, have there been any updates that allow this to work on WinXP (and I guess Vista)?

Would be sweet if this functionality or your UDF is incorporated to the latest Beta of AutoIt that was released last weekend.

However, I want to add a function of the application I want to link to within the contextMenu.

For example, MyPlayerApp has functions where it can either add to queue or play. If I right click an MP3 file, I want it to expose the functions and allow you to choose either Add to Queue or PLAY in "MyPlayerApp", not just open the player.

I hope I am making sense.

Any help in pointing me in the right direction would be much appreciated.

Edited by coffeeturtle, 16 September 2011 - 04:22 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users