Jump to content

Recommended Posts

Posted

I've found a script on this forum and this script opens special folders.

But I don't want it to open but return the path of the folder.

Can somebody help me.

Const $Internet_Explorer                         = 0x1
Const $Programs                                  = 0x2
Const $Control_Panel                             = 0x3
Const $Printers_and_Faxes                        = 0x4
Const $My_Documents                              = 0x5
Const $Favorites                                 = 0x6
Const $Startup                                   = 0x7
Const $My_Recent_Documents                       = 0x8
Const $SendTo                                    = 0x9
Const $Recycle_Bin                               = 0xa
Const $Start_Menu                                = 0xb
Const $My_Music                                  = 0xd
Const $My_Videos                                 = 0xe
Const $Desktop                                   = 0x10
Const $My_Computer                               = 0x11
Const $My_Network_Places                         = 0x12
Const $NetHood                                   = 0x13
Const $Fonts                                     = 0x14
Const $Templates                                 = 0x15
Const $All_Users_Start_Menu                      = 0x16
Const $All_Users_Programs                        = 0x17
Const $All_Users_Startup                         = 0x18
Const $All_Users_Desktop                         = 0x19
Const $Application_Data                          = 0x1a
Const $PrintHood                                 = 0x1b
Const $Local_Settings_Application_Data           = 0x1c
Const $All_Users_Favorites                       = 0x19
Const $Local_Settings_Temporary_Internet_Files   = 0x20
Const $Cookies                                   = 0x21
Const $Local_Settings_History                    = 0x22
Const $All_Users_Application_Data                = 0x23
Const $Windows                                   = 0x24
Const $System32                                  = 0x25
Const $Program_Files                             = 0x26
Const $My_Pictures                               = 0x27
Const $User_Profile                              = 0x28
Const $Common_Files                              = 0x2b
Const $All_Users_Templates                       = 0x2e
Const $Administrative_Tools                      = 0x2f
Const $Network_Connections                       = 0x31
Const $CD_Burning_Folder                         = 0x003b

ConsoleWrite(_Special_Folders($My_Documents) & @CRLF)

Func _Special_Folders($Folder)
    $objShell = ObjCreate("Shell.Application")
    $objShell.open($objShell.NameSpace($Folder))
    Return ?????
EndFunc
Posted

Func _Special_Folders($Folder)
     $objShell = ObjCreate("Shell.Application")
     $oNameSpace = $objShell.NameSpace($Folder)
     Return $oNameSpace.Title()
EndFunc   ;==>_Special_Folders

Try this.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

This looks more like it, thanks.

Is it possible to get the full path, not just only "my documents"?

Func _Special_Folders($Folder)
     $objShell = ObjCreate("Shell.Application")
     $oNameSpace = $objShell.NameSpace($Folder)
     Return $oNameSpace.Title()
EndFunc   ;==>_Special_Folders

Try this.

Posted

Sorry, posted the wrong snippet. :)

Func _Special_Folders($Folder)
     $objShell = ObjCreate("Shell.Application")
     Return  $objShell.NameSpace($Folder).Self.Path
EndFunc   ;==>_Special_Folders

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

  • Moderators
Posted

Building on BrewManNH's suggestion, you could throw it all into an array for visibility:

#include <Array.au3>

$objShell = ObjCreate("Shell.Application")
Local $aFolders[41][2]

$aFolders[0][0] = "Internet Explorer"
    $aFolders[0][1] = $objShell.NameSpace(0x1).Self.Path
$aFolders[1][0] = "Programs"
    $aFolders[1][1] = $objShell.NameSpace(0x2).Self.Path
$aFolders[2][0] = "Control Panel"
    $aFolders[2][1] = $objShell.NameSpace(0x3).Self.Path
$aFolders[3][0] = "Printer and Faxes"
    $aFolders[3][1] = $objShell.NameSpace(0x4).Self.Path
$aFolders[4][0] = "My Documents"
    $aFolders[4][1] = $objShell.NameSpace(0x5).Self.Path
$aFolders[5][0] = "Favorites"
    $aFolders[5][1] = $objShell.NameSpace(0x6).Self.Path
$aFolders[6][0] = "Startup"
    $aFolders[6][1] = $objShell.NameSpace(0x7).Self.Path
