odaylton

Start Menu Programs List

1 post in this topic

#1 ·  Posted (edited)

Translated by Google. Sorry for any mistakes.
Sorry for creating this post based on other great creations but after 15 days searching for a solution to a problem beast I solved them.
Maybe someone new like me can take advantage of this solution for their programs without wasting so much time

I want to leave here my thanks to the 2 post that saved my life

First the Yashied for the excellent work in the article:

And commenting on improvements to the _FileGetShortcutEX function Commented on by
Ascend4nt

Here is my list linking the 2 articles

#Include <GUIConstantsEx.au3>
#Include <GUIImageList.au3>
#Include <GUITreeView.au3>
#Include <TreeViewConstants.au3>
#Include <WindowsConstants.au3>
#Include <WinAPIEx.au3>
#include "_FileGetShortcutEX.au3"

Opt('MustDeclareVars', 1)

Global $hForm, $hTreeView, $hImageList, $hItem = 0, $hSelect = 0, $hInput, $Input, $Dummy1, $Dummy2
;novas linhas <<<<<
Global $hInput2, $Input2
Global $X, $Y, $sPath, $sRoot = @ProgramsCommonDir; mudado para o projeto @HomeDrive

$hForm = GUICreate('MyGUI', 600, 600)
$Input = GUICtrlCreateInput('', 20, 20, 560, 19)
$hInput = GUICtrlGetHandle(-1)
GUICtrlSetState(-1, $GUI_DISABLE)
;novas linhas <<<<<
$Input2 = GUICtrlCreateInput('', 20, 40, 560, 19)
$hInput2 = GUICtrlGetHandle(-1)
;GUICtrlSetState(-1, $GUI_DISABLE)

;$hTreeView = _GUICtrlTreeView_Create($hForm, 20, 50, 560, 530, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
;_GUICtrlTreeView_SetHeight($hTreeView, 18)
GUICtrlCreateTreeView(20, 90, 560, 530, -1, $WS_EX_CLIENTEDGE)
$hTreeView = GUICtrlGetHandle(-1)
$Dummy1 = GUICtrlCreateDummy()
$Dummy2 = GUICtrlCreateDummy()

If _WinAPI_GetVersion() >= '6.0' Then
    _WinAPI_SetWindowTheme($hTreeView, 'Explorer')
EndIf

$hImageList = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 3)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 4)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 51)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList)
$sRoot = StringRegExpReplace(FileGetLongName($sRoot), '\\+\Z', '')
$sPath = StringRegExpReplace($sRoot, '^.*\\', '')
If StringInStr($sPath, ':') Then
    $sRoot &= '\'
    $sPath &= '\'
EndIf

If _WinAPI_PathIsDirectory($sRoot) Then
    $hItem = _GUICtrlTreeView_AddChild($hTreeView, 0, $sPath, 0, 0)
    If FileClose(FileFindFirstFile($sRoot & '\*')) Then
        _GUICtrlTreeView_AddChild($hTreeView, $hItem, '', 2, 2)
    EndIf
EndIf

GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()

If $hItem Then
    _GUICtrlTreeView_Expand($hTreeView, $hItem)
EndIf

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Dummy1 ; Update
            GUISetCursor(1, 1)
            _TVUpdate($hTreeView, GUICtrlRead($Dummy1))
            GUISetCursor(2, 0)
        Case $Dummy2 ; Menu
            $hItem = GUICtrlRead($Dummy2)
            $sPath = _TVGetPath($hTreeView, $hItem, $sRoot)

            ConsoleWrite('-------------------------------' & @CR)
            ConsoleWrite('Handle: ' & $hItem & @CR)
            ConsoleWrite('Path:   ' & $sPath & @CR)
            If _WinAPI_PathIsDirectory($sPath) Then
                ConsoleWrite('Type:   ' & 'Directory' & @CR)
            Else
                ConsoleWrite('Type:   ' & 'File' & @CR)
            EndIf
            ConsoleWrite('X:      ' & MouseGetPos(0) & @CR)
            ConsoleWrite('Y:      ' & MouseGetPos(1) & @CR)
            ConsoleWrite('-------------------------------' & @CR)

    EndSwitch
