Ascend4nt Posted August 3, 2010 Share Posted August 3, 2010 (edited) _FileGetShortcutEx This UDF will return shortcut (.LNK) file information for more advanced shortcuts that AutoIt's built-in FileGetShortcut() chokes on. The following types of shortcuts can be retrieved using this function: MSI Advertised Shortcuts URL (website) Shortcuts that are embedded (rather than put in a .URL file) Special GUID Shell Item Shortcuts. This is only one level deep at the moment, so it will only read the base Folder GUID (For example: shortcuts to 'My Computer', 'Recycle Bin' return fine) UNC Shortcuts ("PCNAME"). This is also only one level deep currently, so "PCNAMEFolder" shortcuts will fail (as well as regular shortcuts, of course) Operation is simple: call '_FileGetShortcutEx("filename")' to get an array that is arranged the same as FileGetShortcut(). Included in the ZIP are two examples of shortcuts that AutoIt will fail on, but this function will work on. I don't have any MSI Advertised shortcut examples, but I believe Microsoft Office and ACDSee shortcuts both use these shortcuts types which return wonky results using AutoIt's function. Thanks go out to Prog@ndy for the original '_FileGetShortcutEx' function and MSI shortcut code (which I converted for Unicode). See my original post here for his code. *Shortcut Key retrieval* This was requested on the Help board, and I thought it was a good idea to include it here. If you need to grab a shortcut's associated Shortcut Key, you can use the below code, assuming you already know beforehand that the file is a shortcut file: $sShortcutFile = "C:\MyShortcut.lnk" $nShortcutKey = Number(StringToBinary(StringMid(FileRead($sShortcutFile, 68), 65, 4))) ConsoleWrite("Shortcut key = " & $nShortcutKey & @CRLF) The format of the key is described under IShellLink::GetHotkey, and I've included code that converts most key combos in >this post.*Special note on 'Normal' Internet shortcuts: While this UDF only looks at .LNK shortcuts (what you use FileGetShortcut() with), some confuse .URL Internet shortcuts with these types, so I decided I'd put a solution for those interested on how to get a URL Internet shortcut. It's actually so simple it can be done in one line, so here it is (note the .URL extension): $sURL=IniRead(@UserProfileDir&"\Favorites\Google.URL","InternetShortcut","URL","") Ascend4nt's AutoIT Code License agreement: no license - just be a good person and credit other people for their work, yeh? Download the ZIP from my site Edited July 25, 2013 by Ascend4nt Inverted 1 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...
KaFu Posted August 3, 2010 Share Posted August 3, 2010 Snatched , just gimme 10 minutes to integrate it into the next SMF release . OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Ascend4nt Posted August 3, 2010 Author Share Posted August 3, 2010 haha you're fast. Bear in mind this was sort of an old script, and I didn't do much in the way of cleanup. I just decided to post it as-is since I wanted to help someone out. Didn't think it'd be of much use to anyone else, but l guess I was wrong 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...
Ascend4nt Posted July 25, 2013 Author Share Posted July 25, 2013 Semi-sorta update: Included code in the 1st post to read the shortcut key from a shortcut file. Also, I have a few >Key-To-String functions on the Help Forum that work with translating most shortcut key combinations. 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...
odaylton Posted November 26, 2016 Share Posted November 26, 2016 Translated by Google. Sorry for any mistakes. I made a post here showing in practice this feature I hope you enjoy Link to comment Share on other sites More sharing options...
odaylton Posted February 15, 2017 Share Posted February 15, 2017 Text translated from Portuguese by google - please apologize for any errors I would firstly like to thank the initiative to spread this knowledge ... I noticed a small flaw in the routine regarding the variable "$ bExpandEnvStrings" which in some cases I used it with the value "TRUE" but I noticed that the answers were not always correct, but with the variables of DOS% XXX% And also in Windows 7 the shortcuts of the games provided by microsoft were not found but the location of the icons did I hope that if possible try to solve the game case in a less simplistic way Then include the lines below expandcollapse popupFunc _FileGetShortcutEx($sLNKFile, $bExpandEnvStrings = False) Local $aShortcutInfo[7] $aShortcutInfo = FileGetShortcut($sLNKFile) ;The array returned from this function is a single dimension array containing the following elements: ;$aArray[0] = Shortcut target path ;$aArray[1] = Working directory ;$aArray[2] = Arguments ;$aArray[3] = Description ;$aArray[4] = Icon filename ;$aArray[5] = Icon index ;$aArray[6] = The shortcut state (@SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE, @SW_SHOWMAXIMIZED) ; MsgBox(0,"LNK","0:" & $aShortcutInfo[0] & @CRLF & "1:" & $aShortcutInfo[1] & @CRLF & _ ; "2:" & $aShortcutInfo[2] & @CRLF & "3:" & $aShortcutInfo[3] & "4:" & $aShortcutInfo[4]) If @error Then SetError(@error, 0) ;17/02/15 incrementei isso If $bExpandEnvStrings Then _ArrayExpandEnvStr($aShortcutInfo, 0, 4) Return $aShortcutInfo EndIf Local $msitest = _MSIShortcutTarget($sLNKFile) If Not @error Then $aShortcutInfo[0] = $msitest ; Shortcut STILL not yielding correct results? ; NOTE: Please use Unicode so that Unicode shortcuts are read/processed properly! If $aShortcutInfo[0] = "" Then ; Try to see if its a special UNC-only, URL-only, or GUID-only LNK file Local $sResult = _FileGetGUIDShortcuts($sLNKFile) ;AutoIt_Debugger_Command:Enable_Debug If $sResult <> "" Then $aShortcutInfo[0] = $sResult Else ;17/02/15 incrementei isso If $aShortcutInfo[4] <> "" Then $aShortcutInfo[0] = $aShortcutInfo[4] Else MsgBox(0, "Este não deu", _ "Os dados do atalho [" & $sLNKFile & "] foram insatisfatorios:" & @CRLF & _ "aArray[0] = Shortcut target path[" & $aShortcutInfo[0] & "]" & @CRLF & _ "aArray[1] = Working directory[" & $aShortcutInfo[1] & "]" & @CRLF & _ "aArray[2] = Arguments[" & $aShortcutInfo[2] & "]" & @CRLF & _ "aArray[3] = Description[" & $aShortcutInfo[3] & "]" & @CRLF & _ "aArray[4] = Icon filename[" & $aShortcutInfo[4] & "]" & @CRLF & _ "aArray[5] = Icon index[" & $aShortcutInfo[5] & "]" & @CRLF & _ "aArray[6] = The shortcut state[" & $aShortcutInfo[6] & "]") EndIf EndIf ;AutoIt_Debugger_Command:Disable_Debug SetError(@error, @extended) ;17/02/15 incrementei isso If $bExpandEnvStrings Then _ArrayExpandEnvStr($aShortcutInfo, 0, 4) Return $aShortcutInfo EndIf If $bExpandEnvStrings Then _ArrayExpandEnvStr($aShortcutInfo, 0, 4) Return $aShortcutInfo EndFunc ;==>_FileGetShortcutEx Link to comment Share on other sites More sharing options...
Letraindusoir Posted May 25, 2020 Share Posted May 25, 2020 (edited) hao can we get the web url from an internet-shortcut file (The extension name is ".url") on the desktop? local $aWebUrl=FileGetShortcut(@DesktopDir & "\AutoIt Forums.URL") _ArrayDisplay($aWebUrl) don't work! Edited May 25, 2020 by Letraindusoir Link to comment Share on other sites More sharing options...
Letraindusoir Posted May 25, 2020 Share Posted May 25, 2020 (edited) hao can we get the web url from an internet-shortcut file (The extension name is ".url") on the desktop? local $aWebUrl=FileGetShortcut(@DesktopDir & "\AutoIt Forums.URL") _ArrayDisplay($aWebUrl) don't work! Edited May 25, 2020 by Letraindusoir Link to comment Share on other sites More sharing options...
seadoggie01 Posted May 26, 2020 Share Posted May 26, 2020 @Letraindusoir This is unrelated to this topic that is 10 years old. A ".url" shortcut is just an Ini file though, open it in Notepad. Get it like IniRead($sFilePath, "InternetShortcut", "URL", "") Letraindusoir 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Letraindusoir Posted June 4, 2020 Share Posted June 4, 2020 On 5/26/2020 at 8:10 PM, seadoggie01 said: @Letraindusoir This is unrelated to this topic that is 10 years old. A ".url" shortcut is just an Ini file though, open it in Notepad. Get it like IniRead($sFilePath, "InternetShortcut", "URL", "") Now I Got it,Most thanks For seadoggie01 ! 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