Jump to content

How to Open Folder and Select File


Recommended Posts

Hi, I'm build my soft.

And I catch a trouble with Open Folder and Select File

It likes Internet Download Manager

Posted Image

Posted Image

Like The Picture, When I open folder, It will open folder and select file.

Other forums also discuss about it, but I don't have knowledge for C#

http://stackoverflow.com/questions/334630/open-folder-and-select-the-file

So, How to Open And Select File with autoit

Edited by hiepxuan2008
Link to comment
Share on other sites

Is it just me that can't see the images you included?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Are you talking about the built in internet download manager that is within Internet Explorer?

Reply: I don't mean built IDM, I just give example about open folder and select file.

Example: I have a path of a file "C:hiepit.jpg" and I want to open the folder with a file is selected

Is it just me that can't see the images you included?

Oh! I have just reupdated it!

The first Pic, I choose a file and click Open Folder

Posted Image

The second picture is a result, Explore open Folder contain its file, and select its file.

Posted Image

Edited by hiepxuan2008
Link to comment
Share on other sites

Looks like you need function FileOpenDialog.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You want to select the folder or a file in the folder?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Something like:

$sSelectedFile = FileOpenDialog("Please select a file", "C:\", "Images (*.jpg)", 3, "hiepit.jpg")
MsgBox(0, "Selected file", $sSelectedFile)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I don't fully get it. You want to select the file in the list of files (that's how I understand your screenshot). What should the user or your script do then?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Wow, I'm sucess . THanks all. It can do work independently

_WinAPI_ShellOpenFolderAndSelectItems('C:\hiepit.jpg')

Func _WinAPI_ShellOpenFolderAndSelectItems($sPath, $aNames = 0, $iStart = 0, $iEnd = -1, $iFlags = 0)

Local $PIDL, $Ret, $tPtr = 0, $Count = 0, $Obj = 0

$sPath = _WinAPI_PathRemoveBackslash(_WinAPI_PathSearchAndQualify($sPath))
If IsArray($aNames) Then
If ($sPath) And (Not _WinAPI_PathIsDirectory($sPath)) Then
Return SetError(1, 0, 0)
EndIf
EndIf
$PIDL = _WinAPI_ShellILCreateFromPath($sPath)
If @error Then
Return SetError(1, 0, 0)
EndIf
If IsArray($aNames) Then
If $iStart < 0 Then
$iStart = 0
EndIf
If ($iEnd < 0) Or ($iEnd > UBound($aNames) - 1) Then
$iEnd = UBound($aNames) - 1
EndIf
$tPtr = DllStructCreate('ptr[' & ($iEnd - $iStart + 1) & ']')
If @error Then
; Nothing
Else
For $i = $iStart To $iEnd
$Count += 1
If $aNames[$i] Then
DllStructSetData($tPtr, 1, _WinAPI_ShellILCreateFromPath($sPath & '\' & $aNames[$i]), $Count)
Else
DllStructSetData($tPtr, 1, 0, $Count)
EndIf
Next
EndIf
EndIf
If _WinAPI_CoInitialize() Then
$Obj = 1
EndIf
$Ret = DllCall('shell32.dll', 'uint', 'SHOpenFolderAndSelectItems', 'ptr', $PIDL, 'uint', $Count, 'ptr', DllStructGetPtr($tPtr), 'dword', $iFlags)
If @error Then
$Ret = 0
Else
If $Ret[0] Then
$Ret = $Ret[0]
EndIf
EndIf
If $Obj Then
_WinAPI_CoUninitialize()
EndIf
_WinAPI_CoTaskMemFree($PIDL)
For $i = 1 To $Count
$PIDL = DllStructGetData($tPtr, $i)
If $PIDL Then
_WinAPI_CoTaskMemFree($PIDL)
EndIf
Next
If Not IsArray($Ret) Then
Return SetError(1, $Ret, 0)
EndIf
Return 1
EndFunc ;==>_WinAPI_ShellOpenFolderAndSelectItems


Func _WinAPI_PathSearchAndQualify($sPath, $fExists = 0)

Local $Ret = DllCall('shlwapi.dll', 'int', 'PathSearchAndQualifyW', 'wstr', $sPath, 'wstr', '', 'int', 4096)

If (@error) Or (Not $Ret[0]) Then
Return SetError(1, 0, '')
EndIf
If ($fExists) And (Not FileExists($Ret[2])) Then
Return SetError(2, 0, '')
EndIf
Return $Ret[2]
EndFunc ;==>_WinAPI_PathSearchAndQualify


Func _WinAPI_PathRemoveBackslash($sPath)

Local $Ret = DllCall('shlwapi.dll', 'ptr', 'PathRemoveBackslashW', 'wstr', $sPath)

If @error Then
Return SetError(1, 0, '')
Else
If Not $Ret[0] Then
Return $sPath
EndIf
EndIf
Return $Ret[1]
EndFunc ;==>_WinAPI_PathRemoveBackslash

Func _WinAPI_ShellILCreateFromPath($sPath)

Local $Ret = DllCall('shell32.dll', 'uint', 'SHILCreateFromPath', 'wstr', $sPath, 'ptr*', 0, 'dword*', 0)

If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Return $Ret[2]
EndFunc ;==>_WinAPI_ShellILCreateFromPath


Func _WinAPI_CoInitialize($iFlags = 0)

Local $Ret = DllCall('ole32.dll', 'uint', 'CoInitializeEx', 'ptr', 0, 'dword', $iFlags)

If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Return 1
EndFunc ;==>_WinAPI_CoInitialize

Func _WinAPI_CoUninitialize()
DllCall('ole32.dll', 'none', 'CoUninitialize')
If @error Then
Return SetError(1, 0, 0)
EndIf
Return 1
EndFunc ;==>_WinAPI_CoUninitialize

Func _WinAPI_CoTaskMemFree($pMemory)
DllCall('ole32.dll', 'none', 'CoTaskMemFree', 'ptr', $pMemory)
If @error Then
Return SetError(1, 0, 0)
EndIf
Return 1
EndFunc ;==>_WinAPI_CoTaskMemFree




Func _WinAPI_PathIsDirectory($sPath)

Local $Ret = DllCall('shlwapi.dll', 'int', 'PathIsDirectoryW', 'wstr', $sPath)

If @error Then
Return SetError(1, 0, 0)
EndIf
Return $Ret[0]
EndFunc   ;==>_WinAPI_PathIsDirectory
Edited by hiepxuan2008
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...