WEnd

Func _TVGetPath($hTV, $hItem, $sRoot)

    Local $Path = StringRegExpReplace(_GUICtrlTreeView_GetTree($hTV, $hItem), '([|]+)|(\\[|])', '\\')

    If Not $Path Then
        Return ''
    EndIf
    If Not StringInStr($Path, ':') Then
        Return StringRegExpReplace($sRoot, '(\\[^\\]*(\\|)+)\Z', '\\') & $Path
    EndIf
    Return $Path
EndFunc   ;==>_TVGetPath

Func _TVSetPath($hTV, $hItem, $sRoot)
    ;16/11/24 incerindo variaveis pra detalhamento
    Local $Arq = _TVGetPath($hTV, $hItem, $sRoot)
    Local $sDir_Name = StringRegExpReplace($Arq, "(^.*\\)(.*)", "\1")
    Local $NomeArq = StringRegExpReplace($Arq, "^.*\\", "")
    Local $NomeArqPos = StringInStr($NomeArq, ".", 0, -1);localiza o ponto da extenso
    if $NomeArqPos Then
        Local $NomeArq2 = StringLeft($NomeArq, $NomeArqPos - 1)
        Local $ArqTipo = StringTrimLeft($NomeArq, $NomeArqPos )
        if $ArqTipo="lnk" Then
            Local $t=_FileGetShortcutEX($Arq);FileGetShortcut($Arq) 
            if $t[2]<> "" Then
                $t[0] &= "' '"&$t[2]
            EndIf
            GUICtrlSetData($Input2,"'"&$t[0] &"'")
        EndIf
        
    Else
        Local $NomeArq2=$NomeArq
        Local $ArqTipo=''
    EndIf
    Local $sDOS_Dir = FileGetShortName($sDir_Name, 1)

    GUICtrlSetData($Input, _WinAPI_PathCompactPath($hInput,$Arq, 554))
    $hSelect = $hItem
EndFunc   ;==>_TVSetPath

Func _TVUpdate($hTV, $hItem)

    Local $hImageList = _SendMessage($hTV, $TVM_GETIMAGELIST)
    Local $Path = StringRegExpReplace(_TVGetPath($hTV, $hItem, $sRoot), '\\+\Z', '')
    Local $hIcon, $hSearch, $hSubitem
    Local $Index, $File

    _WinAPI_LockWindowUpdate($hTV)
    _GUICtrlTreeView_Delete($hTV, _GUICtrlTreeView_GetFirstChild($hTV, $hItem))

    $hSearch = FileFindFirstFile($Path & '\*')
    If $hSearch = -1 Then
        If Not @error Then
            If FileExists($Path) Then
