Jump to content

How to retrieve "Description of a File"


Recommended Posts

Hi All,

The next code will retrieve all files with the extention .scr and will create a combo box with all the files

#include <File.au3>
#include <GUIConstants.au3>
#include <Array.au3>

local $FileList=_FileListToArray(@SystemDir, "*.scr", 1)
$MyGui=GUICreate("List ScreenSavers", 300,100)
$MyList=GuiCtrlCreateCombo("", 20, 20, 260, 200)


For $I = 1 to $FileList[0]
    GuiCtrlSetData($MyList, $FileList[$i])
Next
GUISetState()

While 1
    $msg = GUIGetMsg ()
    Select 
        Case $msg = 0
        Case $msg = $GUI_EVENT_CLOSE 
            exit
    EndSelect
Wend

When i select a screensaver in the display properties ... The files are displayed with there complete description for example "Screen Saver with Logon" this is the logon.scr. I want to retrieve there description instead of there filename.. is this possible ? and how to

Thnx

Emiel

Edited by Emiel Wieldraaijer

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

Hi,

this way?

#include <File.au3>
#include <GUIConstants.au3>
#include <Array.au3>

Local $FileList = _FileListToArray(@SystemDir, "*.scr", 1)
$MyGui = GUICreate("List ScreenSavers", 300, 100)
$MyList = GUICtrlCreateCombo("", 20, 20, 260, 200)
$det_B = GUICtrlCreateButton("Details", 20, 60, 100, 20)


For $I = 1 To $FileList[0]
    GUICtrlSetData($MyList, $FileList[$I])
Next
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = 0
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        case $msg = $det_B
            _showDetails()
    EndSelect
WEnd

Func _showDetails()
    $prop = _GetExtProperty(@SystemDir & '\' & GUICtrlRead($MyList), -1)
    _ArrayDisplay($prop, "Property Array")
EndFunc   ;==>_showDetails


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

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

maybe this helps you out:

#include<Array.au3>
Global $filePath = 'c:\Downloads\AutoIt-Skripte\Meine aktiven Skripte\LoginTM\FirefoxTM_Ver2.0.exe'
Global $info = _getFileInfo($filePath)

If Not IsArray($info) Then
    MsgBox(16, 'Error', 'File not found!')
    Exit (0)
EndIf

_ArrayDisplay($info, 'FileInfo')

Func _getFileInfo($path)
    If Not FileExists($path) Then Return -1
    Local $info_A[12]
    Local $string_A[12] = ['FileVersion', 'FileDescription', 'LegalCopyright', 'Comments', 'InternalName', _
            'ProductName', 'CompanyName', 'ProductVersion', 'LegalTrademarks', 'PrivateBuild', 'OriginalFilename', 'SpecialBuild']
    For $i = 0 To UBound($info_A) - 1
        $info_A[$i] = FileGetVersion($path, $string_A[$i])
    Next
    Return $info_A
EndFunc   ;==>_getFileInfo

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thnx

YOU ARE MEGA

Emiel

Hi,

glad I could help.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi Mega,

maybe you could help me with this .. or should i create a new topic

In the first example i'd like to remove logon.scr from the array

So i use

$SSFound = _ArraySearch ($FileList, "logon.scr")

_Arraydelete ($FileList[$i], $SSFOUND)

GuiCtrlSetData($MyList, $FileList[$i])

but this will not work..

could you tell me what i'm doing wrong

Thnx

Emiel

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

Hi,

sure

#include <File.au3>
#include <GUIConstants.au3>
#include <Array.au3>

Local $FileList = _FileListToArray(@SystemDir, "*.scr", 1)
$MyGui = GUICreate("List ScreenSavers", 300, 100)
$MyList = GUICtrlCreateCombo("", 20, 20, 260, 200)
$det_B = GUICtrlCreateButton("Details", 20, 60, 100, 20)

$SSFound = _ArraySearch ($FileList, "logon.scr")
_Arraydelete($FileList, $SSFOUND)

For $I = 1 To UBound($FileList)-1
    GUICtrlSetData($MyList, $FileList[$I])
Next
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = 0
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        case $msg = $det_B
            _showDetails()
    EndSelect
WEnd

Func _showDetails()
    $prop = _GetExtProperty(@SystemDir & '\' & GUICtrlRead($MyList), -1)
    _ArrayDisplay($prop, "Property Array")
EndFunc   ;==>_showDetails


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

The problem was that you have to use the array name without [$i] in the func.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thnx MEGA..

YOU'RE THE "MEGA" MAN

HI,

:shocked: let's see how long it takes to get the next question done. :-)

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...