robertcollier4 Posted June 13, 2013 Share Posted June 13, 2013 (edited) Scenario: Editing .lnk shortcuts with the Windows dialog is very frustrating due to the small input boxes and non-resizable small dialog window. Very often you need to create a link with a long path and many arguments which becomes hard to see and make edits. Solution: LNKEditorGUI is a resizable and easy to use creator and editor of LNK Windows Shortcut files. This GUI uses built-in AutoIt functions FileGetShortcut() and FileCreateShortcut() to read and write .lnk files. A nice and big (and resizable) GUI is presented with which the user can easily edit and create LNK shortcuts with. A command line argument is accepted and the GUI will automatically open the first file passed to it as an argument allowing for easy association on the right-click menu (see .lnk file right-click context menu registry association example below). Download:LNKEditorGUI.zip Screenshot: Reg Script Use a Registry Script such as following to create a right-click menu entry for LnkEditorGUI for .lnk files. Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\lnkfile\shell\LNKEditorGUI] @="LNK&EditorGUI" [HKEY_CLASSES_ROOT\lnkfile\shell\LNKEditorGUI\command] @="\"C:\\Program Files\\LNKEditorGUI.exe\" \"%1\"" LNKEditorGUI.au3 Code: expandcollapse popup#include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #include <GuiStatusBar.au3> #include <Timers.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Global Const $CmbWinstateNorm = @SW_SHOWNORMAL & " - Normal Window" Global Const $CmbWinstateMin = @SW_SHOWMINNOACTIVE & " - Minimized" Global Const $CmbWinstateMax = @SW_SHOWMAXIMIZED & " - Maximized" #region - GUI $GUI = GUICreate("LNKEditorGUI - Windows Shortcut LNK File Editor", 800, 640, -1, -1, BitOr($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX ), $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_CLOSE, '_exit') GUISetOnEvent($GUI_EVENT_DROPPED, "On_Drop_InFilename") GUISetFont(10) $Status = _GUICtrlStatusBar_Create($GUI) GUICtrlCreateLabel("File:", 4, 6, 36, 24) $inFilename = GUICtrlCreateInput("", 36, 4, 672, 24) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $btBrowseForFile = GUICtrlCreateButton("Browse...", 712, 4, 84, 24) GUICtrlSetOnEvent(-1, '_btBrowseForFile') $btOpenFile = GUICtrlCreateButton("Load LNK File", 20, 32, 370, 28) GUICtrlSetOnEvent(-1, '_btOpenFile') GUICtrlSetResizing($btOpenFile, $GUI_DOCKLEFT) $btSaveFile = GUICtrlCreateButton("Save LNK File", 410, 34, 370, 28) GUICtrlSetOnEvent(-1, '_btSaveFile') GUICtrlSetResizing($btSaveFile, $GUI_DOCKRIGHT) GUICtrlCreateLabel("Target EXE", 4, 80, 172, 24) $inTargetEXE = GUICtrlCreateInput("", 4, 104, 792, 24) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateLabel("Target Arguments", 4, 148, 172, 24) $editTargetArgs = GUICtrlCreateEdit("", 4, 172, 792, 96, $ES_MULTILINE) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateLabel("Working Dir", 4, 288, 172, 24) $inWorkingDir = GUICtrlCreateInput("", 4, 312, 792, 24) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateLabel("Window State", 4, 356, 172, 24) $cmbWindowState = GUICtrlCreateCombo("", 4, 380, 792, 24, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, $CmbWinstateNorm & "|" & $CmbWinstateMin & "|" & $CmbWinstateMax, $CmbWinstateNorm) ; add other item snd set a new default GUICtrlCreateLabel("Icon File", 4, 424, 172, 24) $inIconFile = GUICtrlCreateInput("", 4, 448, 650, 24) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateLabel("Icon Index", 680, 424, 172, 24) $inIconIndex = GUICtrlCreateInput("", 674, 448, 112, 24) GUICtrlCreateLabel("Comment", 4, 492, 172, 24) $editComment = GUICtrlCreateEdit("", 4, 516, 792, 96, $ES_MULTILINE) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW, $GUI) #endregion - GUI If $CmdLine[0] > 0 Then ;MsgBox(0,0,$CmdLine[1]) GUICtrlSetData($inFilename, $CmdLine[1]) _btOpenFile() EndIf While 1 Sleep(100) WEnd ;--------------------------------------------------------------- Func StatusBarNotify($msg) _GUICtrlStatusBar_SetText($Status, $msg) _Timer_SetTimer($GUI, 5000, "_ClearStatusBar") EndFunc ;--------------------------------------------------------------- Func _ClearStatusBar($hWnd, $msg, $iIDTimer, $dwTime) #forceref $hWnd, $msg, $iIDTimer, $dwTime _GUICtrlStatusBar_SetText($Status, "") _Timer_KillTimer($hWnd, $iIDTimer) EndFunc ;--------------------------------------------------------------- Func _btBrowseForFile() Local $var = FileSaveDialog("Choose a LNK File Name", "D:\", "LNK Shortcuts (*.lnk)", 2) ; option 2 = dialog remains until valid path/file selected If @error Then ;MsgBox(4096, "", "No File(s) chosen") Else $var = StringReplace($var, "|", @CRLF) GUICtrlSetData($inFilename, $var) EndIf EndFunc ;--------------------------------------------------------------- Func On_Drop_InFilename() If ( (@GUI_DropId = $inFilename) OR (@GUI_DropId = $inTargetEXE) ) Then GUICtrlSetData(@GUI_DropId, @GUI_DragFile) EndIf If ( (@GUI_DropId = $inFilename) AND (@GUI_DragFile <> "") ) Then OpenFile(@GUI_DragFile) EndIf EndFunc ;--------------------------------------------------------------- Func _btOpenFile() Local $filename = GUICtrlRead($inFilename) If $filename = "" Then ;_btBrowseForFile() ;$filename = GUICtrlRead($inFilename) StatusBarNotify("ERROR: Trying to open file but no file specified.") MsgBox(0,"ERROR","Trying to open file but no file specified.") Else OpenFile($filename) EndIf EndFunc ;--------------------------------------------------------------- Func OpenFile($filename) Local $lnkArray = FileGetShortcut($filename) If Not @error Then ;_ArrayDisplay($lnkArray) Else StatusBarNotify("ERROR: Unable to open file.") MsgBox(0,"ERROR","Unable to open file, please check the file name.") Return EndIf GUICtrlSetData($inTargetEXE, $lnkArray[0]) GUICtrlSetData($editTargetArgs, $lnkArray[2]) GUICtrlSetData($inWorkingDir, $lnkArray[1]) GUICtrlSetData($inIconFile, $lnkArray[4]) GUICtrlSetData($inIconIndex, $lnkArray[5]) GUICtrlSetData($editComment, $lnkArray[3]) If($lnkArray[6] = @SW_SHOWNORMAL) Then GUICtrlSetData($cmbWindowState, $CmbWinstateNorm) ElseIf($lnkArray[6] = @SW_SHOWMINNOACTIVE) Then GUICtrlSetData($cmbWindowState, $CmbWinstateMin) ElseIf($lnkArray[6] = @SW_SHOWMAXIMIZED) Then GUICtrlSetData($cmbWindowState, $CmbWinstateMax) EndIf StatusBarNotify("Successfully loaded file: " & $filename) EndFunc ;--------------------------------------------------------------- Func _btSaveFile() $filename = GUICtrlRead($inFilename) If $filename = "" Then StatusBarNotify("ERROR: Trying to save but no file name specified.") MsgBox(0,"ERROR","Trying to save but no file name specified.") Return EndIf Local $WinStateToWrite Switch GuiCtrlRead($cmbWindowState) Case $CmbWinstateNorm $WinStateToWrite = @SW_SHOWNORMAL Case $CmbWinstateMin $WinStateToWrite = @SW_SHOWMINNOACTIVE Case $CmbWinstateMax $WinStateToWrite = @SW_SHOWMAXIMIZED Case Else $WinStateToWrite = @SW_SHOWNORMAL EndSwitch $saveResult = FileCreateShortcut(GuiCtrlRead($inTargetEXE), $filename, GuiCtrlRead($inWorkingDir), GuiCtrlRead($editTargetArgs), GuiCtrlRead($editComment), GuiCtrlRead($inIconFile), "", GuiCtrlRead($inIconIndex), $WinStateToWrite) If($saveResult) Then StatusBarNotify("Successfully saved file to: " & $filename) Else StatusBarNotify("ERROR: Unable to save file, please check the file name and values.") MsgBox(0,"ERROR","Unable to save file, please check the file name and values.") EndIf EndFunc ;--------------------------------------------------------------- Func _exit() Exit EndFunc ;--------------------------------------------------------------- Edited November 27, 2013 by Jon jaberwacky, mLipok and Earthshine 3 Link to comment Share on other sites More sharing options...
robertcollier4 Posted June 14, 2013 Author Share Posted June 14, 2013 (edited) FYI - this tool is very good with and was inspired by my use of hstart. Highly recommended:http://www.ntwind.com/software/hstart.html For example, with hstart.exe you can launch multiple BAT files or EXE commands to run in parallel and without showing console with the /NOCONSOLE command, for example, this launches 3 batch files with multiple arguments (and without ever showing any windows): hstart.exe /NOCONSOLE ""C:\program files\folderblue\processblue.bat" "blue arg 1" "blue arg 2" "blue arg 3"" ""C:\program files\folderred\processred.bat" "red arg 1" "red arg 2" "red arg 3"" ""C:\program files\foldergreen\processgreen.bat" "green arg 1" "green arg 2" "green arg 3"" Notice how this lnk file would get very unwieldy for the Windows edit properties dialog but LNKEditorGUI would handle it with ease. Edited June 14, 2013 by robertcollier4 Link to comment Share on other sites More sharing options...
trybowski Posted July 25, 2013 Share Posted July 25, 2013 Hello! Nice one! It's understandable, that this editor only allows editing certain, limited range of LNK properties. The problem is that it removes all other properties form a LNK file. I'm especially focused on console properties, which are removed altogether. It's easily reproducible: create an LNK file in Windows, set some console properties (custom font, custom colors). Then open the LNK file in LNKEditorGUI and save it. The console properties are now gone, you can easily see this by editing the LNK again in Windows. Could this be fixed? Also, could the editor be extended to allow edititng of console properties? Rgds, KT Link to comment Share on other sites More sharing options...
Ascend4nt Posted July 25, 2013 Share Posted July 25, 2013 trybowski, those settings aren't saved in the shortcut (.LNK) file itself. Look in the registry at this key: HKEY_CURRENT_USERConsole That key gets updated with each change you make to a shortcut. Older versions of Windows that emulated DOS used a .PIF file to save extra information. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
JonnyHotchkiss Posted March 13, 2015 Share Posted March 13, 2015 Hi, nice app! So, this can be used to create .lnks via command, ie a context menu entry? I don't like having to right-click on the Favorites (%sysdrive%users%username%LINKS) icon / whitespace in Explorer's navigation pane... I've experimented with junctions etc, and it works... but not as well as a DeskLink file would [like the Desktop (create shortcut).DeskLink Desklink in Sendto] Creating .DeskLinks is a bit out of my league... could this be added in?!!?! Thanks Link to comment Share on other sites More sharing options...
wernerml Posted May 29, 2015 Share Posted May 29, 2015 AMAZING!!!!!!Thanks brow! Link to comment Share on other sites More sharing options...
Lilinote Posted October 27, 2015 Share Posted October 27, 2015 Hey there.I'm sorry to up an old thread.Thanks for your tool.I would like to know, is there a way (with this actual tool or in another way) to create a shortcut .lnk who could open 2 files ? For example 2 .html files, or 2 .jpeg files ?I don't want to use a .bat to do that. I want to use a .lnk if it's possible.Thanks a lot for your feedback and your advices.Have a good day.L Link to comment Share on other sites More sharing options...
mLipok Posted October 27, 2015 Share Posted October 27, 2015 @robertcollier4Thanks for sharing. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
gwinter Posted December 27, 2017 Share Posted December 27, 2017 For JonnyHotchkiss and Lilinote, and any others customizing/improving their 'Windows Experience', I came on this web page to find out more about *.lnks, and refresh my memory about how windows uses them. What I wanted to say though was don't forget that you can make your own file-type. It will function exactly how you want and be totally accessible and changeable to you. It can be as simple as a *.txt file with a new made-up extension (like MyLink.luk). I have found that it is better (and sometimes easier) to set up your own control-systems in Windows, keep Windows out of it and you won't tie up Windows by distracting it. For example, I have written Windows-Interface software that runs applications and performs Windows-related functions way faster than explorer, by average, what it takes Windows five seconds to do, my software does in 1 second. For LiliNote, it seems Windows set it up 'one link per LNK', so unless you want to start rewriting system files, you could do what I've done before, make a file that has a list of files to open, you could even include other info AU3 could read, like pictures to go along with media files or documents. I got sick of Windows taking up so much space/time with indexing, file-linking and all the other 'managerial' stuff Windows does. A lot of the times Windows seems to fail/lag at all that anyways. I ended up writing an AU3 'system manager' that would run at start-up, keep a data-base of only the files I would use (not like Windows keeping track of everything numerous times), allowing me to associate my own album art to any media file, perform custom tasks before running a specific app, open certain LNK's or URL's in custom-layout windows, etc. Anyways, back to the 'opening 2 files at once' thing, what you could do is make a file type that contains different headings using an unreserved and unused character, and even add different commands like this: ThemeLinks.luk (a new link file type *.luk) ~FilesToOpen C:\Windows\Desktop\Theme.jpg C:\Users\AppData\ThemePage.url ~FilesToDelete C:\Windows\Desktop\Theme2.jpg The above is an example of a new custom 'LNK', maybe named ThemeLinks.luk, and it is set to "Open With..." MySystemCONT.exe (which is an auto-it exe) which uses "$PassedLUK = $CmdLine[1]" to store the name(and path) of the shortcut passed (in this example '$PassedLUK = "C:\Windows\Desktop\ThemeLinks.luk". MySystemCONT does not even need to sit in the background, whenever a *.luk is opened, Explorer sends the LUK to MySystemCONT.exe, which reads it (looking for the "~" symbol) and performs whatever is listed. I added a ~FilesToDelete for example to also delete a file(if it exists) every time the LUK is opened. You could make any format or process the links however you want. I had a link that would open up all my necessary folders, software and text files for game-programming, even waiting before opening some links. Just an idea to you guys and others, to think outside of the box, or the Window. Link to comment Share on other sites More sharing options...
gwinter Posted December 27, 2017 Share Posted December 27, 2017 You can keep building to it, give it a context menu, add it into the Windows registry, it can make custom links to whatever and send those 'shortcuts' to anywhere (even send them online via GMail or upload-script). Link to comment Share on other sites More sharing options...
gwinter Posted December 27, 2017 Share Posted December 27, 2017 You can keep building to it, give it a context menu, add it into the Windows registry, it can make custom links to whatever and send those 'shortcuts' to anywhere (even send them online via GMail or upload-script). Just recently, I added Window's ClipBoard monitoring to MySysCONT, so it can divert email SENDTOs, quickly and silently collect a list of url's I copy, and even opening Google Chrome(while keeping it hidden) so I can access the Hangouts Extension when a phone number is copied to the clipboard. The Hangouts extension lets you make a call, but can't be opened unless Chrome is opened first, so until I can find a better way, I use AutoIt to bypass. It can mute/adjust audio before calling, etc. You are only limited by your imagination... Link to comment Share on other sites More sharing options...
sl23 Posted November 3 Share Posted November 3 (edited) Some of the best tools seem to be here! I have desperately been searching the web for something like this. I tried the Shortcuts Search and Replace tool, but it's really shifty, doesn't load a folder full of shortcuts, won't replace half the time and is really not easy to work out how to use. Then I found this, it looks like it could be the answer... if it worked!!! Any chance it could be updated? Everytime I run it, either directly from AutoIT as a script or after compiling, it just shuts down. Any idea why? Do I need to compile with an older version of AutoIT? Thanks Edited Monday at 02:27 PM by sl23 Link to comment Share on other sites More sharing options...
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