File paths
Special folders
With all QM file functions (run, cop,
ren, del, FileExists,
str.searchpath, str.getfile and other, also in user-defined functions) and in
menus/toolbars, a file path can begin with a special folder string. There are
several ways to specify a special folder.
1. QM-defined special folder string enclosed in $.
- Example: "$desktop$\file.txt".
- To see available special folders, click SF button in a dialog, for example in
the Run Program dialog.
- QM-specific special folders:
- $qm$ - Quick Macros program folder, eg "C:\Program Files (x86)\Quick Macros 2" or "G:\PortableApps\QuickMacrosPortable\App\QuickMacros".
- $my qm$ - Quick Macros data folder, eg "C:\Users\Me\Documents\My QM" or "G:\PortableApps\QuickMacrosPortable\Data\My QM". Can be changed in Options -> Files.
- $temp qm$ - QM subfolder in user's temporary folder (special folder $temp$). Normally it is same as $temp$\QM. In portable QM it is same as $temp$\QM-portable, and QM deletes it when exits. The folder may not exist, but most QM file functions create it when creating a file or folder in it.
- $drive$ - drive of Quick Macros program folder, like "C:", "G:" or "\\server\share". This can be useful in portable QM, where drive letter is not constant.
- Special
folder CSIDLs.
{CSIDL_ADMINTOOLS, "Administrative Tools"},
{CSIDL_APPDATA, "AppData"},
{CSIDL_INTERNET_CACHE, "Cache"},
{CSIDL_CDBURN_AREA, "CD Burning"},
{CSIDL_PROGRAM_FILES_COMMON, "Common Files"},
{CSIDL_COOKIES, "Cookies"},
{CSIDL_DESKTOPDIRECTORY, "Desktop"},
{CSIDL_PERSONAL, "Documents"},
{CSIDL_PERSONAL, "My Documents"}, //alias
{CSIDL_PERSONAL, "Personal"}, //alias
{CSIDL_FAVORITES, "Favorites"},
{CSIDL_FONTS, "Fonts"},
{CSIDL_HISTORY, "History"},
{CSIDL_LOCAL_APPDATA, "Local AppData"},
//{?, "Local Settings"}, //no csidl. Dropped in QM 2.3.0.
{CSIDL_MYMUSIC, "My Music"},
{CSIDL_MYPICTURES, "My Pictures"},
{CSIDL_MYVIDEO, "My Video"},
{CSIDL_NETHOOD, "NetHood"},
//{CSIDL_PHOTOALBUMS, "Photoalbums"}, //Vista
//{CSIDL_PLAYLISTS, "Playlists"}, //Vista
{CSIDL_PRINTHOOD, "PrintHood"},
{CSIDL_PROGRAM_FILES, "Program Files"},
{CSIDL_PROGRAM_FILES, "PF"}, //alias
{CSIDL_PROGRAMS, "Programs"},
{CSIDL_RECENT, "Recent"},
//{CSIDL_RESOURCES, "Resources"}, //Vista
//{CSIDL_SAMPLE_MUSIC, "Sample Music"}, //Vista
//{CSIDL_SAMPLE_PLAYLISTS, "Sample Playlists"}, //Vista
//{CSIDL_SAMPLE_PICTURES, "Sample Pictures"}, //Vista
//{CSIDL_SAMPLE_VIDEOS, "Sample Videos"}, //Vista
{CSIDL_SENDTO, "SendTo"},
{CSIDL_STARTMENU, "Start Menu"},
{CSIDL_STARTUP, "Startup"},
//{CSIDL_ALTSTARTUP, "AltStartup"}, //?
{CSIDL_SYSTEM, "System"},
{CSIDL_QM_TEMP, "Temp"}, //no scidl. Normally CSIDL_LOCAL_APPDATA\Temp.
{CSIDL_TEMPLATES, "Templates"},
{CSIDL_PROFILE, "User Profile"}, //QM 2.3.0
{CSIDL_WINDOWS, "Windows"},
{CSIDL_COMMON_ADMINTOOLS, "Common Administrative Tools"},
{CSIDL_COMMON_APPDATA, "Common AppData"},
{CSIDL_COMMON_DESKTOPDIRECTORY, "Common Desktop"},
{CSIDL_COMMON_DOCUMENTS, "Common Documents"},
{CSIDL_COMMON_FAVORITES, "Common Favorites"},
{CSIDL_COMMON_MUSIC, "Common Music"},
{CSIDL_COMMON_MUSIC, "CommonMusic"}, //alias, fbc
{CSIDL_COMMON_PICTURES, "Common Pictures"},
{CSIDL_COMMON_PICTURES, "CommonPictures"}, //alias, fbc
{CSIDL_COMMON_PROGRAMS, "Common Programs"},
{CSIDL_COMMON_STARTMENU, "Common Start Menu"},
{CSIDL_COMMON_STARTUP, "Common Startup"},
//{CSIDL_COMMON_ALTSTARTUP, "Common AltStartup"}, //?
{CSIDL_COMMON_TEMPLATES, "Common Templates"},
{CSIDL_COMMON_VIDEO, "Common Video"},
{CSIDL_COMMON_VIDEO, "CommonVideo"}, //alias, fbc
{CSIDL_QM_QM, "QM"},
{CSIDL_QM_MYQM, "My QM"},
{CSIDL_QM_MYQM, "MyQM"}, //alias
{CSIDL_QM_TEMPQM, "Temp QM"}, //QM 2.3.5
{CSIDL_QM_DRIVE, "Drive"}, //QM 2.3.5
2. Environment variable name enclosed
in %.
- Example: "%temp%\file.txt".
- Environment variables are expanded
recursively (QM 2.2.0). For example, if value of environment variable v1 is
"$desktop$", then "%v1%" is expanded to full path of desktop
folder.
- Tip: You can create environment variables and then use them everywhere. Example: SetEnvVar "backup" "E:\_Backup". Use: run "%backup%". Such variables exist only in current process (QM or exe).
3. QM 2.2.0. CSIDL numeric value enclosed in $. For example, "$3$"
expands to ITEMIDLIST string (see below) of Control Panel. To see available
values, search for CSIDL in MSDN Library.
See also: str.expandpath.
ITEMIDLIST strings
Some objects in Window Explorer are not file system objects. Examples are Control
Panel folder and most objects in it. They cannot be accessed using a file system
path. They can be accessed using binary structures of type ITEMIDLIST.
To simplify it, some QM functions (run, menust/toolbars,
and some other) support ITEMIDLIST strings. These strings begin with "::
". They are inserted when you drag and drop a non-file-system object. They
also can be inserted using Run Program, Open File and Open Folder dialogs.
Examples:
run ":: 14001F50E04FD020EA3A6910A2D808002B30309D" ;;My Computer
run "$0x11$" ;;My Computer
run ":: 14001F50E04FD020EA3A6910A2D808002B30309D 14002E1E2020EC21EA3A6910A2DD08002B30309D A90000009CFFFFFF1D002500433A5C57494E444F57535C73797374656D33325C6465736B2E63706C00446973706C6179004368616E67652074686520617070656172616E6365206F6620796F7572206465736B746F702C207375636820617320746865206261636B67726F756E642C2073637265656E2073617665722C20636F6C6F72732C20666F6E742073697A65732C20616E642073637265656E207265736F6C7574696F6E2E00" ;;Display
run "$3$ A90000009CFFFFFF1D002500433A5C57494E444F57535C73797374656D33325C6465736B2E63706C00446973706C6179004368616E67652074686520617070656172616E6365206F6620796F7572206465736B746F702C207375636820617320746865206261636B67726F756E642C2073637265656E2073617665722C20636F6C6F72732C20666F6E742073697A65732C20616E642073637265656E207265736F6C7574696F6E2E00" ;;Display
run ":: " ;;Desktop
The root object is Desktop. Its string is ":: ". It is not the same
as "$desktop$, which is a file system folder.
File system objects also can be accessed using ITEMIDLIST. To insert ITEMIDLIST
string, Shift + drag and drop.
See also: PidlToStr, PidlFromStr.
File search paths, relative paths
Some functions (run, str.searchpath, GetFileIcon,
etc) don't require full path. Can be used only filename or relative path. Then they search in:
1. The QM directory. Before QM 2.3.3, run did not search here.
2. The current directory (GetCurDir/SetCurDir).
3. The 32-bit Windows system directory.
4. The 16-bit Windows system directory.
5. The Windows directory.
6. The directories that are listed in the PATH environment variable.
7. run and str.searchpath
also search in the registry "App Paths" key.
Some functions, including str.searchpath and GetFileIcon,
at first search in $My QM$ special folder.
With some functions, .\ at the beginning means current directory; ..\ at the beginning means one level up from current directory.
For example, if current directory is "c:\program files\quick macros 2",
then "..\" will be "c:\program files\", and "..\otherapp"
will be "c:\program files\otherapp". Also, whole path can be or contain "."
and "..".
Read more: File
names and paths
Shortcuts
When you drag and drop a shortcut to the QM code editor, it inserts run
with path of shortcut target. To insert shortcut path, Ctrl + drag and drop.
Notes
File functions may fail with mapped network drive paths (like "Z:\file"). Always use path like "\\server\share\file".
64-bit Windows has two System32 and Program Files folders. Read more.