Search the Community
Showing results for tags 'programs'.
Found 3 results
Hi all. I am creating an app that runs a program with the admin privileges using the shellexecute's run as verb, but what my problem is, that no matter what I use to launch the program, it doesn't quite work like the run dialog would (certain programs don't get found, etc.). I've tried using the explorer.exe and passing the program to it, that is unreliable and opens documents folder sometimes instead, I've tried using the @comspec /c and that works better, but still some of the programs aren't being found that would be with the run dialog e.g., if I do @comspec /c diskpart it won't find it, I've even tried setting the working dir, but still no luck. I also tried passing commandline params to C:\WINDOWS\system32\rundll32.exe shell32.dll,#61, but no luck. can anyone help me what way to go in order to be able to launch programs in the run dialog style? is there a function in winapi that run dialog uses that I could use as well? Or what would be the best way to go about this? Any help much appreciated.
(The title of this example was originally "The Shell/Custom Favorites/Programs Menus".) This is an implementation of the Shell Favorites and Programs menus with the IShellMenu interface. The purpose of this menu system is to create a popup menu from a directory structure consisting of subfolders and internet or program links. The menu will look like the Favorites menu in Internet or Windows Explorer (as it looked when XP SP2 was released in August 2004). The IShellMenu interface can generally be used to create a menu from a directory structure. The menu items will be supplied with the same icons as the link files and they will be supplied with tooltips too. When you click a menu item the command associated with the internet or program link will be executed. The Favorites and Programs menus will create popup menus from the directory structures given by $CSIDL_FAVORITES, $CSIDL_PROGRAMS, $CSIDL_STARTMENU, $CSIDL_COMMON_PROGRAMS, $CSIDL_COMMON_STARTMENU. The Custom Favorites and Custom Programs menus can be used to create custom popup menus from custom directory structures. Note that the context (right click) menu is working in the Favorites menu. Update #4 2014-05-03: AutoIt 3.3.10 This example was created under 3.3.8 and based on APIConstants.au3 and WinAPIEx.au3 by Yashied. The original example runs under 3.3.10 without any changes at all. But a lot of unused constants and functions are included. In 3.3.10 the two UDFs are divided into several smaller UDFs. This makes it much easier to just include, what is needed. This update only includes the necessary UDFs. You find the new and old zip in bottom of the post. Update #3 2012-11-06: Programs menus Added the Programs menus from the directory structures given by $CSIDL_PROGRAMS, $CSIDL_STARTMENU, $CSIDL_COMMON_PROGRAMS, $CSIDL_COMMON_STARTMENU. To create a menu like the "All Programs" menu copy the two "Start Menu" folders (your own + "All Users") to the "Custom Programs 1" folder and overwrite the existing "Start Menu" folder. Then select the menu item "Custom Programs | Custom Programs 1". Update #2 2012-11-03: Custom Favorites menus If you are creating an AutoIt program and want to add a custom Favorites menu with relevant internet links all you have to do is to create a directory structure, add the subfolders (optional) and links and call the ShowFavsProgsMenu() function with a path to the directory. And you will get a menu that looks like and works like the Favorites menu in Internet Explorer. You can see two custom Favorites menus in the examples. Added two small directory structures to the zip to be used for the custom Favorites menus. Fixed an error: OleInitialize() is used to initialize COM in stead of CoInitialize() (necessary to make the Copy command in the context menu work). Update #1 2012-11-01: Window procedure Because a popup menu like the Favorites menu is modal, it's necessary to use some kind of a window procedure to catch the menu messages. When it's a popup menu it should be enough to have the window procedure running while the popup menu is displayed. In the original scripts the window procedure was created with these commands: $hNewWinProc = DllCallbackRegister( "NewWindowProc", "int", "hwnd;uint;wparam;lparam" ) ; New window procedure $hOldWinProc = _WinAPI_SetWindowLong( $hGui, $GWL_WNDPROC, DllCallbackGetPtr( $hNewWinProc ) ) ; Old window procedureThe procedure was started in the main script in the example and was running as long as the script was running. In this update the menu messages is catched with a hook procedure: $hFavMenuMsg = DllCallbackRegister( "FavMenuMsg", "long", "int;wparam;lparam" ) $hFavMenuMsgHook = _WinAPI_SetWindowsHookEx( $WH_MSGFILTER, DllCallbackGetPtr( $hFavMenuMsg ), 0, _WinAPI_GetCurrentThreadId() ) ; $WH_MSGFILTER installs a hook procedure that monitors messages generated as a ; result of an input event in a dialog box, message box, menu, or scroll bar.The procedure is started in the bottom of the ShowFavoritesMenu() function immediately after the Favorites menu is displayed on the screen, and the procedure is stopped when the menu disappears from the screen. Either because the menu is cancelled or a selection is made. (If you comment out these commands in ShellFavoritesMenu.au3 the Favorites menu will still show up. But the submenus will not be expanded if you keep the mouse steady over a submenu or use the arrow keys.) This hook procedure is much better than the original window procedure. It's much easier to integrate the Favorites menu in other programs when it isn't depending on a "global" window procedure. A "global" window procedure can also have some influence on the GUI (at least on XP, I think it's better on 7). In the original example you saw it clearly when the GUI lost focus. When the GUI got focus back the upper line of the edit box could be behind the toolbar. This is not a problem with a hook procedure only running when the Favorites menu is displayed. Added an example with a menu. Zip updated. First post 2012-10-30 This is an implementation of the Favorites menu primary with the IShellMenu interface but several other interfaces are used as well. The main function: Func ShowFavoritesMenu( $hWnd, $hMenu, $xCoord, $yCoord ) ; --- Create a menu band object and the IShellMenu interface --- Local $oIShellMenu, $pIShellMenu ; Create a menu band object and get a pointer to the IShellMenu interface CoCreateInstance( $tCLSID_MenuBand, $NULL, $CLSCTX_INPROC_SERVER, $tRIID_IShellMenu, $pIShellMenu ) $oIShellMenu = ObjCreateInterface( $pIShellMenu, $sIID_IShellMenu, $dtag_IShellMenu ) If Not IsObj( $oIShellMenu ) Then Return SetError(1,0,0) ; --- Initialize the interface --- If $oIShellMenu.Initialize( $NULL, -1, $ANCESTORDEFAULT, BitOR( $SMINIT_TOPLEVEL, $SMINIT_VERTICAL ) ) <> $S_OK Then Return SetError(2,0,0) ; --- Specify the folder for the menu band to browse --- ; Get a pointer to the IShellFolder interface for the desktop Local $pIShellFolder = $NULL, $oIShellFolderDesktop, $pIShellFolderDesktop, $pidlRel SHGetDesktopFolder( $pIShellFolderDesktop ) SHGetSpecialFolderLocation( $NULL, $CSIDL_FAVORITES, $pidlRel ) $oIShellFolderDesktop = ObjCreateInterface( $pIShellFolderDesktop, $sIID_IShellFolder, $dtag_IShellFolder ) $oIShellFolderDesktop.BindToObject( $pidlRel, $NULL, $tRIID_IShellFolder, $pIShellFolder ) If $pIShellFolder = $NULL Then Return SetError(3,0,0) ; Get the registry key with the "Order" value of the Favorites folder Local $hRegOrder = _WinAPI_RegOpenKey( $HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites", $KEY_READ ) If $hRegOrder = 0 Then Return SetError(4,0,0) ; Specify the folder for the menu band to browse If $oIShellMenu.SetShellFolder( $pIShellFolder, $pidlRel, $hRegOrder, BitOR( $SMSET_BOTTOM, $SMSET_USEBKICONEXTRACTION ) ) <> $S_OK Then Return SetError(5,0,0) _WinAPI_CoTaskMemFree( $pidlRel ) _WinAPI_RegCloseKey( $hRegOrder ) ; --- Append a static menu to the menu band --- If $oIShellMenu.SetMenu( $hMenu, $hWnd, $SMSET_TOP ) <> $S_OK Then Return SetError(6,0,0) ; --- Get access to IMenuPopup, IDeskBar and IDeskBand interfaces --- Local $pIMenuPopup, $pIDeskBar, $pIDeskBand ; The IMenuPopup interface If $pIShellMenu Then If $oIShellMenu.QueryInterface( $tRIID_IMenuPopup, $pIMenuPopup ) <> $S_OK Then Return SetError(7,0,0) EndIf ; The IDeskBar interface If $pIMenuPopup Then Local $oIMenuPopup = ObjCreateInterface( $pIMenuPopup, $sIID_IMenuPopup, $dtag_IMenuPopup ) If $oIMenuPopup.QueryInterface( $tRIID_IDeskBar, $pIDeskBar ) <> $S_OK Then Return SetError(8,0,0) EndIf ; The IDeskBand interface If $pIDeskBar Then Local $oIDeskBar = ObjCreateInterface( $pIDeskBar, $sIID_IDeskBar, $dtag_IDeskBar ) If $oIDeskBar.QueryInterface( $tRIID_IDeskBand, $pIDeskBand ) <> $S_OK Then Return SetError(9,0,0) EndIf ; --- Create a menu desk bar object and the IMenuPopup interface --- Local $oIUnknown, $pIUnknown, $oIMenuPopup, $pIMenuPopup ; Create a menu desk bar object and get a pointer to the IUnknown interface CoCreateInstance( $tCLSID_MenuDeskBar, $NULL, $CLSCTX_INPROC_SERVER, $tRIID_IUnknown, $pIUnknown ) $oIUnknown = ObjCreateInterface( $pIUnknown, $sIID_IUnknown, $dtag_IUnknown ) ; Create the IMenuPopup interface $oIUnknown.QueryInterface( $tRIID_IMenuPopup, $pIMenuPopup ) $oIMenuPopup = ObjCreateInterface( $pIMenuPopup, $sIID_IMenuPopup, $dtag_IMenuPopup ) If Not IsObj( $oIMenuPopup ) Then Return SetError(10,0,0) ; --- Create a menu band site object and the IBandSite interface --- Local $oIBandSite, $pIBandSite ; Create a menu band site object and get a pointer to the IBandSite interface CoCreateInstance( $tCLSID_MenuBandSite, $NULL, $CLSCTX_INPROC_SERVER, $tRIID_IBandSite, $pIBandSite ) $oIBandSite = ObjCreateInterface( $pIBandSite, $sIID_IBandSite, $dtag_IBandSite ) If Not IsObj( $oIBandSite ) Then Return SetError(11,0,0) ; --- Set the band site object as client for the desk bar object --- If $oIMenuPopup.SetClient( $pIBandSite ) <> $S_OK Then Return SetError(12,0,0) ; --- Add the desk band object to the band site object --- If $oIBandSite.AddBand( $pIDeskBand ) <> $S_OK Then Return SetError(13,0,0) ; --- Show the Favorites menu --- Local $tPOINT = DllStructCreate( $tagPOINT ) DllStructSetData( $tPOINT, "X", $xCoord ) DllStructSetData( $tPOINT, "Y", $yCoord ) Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, "Left", $xCoord ) DllStructSetData( $tRECT, "Top", $yCoord+1 ) DllStructSetData( $tRECT, "Right", $xCoord ) DllStructSetData( $tRECT, "Bottom", $yCoord+1 ) $oIMenuPopup.Popup( $tPOINT, $tRECT, $MPPF_ALIGN_RIGHT ) ; --- Create the IMenuBand interface --- Local $oIDeskBand $oIDeskBand = ObjCreateInterface( $pIDeskBand, $sIID_IDeskBand, $dtag_IDeskBand ) $oIDeskBand.QueryInterface( $tRIID_IMenuBand, $pIMenuBand ) $oIMenuBand = ObjCreateInterface( $pIMenuBand, $sIID_IMenuBand, $dtag_IMenuBand ) If Not IsObj( $oIMenuBand ) Then Return SetError(14,0,0) ; $oIMenuBand and $pIMenuBand are global variables ; $oIMenuBand is used to handle the messages from the Favorites menu in the function below ; $pIMenuBand is used to test if the Favorites menu is open ($pIMenuBand <> $NULL) Return 0 EndFunc Example The zip contains the example as you can see in the picture. There are two versions of the example: A version based on a toolbar (ExShellFavsProgsMenus.au3), and a version based on a menu bar (ExShellFavsProgsMenus2.au3). The purpose of the text box is just to have something to put in the window. The zip contains also the ShellFavsProgsMenus.au3 UDF. This zip contains the original scripts for 3.3.8. You need APIConstants.au3 and WinAPIEx.au3 by Yashied. The UDFs are not included in the zip. The zip can be opened with 7-Zip. ShellFavsProgsMenus.zip This zip contains the updated scripts for 3.3.10. Only a matter of UDFs. These scripts will not run under 3.3.8. TheFavoritesMenu.7z Testet on XP 32 bit and Win 7 32/64 bit.
My first project outside of work Since I have literally hundreds of games and programs installed on my pc, even using the start menu can get me lost when looking for a specific thing. With this, you can drag/drop any file or shortcut onto the GUI. Then you can open any file from the convienient GUI sitting on your desktop. 5 different "tabs" or lists allow you to sort and organize your files to make them easier to find when your lists get long. Latest Version 18.104.22.168<-11/8/13 (or 8/11/13 for the European people) You can get the included help file here for a more indepth look at what this program can do and how it works. I've removed the purchase requirement (it's free again) and added a donate button to the installer. Bugs, suggestions and comments are welcome!