$aFolders[7][0] = "My Recent Documents"
    $aFolders[7][1] = $objShell.NameSpace(0x8).Self.Path
$aFolders[8][0] = "SendTo"
    $aFolders[8][1] = $objShell.NameSpace(0x9).Self.Path
$aFolders[9][0] = "Recycle Bin"
    $aFolders[9][1] = $objShell.NameSpace(0xa).Self.Path
$aFolders[10][0] = "Start Menu"
    $aFolders[10][1] = $objShell.NameSpace(0xb).Self.Path
$aFolders[11][0] = "My Music"
    $aFolders[11][1] = $objShell.NameSpace(0xd).Self.Path
$aFolders[12][0] = "My Videos"
    $aFolders[12][1] = $objShell.NameSpace(0xe).Self.Path
$aFolders[13][0] = "Desktop"
    $aFolders[13][1] = $objShell.NameSpace(0x10).Self.Path
$aFolders[14][0] = "My Computer"
    $aFolders[14][1] = $objShell.NameSpace(0x11).Self.Path
$aFolders[15][0] = "My Network Places"
    $aFolders[15][1] = $objShell.NameSpace(0x12).Self.Path
$aFolders[16][0] = "NetHood"
    $aFolders[16][1] = $objShell.NameSpace(0x13).Self.Path
$aFolders[17][0] = "Fonts"
    $aFolders[17][1] = $objShell.NameSpace(0x14).Self.Path
$aFolders[18][0] = "Templates"
    $aFolders[18][1] = $objShell.NameSpace(0x15).Self.Path
$aFolders[19][0] = "All Users Start Menu"
    $aFolders[19][1] = $objShell.NameSpace(0x16).Self.Path
$aFolders[20][0] = "All Users Programs"
    $aFolders[20][1] = $objShell.NameSpace(0x17).Self.Path
$aFolders[21][0] = "All Users Startup"
    $aFolders[21][1] = $objShell.NameSpace(0x18).Self.Path
$aFolders[22][0] = "All Users Desktop"
    $aFolders[22][1] = $objShell.NameSpace(0x19).Self.Path
$aFolders[23][0] = "Application Data"
    $aFolders[23][1] = $objShell.NameSpace(0x1a).Self.Path
$aFolders[24][0] = "PrintHood"
    $aFolders[24][1] = $objShell.NameSpace(0x1b).Self.Path
$aFolders[25][0] = "Local Settings Application Data"
    $aFolders[25][1] = $objShell.NameSpace(0x1c).Self.Path
$aFolders[26][0] = "All Users Favorites"
    $aFolders[26][1] = $objShell.NameSpace(0x19).Self.Path
$aFolders[27][0] = "Local Settings Temporary Internet Files"
    $aFolders[27][1] = $objShell.NameSpace(0x20).Self.Path
$aFolders[28][0] = "Cookies"
    $aFolders[28][1] = $objShell.NameSpace(0x21).Self.Path
$aFolders[29][0] = "Local Settings History"
    $aFolders[29][1] = $objShell.NameSpace(0x22).Self.Path
$aFolders[30][0] = "All Users Application Data"
    $aFolders[30][1] = $objShell.NameSpace(0x23).Self.Path
$aFolders[31][0] = "Windows"
    $aFolders[31][1] = $objShell.NameSpace(0x24).Self.Path
$aFolders[32][0] = "System32"
    $aFolders[32][1] = $objShell.NameSpace(0x25).Self.Path
$aFolders[33][0] = "Program Files"
    $aFolders[33][1] = $objShell.NameSpace(0x26).Self.Path
$aFolders[34][0] = "My Pictures"
    $aFolders[34][1] = $objShell.NameSpace(0x27).Self.Path
$aFolders[35][0] = "User Profile"
    $aFolders[35][1] = $objShell.NameSpace(0x28).Self.Path
$aFolders[36][0] = "Common Files"
    $aFolders[36][1] = $objShell.NameSpace(0x2b).Self.Path
$aFolders[37][0] = "All Users Templates"
    $aFolders[37][1] = $objShell.NameSpace(0x2e).Self.Path
$aFolders[38][0] = "Administrative Tools"
    $aFolders[38][1] = $objShell.NameSpace(0x2f).Self.Path
$aFolders[39][0] = "Network Connections"
    $aFolders[39][1] = $objShell.NameSpace(0x31).Self.Path