;               If _WinAPI_PathIsDirectory($Path) Then
;                   ; Access denied
;               EndIf
            Else
                _GUICtrlTreeView_Delete($hTV, $hItem)
                _WinAPI_LockWindowUpdate(0)
                Return 0
            EndIf
        EndIf
    Else
        While 1
            $File = FileFindNextFile($hSearch)
            If @error Then
                ExitLoop
            EndIf
            If @extended Then
                $hSubItem = _GUICtrlTreeView_AddChild($hTV, $hItem, $File, 0, 0)
                If FileClose(FileFindFirstFile($Path & '\' & $File & '\*')) Then
                    _GUICtrlTreeView_AddChild($hTV, $hSubItem, '', 2, 2)
                EndIf
            EndIf
        WEnd
        FileClose($hSearch)
    EndIf

    $hSearch = FileFindFirstFile($Path & '\*')
    If $hSearch = -1 Then

    Else
        While 1
            $File = FileFindNextFile($hSearch)
            If @error Then
                ExitLoop
            EndIf
            If Not @extended Then
                $hIcon = _WinAPI_ShellExtractAssociatedIcon($Path & '\' & $File, 1)
                $Index = _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon)
                _GUICtrlTreeView_AddChild($hTV, $hItem, $File, $Index, $Index)
                _WinAPI_DestroyIcon($hIcon)
            EndIf
        WEnd
        FileClose($hSearch)
    EndIf

    _GUICtrlTreeView_SetItemParam($hTV, $hItem, 0x7FFFFFFF)
    _WinAPI_LockWindowUpdate(0)

    Return 1
EndFunc   ;==>_TVUpdate

Func _WinAPI_LockWindowUpdate2($hWnd)

    Local $Ret = DllCall('user32.dll', 'int', 'LockWindowUpdate', 'hwnd', $hWnd)

    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_LockWindowUpdate
;AutoIt_Debugger_Command:Disable_Debug

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    Local $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $lParam)
    Local $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
    Local $iState = DllStructGetData($tNMTREEVIEW, 'NewState')
    Local $hTV = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
    Local $ID = DllStructGetData($tNMTREEVIEW, 'Code')
    Local $tTVHTI, $tPoint

    Switch $hTV
        Case $hTreeView
        
            Switch $ID
;AutoIt_Debugger_Command:Enable_Debug
            
                Case $TVN_ITEMEXPANDEDW
                    If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
                        _GUICtrlTreeView_Delete($hTV, $hItem)
                        If BitAND($iState, $TVIS_SELECTED) Then
                            _TVSetPath($hTV, _GUICtrlTreeView_GetSelection($hTV), $sRoot)
                        EndIf
                    Else
                        If Not BitAND($iState, $TVIS_EXPANDED) Then
                            _GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 0)
                            _GUICtrlTreeView_SetImageIndex($hTV, $hItem, 0)
                        Else
                            _GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 1)
                            _GUICtrlTreeView_SetImageIndex($hTV, $hItem, 1)
                            If Not _GUICtrlTreeView_GetItemParam($hTV, $hItem) Then
                                GUICtrlSendToDummy($Dummy1, $hItem)
                            EndIf
                        EndIf
                    EndIf
                Case $TVN_SELCHANGEDW
                    If BitAND($iState, $TVIS_SELECTED) Then
                        If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
                            _GUICtrlTreeView_Delete($hTV, $hItem)
                            $hItem = _GUICtrlTreeView_GetSelection($hTV)
                        EndIf
                        If $hItem <> $hSelect Then
                            _TVSetPath($hTV, $hItem, $sRoot)
                        EndIf
                    EndIf
                Case $NM_RCLICK
                        $tPoint = _WinAPI_GetMousePos(1, $hTV)
                        $tTVHTI = _GUICtrlTreeView_HitTestEx($hTV, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2))
                        $hItem = DllStructGetData($tTVHTI, 'Item')
                        If BitAND(DllStructGetData($tTVHTI, 'Flags'), $TVHT_ONITEM) Then
                            _GUICtrlTreeView_SelectItem($hTreeView, $hItem)
                            If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
                                _GUICtrlTreeView_Delete($hTV, $hItem)
                                $hItem = _GUICtrlTreeView_GetSelection($hTV)
                            Else
                                GUICtrlSendToDummy($Dummy2, $hItem)
                            EndIf
                            If $hItem <> $hSelect Then
                                _TVSetPath($hTV, $hItem, $sRoot)
                            EndIf
                        EndIf
;AutoIt_Debugger_Command:Disable_Debug
                        
                EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
;AutoIt_Debugger_Command:Enable_Debug

 

Edited by odaylton

Share this post


