; IDEA : script which popup browse dialog and generate shortcut ; http://www.donationcoder.com/Forums/bb/index.php?topic=14493.0 #Persistent #SingleInstance force #NoEnv ;#NoTrayIcon ;the user choose a folder, and it generate a shortcut (on his desktop) and add the choosen folder's path to the shortcut DetectHiddenWindows, On SendMode, Input appname=Choose_n_Create vernum=1.05 INI_File=%appname%.ini GoSub, Get_INI If notraymenu=1 Menu, tray, NoIcon Else Gosub, Menu GoSub, Get_Folder Return Get_INI: IfNotExist, %INI_File% { comments= comments=`;%A_Space%Ini settings for "%appname%" script. comments=%comments%`n`;%A_Space% comments=%comments%`n`;%A_Space%This file contains some of the configurable settings. comments=%comments%`n`;%A_Space%-------------------------------------- comments=%comments%`n`;%A_Space%Note: 'IconNumber' is only relevant if specifying icon from an EXE or DLL file. comments=%comments%`n`; FileAppend,%comments%,%INI_File% firsttime=1 browsedlgtext=Select a folder that is to be processed. Note: A shortcut will be created on the Desktop. apppath= shortcutname= iconfilepath= iconnumber= filepattern= param1= param2= param3= notraymenu=0 IniWrite,%firsttime%,%INI_File%,Settings,FirstTime IniWrite,%browsedlgtext%,%INI_File%,Settings,BrowseDlgText IniWrite,%apppath%,%INI_File%,Settings,AppPath IniWrite,%shortcutname%,%INI_File%,Settings,ShortcutName IniWrite,%iconfilepath%,%INI_File%,Settings,IconFilePath IniWrite,%iconnumber%,%INI_File%,Settings,IconNumber ;if specifying icon from an EXE or DLL file IniWrite,%filepattern%,%INI_File%,Settings,FilePattern IniWrite,%param1%,%INI_File%,Settings,Param1 IniWrite,%param2%,%INI_File%,Settings,Param2 IniWrite,%param3%,%INI_File%,Settings,Param3 IniWrite,%notraymenu%,%INI_File%,Settings,NoTrayMenu } Else ;INI file exists, read from it { IniRead,firsttime,%INI_File%,Settings,FirstTime,0 IniRead,browsedlgtext,%INI_File%,Settings,BrowseDlgText,0 IniRead,apppath,%INI_File%,Settings,AppPath IniRead,shortcutname,%INI_File%,Settings,ShortcutName IniRead,iconfilepath,%INI_File%,Settings,IconFilePath IniRead,iconnumber,%INI_File%,Settings,IconNumber IniRead,filepattern,%INI_File%,Settings,FilePattern IniRead,param1,%INI_File%,Settings,Param1 IniRead,param2,%INI_File%,Settings,Param2 IniRead,param3,%INI_File%,Settings,Param3 IniRead,notraymenu,%INI_File%,Settings,notraymenu,0 } If firsttime=1 { IniWrite,0,%INI_File%,Settings,FirstTime MsgBox, 64, %appname%, This seems to be the first time this program has been executed. `nPlease check the contents of the ini file and make your changes `naccordingly. RunWait, edit %INI_File%, , UseErrorLevel If ErrorLevel = ERROR RunWait, %INI_File%, , UseErrorLevel GoSub, Get_INI } Return Get_Folder: FileSelectFolder, selFolder, , 3, %browsedlgtext% If selFolder = { Return } Else { selFolder := RegExReplace(selFolder, "\\$") ; No trailing backslash SplitPath, selFolder, getFileName, getDir, getExtension, getNameNoExt ;Msgbox shortcutname = %shortcutname% If shortcutname = MyLinkPath=%A_Desktop%\Process '%getNameNoExt%' Folder.lnk Else MyLinkPath=%A_Desktop%\%shortcutname% - '%getNameNoExt%'.lnk MyArgs="%selFolder%\%filepattern%" "%selFolder%" %param1% %param2% %param3% SplitPath, iconfilepath, , , getExt ;to see if ico If getExt = ico FileCreateShortCut, %apppath%, %MyLinkPath%, %selFolder%,%MyArgs%,,%iconfilepath% Else ; use only if there if it is not a ico file FileCreateShortCut, %apppath%, %MyLinkPath%, %selFolder%,%MyArgs%,,%iconfilepath%,,%iconnumber% ;notraymenu - non-persistent If notraymenu=1 { Sleep, 1000 GoSub, ExitSub } } Return Menu: Menu, tray, NoStandard Menu, tray, DeleteAll Menu, tray, Tip, %appname% v%vernum% IfExist %A_WorkingDir%\Foood_Bulb.ico Menu, tray, Icon, %A_WorkingDir%\Foood_Bulb.ico Menu, tray, Add, Choose_n_Create, LaunchApp Menu, tray, Add, Modify INI file, EditINI Menu, tray, Add, Menu, tray, Add, About this program, DC-Forum Menu, tray, Add, Exit, EXIT Menu, tray, Default, Choose_n_Create Return DC-Forum: MsgBox, 36, %appname%, Do you wish to visit DonationCoder.com forum to post a feedback about this program? IfMsgBox Yes Run, http://www.donationcoder.com/Forums/bb/index.php?topic=14493.new#new Return EditINI: RunWait, edit %INI_File%, , UseErrorLevel If ErrorLevel = ERROR RunWait, %INI_File%, , UseErrorLevel Return LaunchApp: GoSub, Get_INI GoSub, Get_Folder Return ExitSub: EXIT: ExitApp Return