$aFolders[40][0] = "CD Burning Folder"
    $aFolders[40][1] = $objShell.NameSpace(0x003b).Self.Path

_ArrayDisplay($aFolders)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)

 

Building on BrewManNH's suggestion, you could throw it all into an array for visibility:

#include <Array.au3>

$objShell = ObjCreate("Shell.Application")
Local $aFolders[41][2]

$aFolders[0][0] = "Internet Explorer"
    $aFolders[0][1] = $objShell.NameSpace(0x1).Self.Path
$aFolders[1][0] = "Programs"
    $aFolders[1][1] = $objShell.NameSpace(0x2).Self.Path
$aFolders[2][0] = "Control Panel"
    $aFolders[2][1] = $objShell.NameSpace(0x3).Self.Path
$aFolders[3][0] = "Printer and Faxes"
    $aFolders[3][1] = $objShell.NameSpace(0x4).Self.Path
$aFolders[4][0] = "My Documents"
    $aFolders[4][1] = $objShell.NameSpace(0x5).Self.Path
$aFolders[5][0] = "Favorites"
    $aFolders[5][1] = $objShell.NameSpace(0x6).Self.Path
$aFolders[6][0] = "Startup"
    $aFolders[6][1] = $objShell.NameSpace(0x7).Self.Path
$aFolders[7][0] = "My Recent Documents"
    $aFolders[7][1] = $objShell.NameSpace(0x8).Self.Path
$aFolders[8][0] = "SendTo"
    $aFolders[8][1] = $objShell.NameSpace(0x9).Self.Path
$aFolders[9][0] = "Recycle Bin"
    $aFolders[9][1] = $objShell.NameSpace(0xa).Self.Path
$aFolders[10][0] = "Start Menu"
    $aFolders[10][1] = $objShell.NameSpace(0xb).Self.Path
$aFolders[11][0] = "My Music"
    $aFolders[11][1] = $objShell.NameSpace(0xd).Self.Path
$aFolders[12][0] = "My Videos"
    $aFolders[12][1] = $objShell.NameSpace(0xe).Self.Path
$aFolders[13][0] = "Desktop"
    $aFolders[13][1] = $objShell.NameSpace(0x10).Self.Path
$aFolders[14][0] = "My Computer"
    $aFolders[14][1] = $objShell.NameSpace(0x11).Self.Path
$aFolders[15][0] = "My Network Places"
    $aFolders[15][1] = $objShell.NameSpace(0x12).Self.Path
$aFolders[16][0] = "NetHood"
    $aFolders[16][1] = $objShell.NameSpace(0x13).Self.Path
$aFolders[17][0] = "Fonts"
    $aFolders[17][1] = $objShell.NameSpace(0x14).Self.Path
$aFolders[18][0] = "Templates"
    $aFolders[18][1] = $objShell.NameSpace(0x15).Self.Path
$aFolders[19][0] = "All Users Start Menu"
    $aFolders[19][1] = $objShell.NameSpace(0x16).Self.Path
$aFolders[20][0] = "All Users Programs"
    $aFolders[20][1] = $objShell.NameSpace(0x17).Self.Path
$aFolders[21][0] = "All Users Startup"
    $aFolders[21][1] = $objShell.NameSpace(0x18).Self.Path
$aFolders[22][0] = "All Users Desktop"
    $aFolders[22][1] = $objShell.NameSpace(0x19).Self.Path
$aFolders[23][0] = "Application Data"
    $aFolders[23][1] = $objShell.NameSpace(0x1a).Self.Path
$aFolders[24][0] = "PrintHood"
    $aFolders[24][1] = $objShell.NameSpace(0x1b).Self.Path
$aFolders[25][0] = "Local Settings Application Data"
    $aFolders[25][1] = $objShell.NameSpace(0x1c).Self.Path
$aFolders[26][0] = "All Users Favorites"
    $aFolders[26][1] = $objShell.NameSpace(0x19).Self.Path
$aFolders[27][0] = "Local Settings Temporary Internet Files"
    $aFolders[27][1] = $objShell.NameSpace(0x20).Self.Path
$aFolders[28][0] = "Cookies"
    $aFolders[28][1] = $objShell.NameSpace(0x21).Self.Path
