Jump to content
Sign in to follow this  
Fire

[Solved] How to Open File Property Box for any file?

Recommended Posts

Fire

Hi to Great AUTOIT Community.

I need help.

My Question:

Is here any way to open <File Property Box(GUI)> for any file?

In eg: like this:

Posted Image

Thanks in advance.

Edited by Sh3llC043r

[size="5"] [/size]

Share this post


Link to post
Share on other sites
goldenix

I assume you are looking for file info:

try this:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         myName

 Script Function:
    File Info [by Malkey ].au3

#ce ----------------------------------------------------------------------------
Local $FileName,$FileSize,$FileType,$FileModified,$FileCreated,$FileAccessed
Local $FileReadyArchiving,$ImageWidthxHeight,$ImageWidthxHeight,$ImageHeight
$ImageFile = "ev020113.jpg"
$folder = @ScriptDir

;Based on gaFrost's FileExtProperties - kudos to simucal
$objShell = ObjCreate("Shell.Application")
$objFolder = $objShell.Namespace ($folder)
For $strFileName In $objFolder.Items
    If $objFolder.GetDetailsOf ($strFileName, 0) = $ImageFile Then
        $FileName            = $objFolder.GetDetailsOf ($strFileName, 0)
        $FileSize            = $objFolder.GetDetailsOf ($strFileName, 1)
        $FileType            = $objFolder.GetDetailsOf ($strFileName, 2)
        $FileModified        = $objFolder.GetDetailsOf ($strFileName, 3)
        $FileCreated         = $objFolder.GetDetailsOf ($strFileName, 4)
        $FileAccessed        = $objFolder.GetDetailsOf ($strFileName, 5)
        $FileReadyArchiving  = $objFolder.GetDetailsOf ($strFileName, 6)
        $ImageWidthxHeight   = $objFolder.GetDetailsOf ($strFileName, 26)
        $ImageWidth          = $objFolder.GetDetailsOf ($strFileName, 27)
        $ImageHeight         = $objFolder.GetDetailsOf ($strFileName, 28)
        for $x = 0 to 100
            ConsoleWrite($x & "  " & $objFolder.GetDetailsOf ($strFileName, $x) & @CRLF)
        next
        ExitLoop
    EndIf
Next
MsgBox(0,"", "File Name                :"& $FileName & @CRLF & _
             "File Size             :"& $FileSize & @CRLF  & _
             "Type of File              :"& $FileType & @CRLF  & _
             "File Modified         :"& $FileModified & @CRLF & _
             "File Created             :"& $FileCreated & @CRLF & _
             "File Accessed         :"& $FileAccessed & @CRLF & _
             "File ready for Archiving   :"& $FileReadyArchiving & @CRLF & _
             "Image Width x Height          :"& $ImageWidthxHeight & @CRLF & _
             "Image Width                :"& $ImageWidth & @CRLF & _
             "Image Height               :"& $ImageHeight & @CRLF     )

Or this:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         myName

 Script Function:
    File Info [by Simucal ].au3

#ce ----------------------------------------------------------------------------
;===============================================================================
; Function Name:    GetExtProperty($sPath,$iProp)
; Description:      Returns an extended property of a given file.
; Parameter(s):     $sPath - The path to the file you are attempting to retrieve an extended property from.
;                   $iProp - The numerical value for the property you want returned. If $iProp is is set
;                             to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
;                           The properties are as follows:
;                           Name = 0
;                           Size = 1
;                           Type = 2
;                           DateModified = 3
;                           DateCreated = 4
;                           DateAccessed = 5
;                           Attributes = 6
;                           Status = 7
;                           Owner = 8
;                           Author = 9
;                           Title = 10
;                           Subject = 11
;                           Category = 12
;                           Pages = 13
;                           Comments = 14
;                           Copyright = 15
;                           Artist = 16
;                           AlbumTitle = 17
;                           Year = 18
;                           TrackNumber = 19
;                           Genre = 20
;                           Duration = 21
;                           BitRate = 22
;                           Protected = 23
;                           CameraModel = 24
;                           DatePictureTaken = 25
;                           Dimensions = 26
;                           Width = 27
;                           Height = 28
;                           Company = 30
;                           Description = 31
;                           FileVersion = 32
;                           ProductName = 33
;                           ProductVersion = 34
; Requirement(s):   File specified in $spath must exist.
; Return Value(s):  On Success - The extended file property, or if $iProp = -1 then an array with all properties
;                   On Failure - 0, @Error - 1 (If file does not exist)
; Author(s):        Simucal (Simucal@gmail.com)
; Note(s):
;

