spuuunit Posted June 28, 2020 Share Posted June 28, 2020 I want to be able to detect what files I've selected on the Desktop and I was successfull doing so thanks to this thread (thanks Nine). But I only get the names with no file extension, which seem a little odd to me. Am I missing something? Or do I have to list all files in Desktop and compare the two? This is my code for now: Sleep(5000) Local $sSel = ControlListView ("[CLASS:Progman]", "", 1, "GetSelected", 1) Local $aSel = StringSplit ($sSel,"|") Local $sList = "" For $i = 1 to $aSel[0] $sList = $sList & ControlListView ("[CLASS:Progman]", "", 1, "GetText", $aSel[$i]) & @CRLF Next MsgBox(0, "", $sList) Link to comment Share on other sites More sharing options...
Zedna Posted June 28, 2020 Share Posted June 28, 2020 I think that you have to compare these names with content of @DesktopDir Also look at FileGetShortcut() to get full path of LNK files from desktop ... ; Read in the path of a shortcut $details = FileGetShortcut(@DesktopDir & "\Shortcut Test.lnk") If Not @error Then MsgBox(0, "Path:", $details[0]) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
spuuunit Posted June 28, 2020 Author Share Posted June 28, 2020 6 minutes ago, Zedna said: I think that you have to compare these names with content of @DesktopDir Also look at FileGetShortcut() to get full path of LNK files from desktop ... ; Read in the path of a shortcut $details = FileGetShortcut(@DesktopDir & "\Shortcut Test.lnk") If Not @error Then MsgBox(0, "Path:", $details[0]) Thanks, I'll do that. 🙂 Link to comment Share on other sites More sharing options...
Nine Posted June 28, 2020 Share Posted June 28, 2020 (edited) Don't forget to add @DesktopCommonDir too if you want both name and full path, use this : Opt ("MustDeclareVars", 1) ; https://docs.microsoft.com/en-us/windows/win32/api/shldisp/ne-shldisp-shellspecialfolderconstants Global Enum $ssfDESKTOP, $ssfPROGRAMS = 2, $ssfCONTROLS, $ssfPRINTERS, $ssfPERSONAL, $ssfFAVORITES, $ssfSTARTUP, _ $ssfRECENT, $ssfSENDTO, $ssfBITBUCKET, $ssfSTARTMENU, $ssfDESKTOPDIRECTORY = 16, $ssfDRIVES, $ssfNETWORK, $ssfNETHOOD, $ssfFONTS, _ $ssfTEMPLATES, $ssfCOMMONSTARTMENU, $ssfCOMMONPROGRAMS, $ssfCOMMONSTARTUP, $ssfCOMMONDESKTOPDIR, $ssfAPPDATA, $ssfPRINTHOOD, $ssfLOCALAPPDATA, _ $ssfALTSTARTUP, $ssfCOMMONALTSTARTUP, $ssfCOMMONFAVORITES, $ssfINTERNETCACHE, $ssfCOOKIES, $ssfHISTORY, $ssfCOMMONAPPDATA, $ssfWINDOWS, _ $ssfSYSTEM, $ssfPROGRAMFILES, $ssfMYPICTURES, $ssfPROFILE, $ssfSYSTEMx86, $ssfPROGRAMFILESx86 = 48 ; https://docs.microsoft.com/en-us/windows/win32/shell/folderitems3-filter Global Enum $SHCONTF_CHECKING_FOR_CHILDREN = 0x10, $SHCONTF_FOLDERS = 0x20, $SHCONTF_NONFOLDERS = 0x40, $SHCONTF_INCLUDEHIDDEN = 0x80, _ $SHCONTF_INIT_ON_FIRST_NEXT = 0x100, $SHCONTF_NETPRINTERSRCH = 0x200, $SHCONTF_SHAREABLE = 0x400, $SHCONTF_STORAGE = 0x800, _ $SHCONTF_NAVIGATION_ENUM = 0x1000, $SHCONTF_FASTITEMS = 0x2000, $SHCONTF_FLATLIST = 0x4000, $SHCONTF_ENABLE_ASYNC = 0x8000, _ $SHCONTF_INCLUDESUPERHIDDEN = 0x10000 Global $oShellApplication = ObjCreate("Shell.Application") Local $oShellFolder = $oShellApplication.NameSpace($ssfDESKTOPDIRECTORY) Local $oShellFolderItems = $oShellFolder.Items() $oShellFolderItems.Filter($SHCONTF_NONFOLDERS, "*") For $oShellFolderItem In $oShellFolderItems ConsoleWrite("Name : " & $oShellFolderItem.name & " / Real path : " & $oShellFolderItem.path & @CRLF) For $i = 0 to 10 ConsoleWrite (@TAB & $oShellFolder.GetDetailsOf($oShellFolderItem, $i) & @CRLF) Next Next Edited June 28, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted June 28, 2020 Share Posted June 28, 2020 (edited) Ahh You got me interested, so I put everything together. That is my problem, I get interested in others issues and forget my owns 😞 expandcollapse popup#AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <File.au3> ListSelect() Func ListSelect() MsgBox($MB_SYSTEMMODAL, "", "You will have 5 sec to choose desktop icons after closing this msgBox") Sleep(5000) Local $sSel = ControlListView("[CLASS:Progman]", "", 1, "GetSelected", 1) Local $aSel = StringSplit($sSel, "|") _ArrayColInsert($aSel, 1) For $i = 1 To $aSel[0][0] $aSel[$i][0] = ControlListView("[CLASS:Progman]", "", 1, "GetText", $aSel[$i][0]) $aSel[$i][1] = SearchPath($aSel[$i][0]) Next _ArrayDisplay($aSel) EndFunc ;==>ListSelect Func SearchPath($sName) Local $ssfDESKTOPDIRECTORY = 16, $ssfCOMMONDESKTOPDIR = 25 Local $SHCONTF_NONFOLDERS = 0x40 Local $oShellApplication = ObjCreate("Shell.Application") Local $oShellFolder = $oShellApplication.NameSpace($ssfDESKTOPDIRECTORY) Local $oShellFolderItems = $oShellFolder.Items() $oShellFolderItems.Filter($SHCONTF_NONFOLDERS, "*") For $oShellFolderItem In $oShellFolderItems If $oShellFolderItem.name = $sName Then Return $oShellFolderItem.path Next $oShellFolder = $oShellApplication.NameSpace($ssfCOMMONDESKTOPDIR) $oShellFolderItems = $oShellFolder.Items() $oShellFolderItems.Filter($SHCONTF_NONFOLDERS, "*") For $oShellFolderItem In $oShellFolderItems If $oShellFolderItem.name = $sName Then Return $oShellFolderItem.path Next Return "" EndFunc ;==>SearchPath Edited June 28, 2020 by Nine Danyfirex and argumentum 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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