$aFolders[29][0] = "Local Settings History"
    $aFolders[29][1] = $objShell.NameSpace(0x22).Self.Path
$aFolders[30][0] = "All Users Application Data"
    $aFolders[30][1] = $objShell.NameSpace(0x23).Self.Path
$aFolders[31][0] = "Windows"
    $aFolders[31][1] = $objShell.NameSpace(0x24).Self.Path
$aFolders[32][0] = "System32"
    $aFolders[32][1] = $objShell.NameSpace(0x25).Self.Path
$aFolders[33][0] = "Program Files"
    $aFolders[33][1] = $objShell.NameSpace(0x26).Self.Path
$aFolders[34][0] = "My Pictures"
    $aFolders[34][1] = $objShell.NameSpace(0x27).Self.Path
$aFolders[35][0] = "User Profile"
    $aFolders[35][1] = $objShell.NameSpace(0x28).Self.Path
$aFolders[36][0] = "Common Files"
    $aFolders[36][1] = $objShell.NameSpace(0x2b).Self.Path
$aFolders[37][0] = "All Users Templates"
    $aFolders[37][1] = $objShell.NameSpace(0x2e).Self.Path
$aFolders[38][0] = "Administrative Tools"
    $aFolders[38][1] = $objShell.NameSpace(0x2f).Self.Path
$aFolders[39][0] = "Network Connections"
    $aFolders[39][1] = $objShell.NameSpace(0x31).Self.Path
$aFolders[40][0] = "CD Burning Folder"
    $aFolders[40][1] = $objShell.NameSpace(0x003b).Self.Path

_ArrayDisplay($aFolders)
#include <array.au3>
 
global $folders[41][2]
global $oS = objcreate("Shell.Application")
 
for $i = 0 to ubound($folders) - 1
    local $sfolder = $oS.namespace($i + 1)
    if not isobj($sfolder) then continueloop
    $folders[$i][0] = $sfolder.title()
    $folders[$i][1] = $sfolder.self.path
next
 
_arraydisplay($folders)

outputs folders in installed language as well

Edited by Shaggi

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Posted

Thanks for the script, I think I can use that.

 

Building on BrewManNH's suggestion, you could throw it all into an array for visibility:

#include <Array.au3>

$objShell = ObjCreate("Shell.Application")
Local $aFolders[41][2]

$aFolders[0][0] = "Internet Explorer"
    $aFolders[0][1] = $objShell.NameSpace(0x1).Self.Path
$aFolders[1][0] = "Programs"
    $aFolders[1][1] = $objShell.NameSpace(0x2).Self.Path
$aFolders[2][0] = "Control Panel"
    $aFolders[2][1] = $objShell.NameSpace(0x3).Self.Path
$aFolders[3][0] = "Printer and Faxes"
    $aFolders[3][1] = $objShell.NameSpace(0x4).Self.Path
$aFolders[4][0] = "My Documents"
    $aFolders[4][1] = $objShell.NameSpace(0x5).Self.Path
$aFolders[5][0] = "Favorites"
    $aFolders[5][1] = $objShell.NameSpace(0x6).Self.Path
$aFolders[6][0] = "Startup"
    $aFolders[6][1] = $objShell.NameSpace(0x7).Self.Path
$aFolders[7][0] = "My Recent Documents"
    $aFolders[7][1] = $objShell.NameSpace(0x8).Self.Path
$aFolders[8][0] = "SendTo"
    $aFolders[8][1] = $objShell.NameSpace(0x9).Self.Path
$aFolders[9][0] = "Recycle Bin"
    $aFolders[9][1] = $objShell.NameSpace(0xa).Self.Path
$aFolders[10][0] = "Start Menu"
    $aFolders[10][1] = $objShell.NameSpace(0xb).Self.Path
$aFolders[11][0] = "My Music"
    $aFolders[11][1] = $objShell.NameSpace(0xd).Self.Path
$aFolders[12][0] = "My Videos"
    $aFolders[12][1] = $objShell.NameSpace(0xe).Self.Path
$aFolders[13][0] = "Desktop"
    $aFolders[13][1] = $objShell.NameSpace(0x10).Self.Path
$aFolders[14][0] = "My Computer"
    $aFolders[14][1] = $objShell.NameSpace(0x11).Self.Path