;~ Example1: 
;~ $path = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)")
;~ $prop = _GetExtProperty($path,21)
;~ ConsoleWrite("Property #"&$i&": "&$prop&@CRLF)


;~ Example2: 
#include <array.au3>
$path = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)")
$prop = _GetExtProperty($path,-1)
_ArrayDisplay($prop,"Property Array")

;===============================================================================
Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
        SetError(1)
        Return 0
    Else
        $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
        $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
        $oShellApp = ObjCreate ("shell.application")
        $oDir = $oShellApp.NameSpace ($sDir)
        $oFile = $oDir.Parsename ($sFile)
        If $iProp = -1 Then
            Local $aProperty[35]
            For $i = 0 To 34
                $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
            Next
            Return $aProperty
        Else
            $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
            If $sProperty = "" Then
                Return 0
            Else
                Return $sProperty
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_GetExtProperty

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
KaFu

Func _ShowFileProperties($sFile, $sVerb = "properties", $hWnd = 0)
    ; function by Rasim
    ; http://www.autoitscript.com/forum/index.php?showtopic=78236&view=findpost&p=565547

    Local Const $SEE_MASK_INVOKEIDLIST = 0xC
    Local Const $SEE_MASK_NOCLOSEPROCESS = 0x40
    Local Const $SEE_MASK_FLAG_NO_UI = 0x400

    Local $PropBuff, $FileBuff, $SHELLEXECUTEINFO

    $PropBuff = DllStructCreate("char[256]")
    DllStructSetData($PropBuff, 1, $sVerb)

    $FileBuff = DllStructCreate("char[256]")
    DllStructSetData($FileBuff, 1, $sFile)

    $SHELLEXECUTEINFO = DllStructCreate("int cbSize;long fMask;hwnd hWnd;ptr lpVerb;ptr lpFile;ptr lpParameters;ptr lpDirectory;" & _
            "int nShow;int hInstApp;ptr lpIDList;ptr lpClass;hwnd hkeyClass;int dwHotKey;hwnd hIcon;" & _
            "hwnd hProcess")

    DllStructSetData($SHELLEXECUTEINFO, "cbSize", DllStructGetSize($SHELLEXECUTEINFO))
    DllStructSetData($SHELLEXECUTEINFO, "fMask", $SEE_MASK_INVOKEIDLIST)
    DllStructSetData($SHELLEXECUTEINFO, "hwnd", $hWnd)
    DllStructSetData($SHELLEXECUTEINFO, "lpVerb", DllStructGetPtr($PropBuff, 1))
    DllStructSetData($SHELLEXECUTEINFO, "lpFile", DllStructGetPtr($FileBuff, 1))

    $aRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($SHELLEXECUTEINFO))
    If $aRet[0] = 0 Then Return SetError(2, 0, 0)

    Return $aRet[0]
EndFunc   ;==>_ShowFileProperties

Share this post


Link to post
Share on other sites
Fire

Thanks for your response goldenix. I Greatly appreciate your reply.But yet when i searched in forum i found the second script which you post here.

