Sign in to follow this  
Followers 0
Gif

Shell Properties

5 posts in this topic

OK i want the properties of a folder/program. How do i do it quietly in AutoIt??

ShellExecute() with properties as a verb doesnt work for me. I ve also looked for shell.application object.. nothing there to.

Thanks in advance

Share this post


Link to post
Share on other sites



Hi, i have asked for this too (here), i even posted a bug report, the answer i found much later then i ask :) ...

Here it is:

HotKeySet("{Esc}", "OnExit")

$sFile = @ScriptName

_ShellExecuteEx($sFile, "", @ScriptDir, "properties")

$sWinText = StringTrimRight($sFile, 4)
WinWait("[CLASS:#32770]", $sWinText)
WinWaitClose("[CLASS:#32770]", $sWinText)

Func _ShellExecuteEx($sCmd, $Args = "", $sFolder = "", $Verb = "", $rState = @SW_SHOWNORMAL, $hWnd = 0)
    Local $struINFO = DllStructCreate("long;long;long;ptr;ptr;ptr;ptr;long;long;long;ptr;long;long;long;long")
    Local $struVerb = DllStructCreate("char[15];char")
    Local $struPath = DllStructCreate("char[255];char")
    Local $struArgs = DllStructCreate("char[255];char")
    Local $struWDir = DllStructCreate("char[255];char")
    
    DllStructSetData($struVerb, 1, $Verb)
    If StringRight($sCmd, 3) = "lnk" Then
        Local $aShortcutInfo = FileGetShortcut($sCmd)
        If IsArray($aShortcutInfo) Then
            DllStructSetData($struPath, 1, $aShortcutInfo[0])
            DllStructSetData($struWDir, 1, $aShortcutInfo[1])
            DllStructSetData($struArgs, 1, $aShortcutInfo[2])
            $rState = $aShortcutInfo[6]
        Else
            Return 0
        EndIf
    Else
        DllStructSetData($struPath, 1, $sCmd)
        DllStructSetData($struWDir, 1, $sFolder)
        DllStructSetData($struArgs, 1, $Args)
    EndIf

    DllStructSetData($struINFO, 1, DllStructGetSize($struINFO))
    DllStructSetData($struINFO, 2, BitOR(0xC, 0x40, 0x400))
    DllStructSetData($struINFO, 3, $hWnd)
    DllStructSetData($struINFO, 4, DllStructGetPtr($struVerb))
    DllStructSetData($struINFO, 5, DllStructGetPtr($struPath))
    DllStructSetData($struINFO, 6, DllStructGetPtr($struArgs))
    DllStructSetData($struINFO, 7, DllStructGetPtr($struWDir))
    DllStructSetData($struINFO, 8, $rState)

    Local $iRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($struINFO))
    Return $iRet[0]
EndFunc   ;==>_ShellExecuteEx

Func OnExit()
    Exit
EndFunc   ;==>OnExit

Only problem that when autoit script exits, the Properties dialog disappear too :P


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thank you so much, just when i found this, but you've saved me a lot of time :).

(To much work now..)

Share this post


Link to post
Share on other sites

I have modified this script a little bit. All I need it for is to open up the properties window of the My Documents folder. To do this however, it needs to open the registry and find the path of the my documents folder. Unfortuanatley this wont work if the registry value for Personal is %USERPROFILE%\My Documents. It cant find the path of %USERPROFILE% when read from the registry.

Func ChangeMyDocumentsPath()
    $sFile = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" , "Personal")

_ShellExecuteEx($sFile, "", @ScriptDir, "properties")

$sWinText = StringTrimRight($sFile, 4)
WinWait("[CLASS:#32770]", $sWinText)
WinWaitClose("[CLASS:#32770]", $sWinText)
EndFunc

Func _ShellExecuteEx($sCmd, $Args = "", $sFolder = "", $Verb = "", $rState = @SW_SHOWNORMAL, $hWnd = 0)
    Local $struINFO = DllStructCreate("long;long;long;ptr;ptr;ptr;ptr;long;long;long;ptr;long;long;long;long")
    Local $struVerb = DllStructCreate("char[15];char")
    Local $struPath = DllStructCreate("char[255];char")
    Local $struArgs = DllStructCreate("char[255];char")
    Local $struWDir = DllStructCreate("char[255];char")
   
    DllStructSetData($struVerb, 1, $Verb)
    If StringRight($sCmd, 3) = "lnk" Then
        Local $aShortcutInfo = FileGetShortcut($sCmd)
        If IsArray($aShortcutInfo) Then
            DllStructSetData($struPath, 1, $aShortcutInfo[0])
            DllStructSetData($struWDir, 1, $aShortcutInfo[1])
            DllStructSetData($struArgs, 1, $aShortcutInfo[2])
            $rState = $aShortcutInfo[6]
        Else
            Return 0
        EndIf
    Else
        DllStructSetData($struPath, 1, $sCmd)
        DllStructSetData($struWDir, 1, $sFolder)
        DllStructSetData($struArgs, 1, $Args)
    EndIf

    DllStructSetData($struINFO, 1, DllStructGetSize($struINFO))
    DllStructSetData($struINFO, 2, BitOR(0xC, 0x40, 0x400))
    DllStructSetData($struINFO, 3, $hWnd)
    DllStructSetData($struINFO, 4, DllStructGetPtr($struVerb))
    DllStructSetData($struINFO, 5, DllStructGetPtr($struPath))
    DllStructSetData($struINFO, 6, DllStructGetPtr($struArgs))
    DllStructSetData($struINFO, 7, DllStructGetPtr($struWDir))
    DllStructSetData($struINFO, 8, $rState)

    Local $iRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($struINFO))
    Return $iRet[0]
EndFunc  ;==>_ShellExecuteEx

Share this post


Link to post
Share on other sites

Yes, you sure can get the path from such a string as %userprofile%, all you need to do is use this:

Opt("ExpandEnvStrings", 1)

Otherwise, would not using the macro @MyDocumentsDir work? alternatively @DocumentsCommonDir ?

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  
Followers 0