$aFolders[15][0] = "My Network Places"
    $aFolders[15][1] = $objShell.NameSpace(0x12).Self.Path
$aFolders[16][0] = "NetHood"
    $aFolders[16][1] = $objShell.NameSpace(0x13).Self.Path
$aFolders[17][0] = "Fonts"
    $aFolders[17][1] = $objShell.NameSpace(0x14).Self.Path
$aFolders[18][0] = "Templates"
    $aFolders[18][1] = $objShell.NameSpace(0x15).Self.Path
$aFolders[19][0] = "All Users Start Menu"
    $aFolders[19][1] = $objShell.NameSpace(0x16).Self.Path
$aFolders[20][0] = "All Users Programs"
    $aFolders[20][1] = $objShell.NameSpace(0x17).Self.Path
$aFolders[21][0] = "All Users Startup"
    $aFolders[21][1] = $objShell.NameSpace(0x18).Self.Path
$aFolders[22][0] = "All Users Desktop"
    $aFolders[22][1] = $objShell.NameSpace(0x19).Self.Path
$aFolders[23][0] = "Application Data"
    $aFolders[23][1] = $objShell.NameSpace(0x1a).Self.Path
$aFolders[24][0] = "PrintHood"
    $aFolders[24][1] = $objShell.NameSpace(0x1b).Self.Path
$aFolders[25][0] = "Local Settings Application Data"
    $aFolders[25][1] = $objShell.NameSpace(0x1c).Self.Path
$aFolders[26][0] = "All Users Favorites"
    $aFolders[26][1] = $objShell.NameSpace(0x19).Self.Path
$aFolders[27][0] = "Local Settings Temporary Internet Files"
    $aFolders[27][1] = $objShell.NameSpace(0x20).Self.Path
$aFolders[28][0] = "Cookies"
    $aFolders[28][1] = $objShell.NameSpace(0x21).Self.Path
$aFolders[29][0] = "Local Settings History"
    $aFolders[29][1] = $objShell.NameSpace(0x22).Self.Path
$aFolders[30][0] = "All Users Application Data"
    $aFolders[30][1] = $objShell.NameSpace(0x23).Self.Path
$aFolders[31][0] = "Windows"
    $aFolders[31][1] = $objShell.NameSpace(0x24).Self.Path
$aFolders[32][0] = "System32"
    $aFolders[32][1] = $objShell.NameSpace(0x25).Self.Path
$aFolders[33][0] = "Program Files"
    $aFolders[33][1] = $objShell.NameSpace(0x26).Self.Path
$aFolders[34][0] = "My Pictures"
    $aFolders[34][1] = $objShell.NameSpace(0x27).Self.Path
$aFolders[35][0] = "User Profile"
    $aFolders[35][1] = $objShell.NameSpace(0x28).Self.Path
$aFolders[36][0] = "Common Files"
    $aFolders[36][1] = $objShell.NameSpace(0x2b).Self.Path
$aFolders[37][0] = "All Users Templates"
    $aFolders[37][1] = $objShell.NameSpace(0x2e).Self.Path
$aFolders[38][0] = "Administrative Tools"
    $aFolders[38][1] = $objShell.NameSpace(0x2f).Self.Path
$aFolders[39][0] = "Network Connections"
    $aFolders[39][1] = $objShell.NameSpace(0x31).Self.Path
$aFolders[40][0] = "CD Burning Folder"
    $aFolders[40][1] = $objShell.NameSpace(0x003b).Self.Path

_ArrayDisplay($aFolders)
Posted (edited)

Nice al those Ideas.

Thanks for your script!

#include <array.au3>
 
global $folders[41][2]
global $oS = objcreate("Shell.Application")
 
for $i = 0 to ubound($folders) - 1
    local $sfolder = $oS.namespace($i + 1)
    if not isobj($sfolder) then continueloop
    $folders[$i][0] = $sfolder.title()
    $folders[$i][1] = $sfolder.self.path
next
 
_arraydisplay($folders)

outputs folders in installed language as well

Edited by nend
Posted

Just a other question where can you find some information about these objects.

It seems that "self.path" whas the answer, where can you find that?

  • Moderators
Posted

There are a ton of websites where you can find information and examples, but I usually go back to MSDN and do a search:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb787844(v=vs.85).aspx

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

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