I`m sorry but both scripts didn`t works for me.I assume both of script did`nt solve my question.

Anyway Thanks so much for response.

I appreciate your help.

BTW i googled about it and i found about rundll32.exe method for this reason but i cannot figure it out to work under Win Xp Sp2.

KaFu Thank you too for help But again i cannot figure it out to work.:idea:

Thanks to all for reply.

EDIT:

Found another script in forum but it works problematicly for me.

It is able to open File Property Box for choosed file.But it is not stabel:(

#cs

Grabbed from http://www.autoitscript.com/forum/index.php?showtopic=98713&st=0&p=709948&hl=file%20property&fromsearch=1&#


#ce



Global $g_eventerror = 0, $sCOMError ; to be checked to know if com error occurs. Must be reset after handling.
Global $oMyError = ObjEvent("AutoIt.Error", "ComErrorHandler"); Install a custom error handler

Global Const $SHOP_FILEPATH = 0x00000002

$file=FileOpenDialog("Choose Your File",@ScriptDir,"All files(*.*)")

; Create the comment string to write
Global $strComment = "20090413154626" & "|" & _
    "Really hope someone could help me with this piece of code,..." & "|" & _
    "since I searched and googled it a lot with no solution." & "|" & _
    "20090721163452"

; Identify Properties window
Global $strPropWinTitle = "[REGEXPTITLE:Proprietes | Properties; CLASS:#32770]"

Global $hProperties, $sTab, $hEdit, $sComment

Switch @OSLang
    Case "040c", "080c", "0c0c", "100c", "140c", "180c" ; French
    $sTab = "Resume"
    ;Case Else
    Case "1009", "0409", "0809", "0c09", "1409", "1809", "1c09", "2009", "2409", "2809", "2c09", "3009", "3409","0419" ; English ;0419 Russian Language in WIN
    $sTab = "Summary"
EndSwitch

; Create some file
Global $file



; Call file's properties dialog with 'Summary' property sheet page as default tab
Global $intReturn = DllCall("shell32.dll", "int", "SHObjectProperties", "hwnd", 0, "dword", _
    $SHOP_FILEPATH, "wstr", $file, "wstr", $sTab)

; Wait for dialog to come and activate 'Summary' tab
WinWaitActive($strPropWinTitle, "", 3)
#cs
If Not WinExists($strPropWinTitle) Then
    MsgBox(0, "Window does not exist", $strPropWinTitle)
    Exit
EndIf
#ce

$hProperties = WinGetHandle($strPropWinTitle, "")
If Not IsHWnd($hProperties) Then Exit

; Write the string and click OK button to save and dismiss dialog
$hEdit = ControlGetHandle($hProperties, "", "[CLASS:Edit; ID:321]")
If Not IsHWnd($hEdit) Then
    MsgBox(0, "Control handle error", "[CLASS:Edit; ID:321]")
    Exit
EndIf

ControlFocus($hProperties, "", $hEdit)
ControlSetText($hProperties, "", $hEdit, $strComment)
ControlClick($hProperties, "", "[CLASS:Button; ID:1]")

;retrieve comment text from file properties
$sComment = _GetExtProperty($file, 14)
;check COM error
If $g_eventerror = 1 Or @error <> 0 Then
    $g_eventerror = 0
    MsgBox(0, "COM Error", "COM: " & $sCOMError & @CRLF & "Error: " & @error)
EndIf

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sComment = ' & $sComment & @crlf & '>Error code: ' & @error & @crlf)

If StringCompare($strComment, $sComment) <> 0 Then
 ; MsgBox(0, "Error setting file comment property", "Comment string does not match $strComment")
Else
 ; MsgBox(0, "File comment property set", $sComment)
EndIf

Func ComErrorHandler()
    Local $sHexNumber = Hex($oMyError.number, 8)
    $sCOMError = StringStripWS($oMyError.windescription, 2)
    $g_eventerror = 1 ; something to check for when this function returns
    $oMyError.clear
EndFunc ;==>ComErrorHandler

;===============================================================================
; modified version: array return removed, object error handling added
; Function Name:    GetExtProperty($sPath,$iProp)
; Description:  Returns an extended property of a given file.
; Parameter(s):     $sPath - The path to the file you are attempting to retrieve an extended property from.
;   $iProp - The numerical value for the property you want returned
;   The properties are as follows:
;   Name = 0
;   Size = 1
;   Type = 2
;   DateModified = 3
;   DateCreated = 4
;   DateAccessed = 5
;   Attributes = 6
;   Status = 7
;   Owner = 8
;   Author = 9
;   Title = 10
;   Subject = 11
;   Category = 12
;   Pages = 13
;   Comments = 14
;   Copyright = 15
;   Artist = 16
;   AlbumTitle = 17
;   Year = 18
;   TrackNumber = 19
;   Genre = 20
;   Duration = 21
;   BitRate = 22
;   Protected = 23
;   CameraModel = 24
;   DatePictureTaken = 25
;   Dimensions = 26
;   Width = 27
;   Height = 28
;   Company = 30
;   Description = 31
;   FileVersion = 32
;   ProductName = 33
;   ProductVersion = 34
; Requirement(s): file specified in $spath must exist.
; Return Value(s): On Success - The extended file property
;   On Failure - 0, @Error - 1 (If file does not exist)
; Author(s):    Simucal (Simucal@gmail.com)
; Note(s):
;
;===============================================================================
Func _GetExtProperty($sPath, $iProp = 14)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then Return SetError(1, 0, "")
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate("shell.application")
    If Not IsObj($oShellApp) Then Return SetError(2, 0, "")
    $oDir = $oShellApp.NameSpace($sDir)
    If Not IsObj($oDir) Then Return SetError(3, 0, "")
    $oFile = $oDir.Parsename($sFile)
    If Not IsObj($oFile) Then Return SetError(4, 0, "")
    Local $sComment = $oDir.GetDetailsOf($oFile, $iProp)
    Return SetError(0, 0, $sComment)
EndFunc ;==>_GetExtProperty
Edited by Sh3llC043r

[size="5"] [/size]

Share this post


Link to post
Share on other sites
goldenix

ok this should be beginner proof.

Those functions above search for recursive functions & how they work. its very simple & useful once you understand it.

Edit that kafu script, I tried, sometimes it works, & sometimes not.

$File = 'explorer.exe'
$folder = 'C:\WINDOWS\'

;Based on gaFrost's FileExtProperties - kudos to simucal
$objShell = ObjCreate("Shell.Application")
$objFolder = $objShell.Namespace ($folder)
For $strFileName In $objFolder.Items
    If $objFolder.GetDetailsOf ($strFileName, 0) = $File Then
        $FileName            = $objFolder.GetDetailsOf ($strFileName, 0)
        $FileSize            = $objFolder.GetDetailsOf ($strFileName, 1)
        $FileType            = $objFolder.GetDetailsOf ($strFileName, 2)
        $FileModified        = $objFolder.GetDetailsOf ($strFileName, 3)
        $FileCreated         = $objFolder.GetDetailsOf ($strFileName, 4)
        $FileAccessed        = $objFolder.GetDetailsOf ($strFileName, 5)
        $FileReadyArchiving  = $objFolder.GetDetailsOf ($strFileName, 6)
        $ImageWidthxHeight   = $objFolder.GetDetailsOf ($strFileName, 26)
        $ImageWidth          = $objFolder.GetDetailsOf ($strFileName, 27)
        $ImageHeight         = $objFolder.GetDetailsOf ($strFileName, 28)
        ExitLoop
    EndIf
Next
ConsoleWrite($FileName & @CRLF)  ; etc...
ConsoleWrite($FileSize & @CRLF)
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
KaFu

Jess, just realize the first time that it's bound to the script running...

HotKeySet("{ESC}","_Exit")

_ShowFileProperties(@ScriptName)

While 1
sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc

Func _ShowFileProperties($sFile, $sVerb = "properties", $hWnd = 0)
    ; function by Rasim
    ; http://www.autoitscript.com/forum/index.php?showtopic=78236&view=findpost&p=565547

    Local Const $SEE_MASK_INVOKEIDLIST = 0xC
    Local Const $SEE_MASK_NOCLOSEPROCESS = 0x40
    Local Const $SEE_MASK_FLAG_NO_UI = 0x400

    Local $PropBuff, $FileBuff, $SHELLEXECUTEINFO

    $PropBuff = DllStructCreate("char[256]")
    DllStructSetData($PropBuff, 1, $sVerb)

    $FileBuff = DllStructCreate("char[256]")
    DllStructSetData($FileBuff, 1, $sFile)

    $SHELLEXECUTEINFO = DllStructCreate("int cbSize;long fMask;hwnd hWnd;ptr lpVerb;ptr lpFile;ptr lpParameters;ptr lpDirectory;" & _
            "int nShow;int hInstApp;ptr lpIDList;ptr lpClass;hwnd hkeyClass;int dwHotKey;hwnd hIcon;" & _
            "hwnd hProcess")

    DllStructSetData($SHELLEXECUTEINFO, "cbSize", DllStructGetSize($SHELLEXECUTEINFO))
    DllStructSetData($SHELLEXECUTEINFO, "fMask", $SEE_MASK_INVOKEIDLIST)
    DllStructSetData($SHELLEXECUTEINFO, "hwnd", $hWnd)
    DllStructSetData($SHELLEXECUTEINFO, "lpVerb", DllStructGetPtr($PropBuff, 1))
    DllStructSetData($SHELLEXECUTEINFO, "lpFile", DllStructGetPtr($FileBuff, 1))

    $aRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($SHELLEXECUTEINFO))
    If $aRet[0] = 0 Then Return SetError(2, 0, 0)

    Return $aRet[0]
EndFunc   ;==>_ShowFileProperties

Share this post


Link to post
Share on other sites
Fire

Jess, just realize the first time that it's bound to the script running...

Thanks so much KaFu it works.

goldenix thanks to you too.Solved.

:idea:


[size="5"] [/size]

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.