Link to post
Share on other sites



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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Tankerspam
      Start Menu Example
      By Tankerspam
      Hi all,
      [Note: This is designed for MY PC if I get enough interest I may optimize it for other people's/make it universal.]
      This is an example script (purely a concept)
      Examples below.
      Please read the concept idea before using.
      You will need all the below files for it to work (Bar the source code.)
      Please note that while I am giving access to this any damage done is not to be held to my accountabilitiy, additionally, please do not claim this is your own, and if you do improve on this it would be great to give some credit to me :D. You may give this away freely and are free to do what you wish with this.
      Have fun with the code and enjoy.
      Background for concept:
      I started designing this to be a Windows 8 start menu, one of my mates asked me if he could use it, also asked me to put it on the web somewhere, and I no longer use windows 8 (that yucky OS! I hope most of you will agree with me on that.) I guess you could say, it's like the windows 95/98 start menu in looks, a but yuck. Anyway have fun and enjoy.
      I may optimize this for other PCs if I get enough interest.
      ChangeLog.txt
      ConceptIdea.txt
      Start Menu Concept1.au3
      Start Menu Concept1.exe
    • imitto
      Script not working if run from shortcut
      By imitto
      Hello all!
      I was in read-only until today, started to use Autoit 3 weeks ago. It can really make things easy, I really love it
      I have some script now that works and make our job effective, but I have problems with the latest. It works if I open the script's folder and run the exe directly. If I use the shortcut that I created on the desktop, it's not working properly. Activates the window, but not opening/exporting my files, just opens the last msgbox. I use ftp becouse the PC and the destination PC is not on the same network.
      Here's the script:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\microsoft_excel.ico #AutoIt3Wrapper_Res_Comment=send file over ftp #AutoIt3Wrapper_Res_Description=send file over ftp for process #AutoIt3Wrapper_Res_Language=1038 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: imitto Script Function: Rename and put playlist file on ftp #ce ---------------------------------------------------------------------------- #RequireAdmin #include <File.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FTPEx.au3> ; Script Start Global $playlistname=@YEAR&@MON&@MDAY&"-playlist.pll" BlockInput($BI_DISABLE) Opt ("WinTitleMatchMode", 2) WinActivate("MAIN SCHED") WinWaitActive("MAIN SCHED") ;Opt ("WinTitleMatchMode", 1) Send("!fo") WinWaitActive("Open") Send("Z:\playlist\"&$playlistname&"{ENTER}") Sleep(2000) Send("!fe") WinWaitActive("MCon") Send("{ENTER}") WinWaitActive("Save") Send("C:\sendFileForXLS\lista.txt{ENTER}") Sleep(500) Send("!fc") BlockInput($BI_ENABLE) Sleep(50) Opt ("WinTitleMatchMode", 1) Local $hOpen = _FTP_Open('MyFTP Control') $ftp=_FTP_Connect($hOpen, "**********", "******", "******") If @error Then MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error) Else _FTP_FilePut($ftp, @ScriptDir&"\lista.txt", "/lista.txt") EndIf Local $iFtpc = _FTP_Close($hOpen) FileDelete(@ScriptDir&"\lista.txt") MsgBox(0, "", "Playlist exported", 2) Exit  
    • littleboy62
      How do pin a shortcut in start menu ? (windows 10)
      By littleboy62
      Hello everyone.
      First, sorry for mistakes, I'm french. ^^
      =====
      I've tried (and I try always) to pin a shortcut (lnk) to startmenu (on Windows 10).

      Look this subject (in forum FR autoit) : http://www.autoitscript.fr/forum/viewtopic.php?f=21&t=12031
      The script I wrote, doesn't work, despithe the display of "Épingler à l'écran de démarrage" by a consolewrite.
      This is the script :
      #RequireAdmin $path = @DesktopDir & "\vlc.lnk" PinToTaskBand($path) Func PinToTaskBand($path) $objShell = ObjCreate("shell.application") $objFSO = ObjCreate("Scripting.FileSystemObject") $strFolder = $objFSO.GetParentFolderName($path) $strFile = $objFSO.GetFileName($path) $objFolder = $objShell.Namespace($strFolder) $objFolderItem = $objFolder.ParseName($strFile) $colVerbs = $objFolderItem.Verbs For $itemVerb In $objFolderItem.Verbs ;~ MsgBox(0,"", $itemVerb.name) $var = StringReplace($itemVerb.name, "&", "") ConsoleWrite($var & " | ") If $var = "Pin to startmenu" Or $var="Épingler à l’écran de démarrage" Then MsgBox(0, "", 1) $itemVerb.DoIt EndIf Next EndFunc ;==>PinToTaskBand Func UnpinToTaskBand($path) $objShell = ObjCreate("shell.application") $objFSO = ObjCreate("Scripting.FileSystemObject") $strFolder = $objFSO.GetParentFolderName($path) $strFile = $objFSO.GetFileName($path) $objFolder = $objShell.Namespace($strFolder) $objFolderItem = $objFolder.ParseName($strFile) $colVerbs = $objFolderItem.Verbs For $itemVerb In $objFolderItem.Verbs ConsoleWrite($itemVerb.name & " | ") If StringReplace($itemVerb.name, "&", "") == "Unpin from Taskbar" Or StringReplace($itemVerb.name, "&", "") == "Détacher de la barre des tâches" Then $itemVerb.DoIt Next EndFunc ;==>UnpinToTaskBand If StringInStr($var, "Pin to startmenu") Or StringInStr($var, "Épingler à l’écran de démarrage") Then MsgBox(0, "", 1) $itemVerb.DoIt EndIf  
      It shows 1 (msgbox) correctly.
      But $itemVerb.DoIt doesn't work.

      Someone would he know how to do ?
      If i do mistakes, where are it ? Please.
      Else, is there another way to pin a shortcut to startmenu (on windows 10)?
      Thanks by advance.
      Cheers.
      Good day guys:D
    • robertcollier4
      LNKSubstringReplacer Link LNK Path Substring Replacer
      By robertcollier4
      Choose a directory of link files to replace substring paths.
      LNKSubstringReplacer.au3
      _RecFileListToArray.au3

       
      #include <Array.au3> #include <_RecFileListToArray.au3> #include <File.au3> $modalSimulMode = MsgBox (3, "Simulated mode?" ,"Would you like to perform this substring replacement of link files in simulated mode? In simulated mode you will see what would have happened in a file named" & @CRLF & "LNKSubstringReplacer Results.txt" & @CRLF & @CRLF & "but no changes will be made" & @CRLF & @CRLF & "Yes - simulated mode, no changes will be made" & @CRLF & "No - resaving mode, changes will be made") If $modalSimulMode = 2 Then Exit ElseIf $modalSimulMode = 6 Then $saveAgain = False ElseIf $modalSimulMode = 7 Then $saveAgain = True ElseIf MsgBox(0, "ERROR", "Error with asking simulated mode, exiting") EndIf Local $dirToSearchDefault = @ProgramsCommonDir ; Local $dirToSearchDefault = "T:\testdir" Local $dirToSearch = InputBox("Select directory", "In which directory would you like to search for files to perform substring link replacement for?", $dirToSearchDefault, "", 520, 320) If $dirToSearch = "" Then Exit EndIf Local $StrToSearch = InputBox("Specify substring to search for", "What substring would you like to be replaced for link target and link working directory?", "", "", 520, 320) ; If $StrToSearch = "" Then ; allow empty input in case just want to resave and fix all links If @error = 1 Then Exit EndIf Local $StrToReplace = InputBox("Specify substring to replace with", "All occurrences of" & @CRLF & $StrToSearch & @CRLF & @CRLF & "Contained in links in the directory " & @CRLF & $dirToSearch & @CRLF & @CRLF & "Should be replaced with what?", $StrToSearch, "", 520, 320) ; If $StrToSearch = "" Then ; allow empty input in case just want to resave and fix all links If @error = 1 Then Exit EndIf Local $listFiles = _RecFileListToArray($dirToSearchDefault, "*", 1, 1, 0, 2) If (Not IsArray($listFiles)) and (@Error=1) Then MsgBox (0,"","No files found in search path, exiting") Exit EndIf ; _ArrayDisplay($listFiles, "$aFileList") ; Write simulated results to a text file $dateNow = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & @SEC $fileLnkPath = @ScriptDir & "\" & $dateNow & " LNKSubstringReplacer Results.txt" FileDelete($fileLnkPath) Local $fileTextList = FileOpen($fileLnkPath, $FO_APPEND) If $fileTextList = -1 Then MsgBox(0, $fileLnkPath, "FileOpen Error, exiting") Exit EndIf FileWrite($fileTextList, "---------------------------------------" & @CRLF) FileWrite($fileTextList, "Link file to scan" & @CRLF) FileWrite($fileTextList, "Link target" & @CRLF) FileWrite($fileTextList, "Link working directory" & @CRLF) Local $thisExtension = "" Local $sDrive = "", $sDir = "", $sFileName = "" For $i = 1 To $listFiles[0] ; Only do LNK extension Local $listFilesPathSplit = _PathSplit($listFiles[$i], $sDrive, $sDir, $sFileName, $thisExtension) ; MsgBox(0, $i, $listFiles[$i] & " , " & $thisExtension) If(StringCompare(".lnk", $thisExtension, 2) == 0) Then ; If(NOT StringCompare(".lnk", $thisExtension, 2)) Then FileWrite($fileTextList, @CRLF & "---------------------------------------" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) Local $thislnkArray = FileGetShortcut($listFiles[$i]) If(NOT @error) Then If($thislnkArray[0] <> "") Then ; _ArrayDisplay($lnkArray) ; FileWrite($fileTextList, $thislnkArray[0] & @CRLF) ; FileWrite($fileTextList, $thislnkArray[2] & @CRLF) FileWrite($fileTextList, $thislnkArray[0] & $thislnkArray[2] & @CRLF) FileWrite($fileTextList, $thislnkArray[1] & @CRLF) ; Allow empty $StrToSearch or empty $strToReplace just to fix and resave all links If( ($StrToSearch = "") OR ($StrToReplace = "") ) Then $newLinkTarget = RemoveSurrQuotes($thislnkArray[0]) $newLinkTargetArgs = $thislnkArray[2] $newLinkWorkingDir = RemoveSurrQuotes($thislnkArray[1]) Else $newLinkTarget = RemoveSurrQuotes(StringReplace($thislnkArray[0], $StrToSearch, $StrToReplace)) $newLinkTargetArgs = StringReplace($thislnkArray[2], $StrToSearch, $StrToReplace) $newLinkWorkingDir = RemoveSurrQuotes(StringReplace($thislnkArray[1], $StrToSearch, $StrToReplace)) EndIf ; Remove ending backslash from working dir While (StringRight($newLinkWorkingDir, 1) = "\") $newLinkWorkingDir = StringTrimRight($newLinkWorkingDir, 1) WEnd If($saveAgain) Then FileWrite($fileTextList, @CRLF & "Resaved:" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) FileWrite($fileTextList, $newLinkTarget & " " & $newLinkTargetArgs & @CRLF) FileWrite($fileTextList, $newLinkWorkingDir & @CRLF) $saveResult = FileCreateShortcut( _ $newLinkTarget, _ $listFiles[$i], _ $newLinkWorkingDir, _ $newLinkTargetArgs, _ $thislnkArray[3], _ $thislnkArray[4], _ "", _ $thislnkArray[5], _ $thislnkArray[6] _ ) If(NOT $saveResult) Then FileWrite($fileTextList, "ERROR Unable to resave: " & $listFiles[$i] & @CRLF) EndIf Else FileWrite($fileTextList, @CRLF & "Simulated Resave:" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) FileWrite($fileTextList, $newLinkTarget & " " & $newLinkTargetArgs & @CRLF) FileWrite($fileTextList, $newLinkWorkingDir & @CRLF) EndIf Else FileWrite($fileTextList, "Found empty link target, skipping " & @CRLF) EndIf Else FileWrite($fileTextList, "FileGetShortcut Error, skipping " & @CRLF) Exit EndIf Else FileWrite($fileTextList, @CRLF & "---------------------------------------" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) FileWrite($fileTextList, "Skipping not a link file" & @CRLF) EndIf Next FileClose($fileTextList) ;--------------------------------------------------------------- Func RemoveSurrQuotes($myString) Return StringReplace($myString, '"', '') EndFunc ;---------------------------------------  
    • Danyfirex
      Create NetWork Connection ShortCut
      By Danyfirex
      Well. I was needing to create a networks shortcut. so I did find anything into the forum. So I write this after reading about Nonfile Object.
       
      ;~ Danyfirex 26/07/2015 #include <WinAPIShellEx.au3> Opt("MustDeclareVars", 1) Global Const $SHCONTF_NONFOLDERS = 0x00040 Global Const $SHGDN_NORMAL = 0 Global Const $S_OK = 0 Global Const $sTagSTRRET = "UINT uType;ptr pOleStr;UINT uOffset;CHAR cStr[256]" Global Const $CLSID_ShellLink = "{00021401-0000-0000-C000-000000000046}" Global Const $sIID_IShellLinkW = "{000214F9-0000-0000-C000-000000000046}" Global Const $sTagIShellLink = "getpath hresult(long;long;long;long); " & _ "getidlist hresult(ptr); " & _ "setidlist hresult(ptr); " & _ "getdescription hresult(long;long); " & _ "setdescription hresult(wstr); " & _ "getworkingdirectory hresult(long;long); " & _ "setworkingdirectory hresult(long); " & _ "getarguments hresult(long;long); " & _ "setarguments hresult(ptr); " & _ "gethotkey hresult(long); " & _ "sethotkey hresult(word); " & _ "getshowcmd hresult(long); " & _ "setshowcmd hresult(int); " & _ "geticonlocation hresult(long;long;long); " & _ "seticonlocation hresult(wstr;int); " & _ "setrelativepath hresult(long;long); " & _ "resolve hresult(long;long); " & _ "setpath hresult(wstr)" Global Const $sIID_IPersistFile = "{0000010b-0000-0000-C000-000000000046}" Global Const $sTagIPersistFile = "GetClassID hresult(long); IsDirty hresult(); Load hresult(long;long); Save hresult(wstr;bool); SaveCompleted hresult(long); GetCurFile hresult(long)" Global Const $sIID_IEnumIDList = "{000214F2-0000-0000-C000-000000000046}" Global Const $sTagIEnumIDList = "Next hresult(ulong;ptr*;ulong*);" & _ "Reset hresult();" & _ "Skip hresult(ulong);" & _ "Clone hresult(ptr*);" Global Const $sIID_IShellFolder = "{000214E6-0000-0000-C000-000000000046}" Global Const $sTagIShellFolder = "ParseDisplayName hresult(hwnd;ptr;wstr;ulong*;ptr*;ulong*);" & _ "EnumObjects hresult(hwnd;dword;ptr*);" & _ "BindToObject hresult(ptr;ptr;clsid;ptr*);" & _ "BindToStorage hresult(ptr*;ptr;clsid;ptr*);" & _ "CompareIDs hresult(lparam;ptr*;ptr*);" & _ "CreateViewObject hresult(hwnd;clsid;ptr*);" & _ "GetAttributesOf hresult(uint:ptr*;ulong*);" & _ "GetUIObjectOf hresult(hwnd;uint;ptr*;clsid;uint*;ptr*);" & _ "GetDisplayNameOf hresult(ptr;dword;ptr);" & _ "SetNameOf hresult(hwnd;ptr*;wstr;dword;ptr*);" Local $MyNetWorkConnectionName="Conexión de red inalámbrica" CreateNetWorkConnectionShortCut($MyNetWorkConnectionName) ;~ Success: Return True ;~ Failure: Return False ;~ if $lnkPath = "" ShortCut will be Create on Desktop with the name of the Conections($sConnectionName) Func CreateNetWorkConnectionShortCut($sConnectionName, $lnkPath = "") Local $pConecctionsFolder = 0 Local $oConecctionsFolder = 0 Local $pEnumIDList = 0 Local $oEnumIDList = 0 Local $pPIDLItem = 0 Local $celtFetched = 0 Local $pPIDLConectionsFolder = 0 Local $bRet = False Local $tSTRRET = 0 Local $twstring = 0 Local $pShellFolder = SHGetDesktopFolder() Local $oShellFolder = ObjCreateInterface($pShellFolder, $sIID_IShellFolder, $sTagIShellFolder) If @error Then Return $bRet $pPIDLConectionsFolder = _WinAPI_ShellGetSpecialFolderLocation($CSIDL_CONNECTIONS) If SUCCEEDED($oShellFolder.BindToObject($pPIDLConectionsFolder, Null, $sIID_IShellFolder, $pConecctionsFolder)) Then $oConecctionsFolder = ObjCreateInterface($pConecctionsFolder, $sIID_IShellFolder, $sTagIShellFolder) If IsObj($oConecctionsFolder) Then If SUCCEEDED($oConecctionsFolder.EnumObjects(Null, $SHCONTF_NONFOLDERS, $pEnumIDList)) Then $oEnumIDList = ObjCreateInterface($pEnumIDList, $sIID_IEnumIDList, $sTagIEnumIDList) If IsObj($oEnumIDList) Then $tSTRRET = DllStructCreate($sTagSTRRET) While (SUCCEEDED($oEnumIDList.Next(1, $pPIDLItem, $celtFetched)) And $celtFetched > 0) If SUCCEEDED($oConecctionsFolder.GetDisplayNameOf($pPIDLItem, $SHGDN_NORMAL, DllStructGetPtr($tSTRRET))) Then $twstring = DllStructCreate("wchar Name[512]", $tSTRRET.pOleStr) If $twstring.Name = $sConnectionName Then If $lnkPath = "" Then $lnkPath = @DesktopDir & "\" & $twstring.Name & ".lnk" $bRet = CreateLnk($pPIDLConectionsFolder, $pPIDLItem, $lnkPath) ExitLoop EndIf $twstring = 0 EndIf WEnd EndIf EndIf EndIf EndIf If $pPIDLConectionsFolder Then _WinAPI_CoTaskMemFree($pPIDLConectionsFolder) Return $bRet EndFunc ;==>CreateNetWorkShortCut Func CreateLnk($PIDL1, $PIDL2, $lnkPath) Local $oShellLink = 0 Local $oIPersistFile = 0 Local $pIPersistFile = 0 Local $pAppendID = 0 Local $bRet = False $oShellLink = ObjCreateInterface($CLSID_ShellLink, $sIID_IShellLinkW, $sTagIShellLink) If @error Then Return $bRet $pAppendID = ILAppendID($PIDL1, $PIDL2) If IsObj($oShellLink) And $pAppendID Then If SUCCEEDED($oShellLink.SetIDList($pAppendID)) Then $oShellLink.QueryInterface($sIID_IPersistFile, $pIPersistFile) $oIPersistFile = ObjCreateInterface($pIPersistFile, $sIID_IPersistFile, $sTagIPersistFile) If IsObj($oIPersistFile) Then $bRet = SUCCEEDED($oIPersistFile.Save($lnkPath, True)) EndIf EndIf EndIf Return $bRet EndFunc ;==>CreateLnk Func ILAppendID($PIDLIST_RELATIVE, $LPSHITEMID, $fAppend = True) Local $aRet = DllCall("Shell32.dll", "ptr", "ILAppendID", "ptr", $PIDLIST_RELATIVE, "ptr", $LPSHITEMID, "bool", $fAppend) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] = 0 Then Return SetError(10, $aRet[0], 0) Return $aRet[0] EndFunc ;==>ILAppendID Func SHGetDesktopFolder() Local $aRet = DllCall("Shell32.dll", "long", "SHGetDesktopFolder", "ptr*", Null) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $aRet[1] EndFunc ;==>SHGetDesktopFolder Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos