It is currently November 29th, 2020, 8:30 pm

FileChoose [Ver.1.1.0]

Share and get help with Plugins and Addons
User avatar
Posts: 12
Joined: March 20th, 2018, 9:53 am
Location: China

FileChoose [Ver.1.1.0]

Post by Setsukka »

Ver. Dec. 08 2019
_Change the code for saving icon image to solve some bugs.

Ver. Oct. 31 2019
_Add $Icon$ for use.
_Add new bang "Resolve N Path" for use.


The idea comes up when I am working on my skin suite. I find I need a method to open a dialog to choose a file/folder/image without refreshing the skin. So I work for about a week on this plugin.
The plugin works like "RainFile.exe". FileChoose.dll enable users to open a windows dialog to choose a file/folder/image, and then get the name, extension, path.

I develop the plugin on win10, VS2017. In theory the plugin can be used on WinXP and greater, but I have tested it only on win10 and win7.

FileChoose Sample_1.1.0.2.rmskin
SouceCode :

Code: Select all


Command1=[!Log "$Name$"][!Log "$Path$"][!Log """$[Path]$"""][!Log "$Ext$"][!Log "$NameAndExt$"][!Log "$Icon$"]

LeftMouseUpAction=[!CommandMeasure MeasureChoose "ChooseFile 1"]
  • UseNewStyle ( Default : 0 )
If set to 1, a new method will be used.
  • GetTarget ( Default : 1 )
If set to 1, the ".lnk" file and ".url" file will be dereferanced to get the path of the target.
If failed to get the target, return the path of the shortcut file, or copy the shortcut if "CopyLink = 1".
Only be valid when choosing a file.
NOTE : Whether GetTarget = 1 or not, the name will be that of the shortcut file rather than the target.
  • AllowNonstorageFolder ( Default : 0 )
If set to 1, a nonstorage folder is allowed for choose.
Only be valid when choosing a folder and "UseNewStyle = 1".
NOTE : Nonstorage folder:
like "My Computer", whose path is "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
like some folder packed in the rar (DONT CHOOSE IT, PLEASE)

  • CopyLink ( Default : 0 )
If set to 1, when fail to get the target, the original shortcut file will be copied to a cache folder.
In this case, the path we get will be the path of the copy.
The cache folder must exist, which can be set with the option "LinkCache".
If failed to copy it, return the path of the original one.
NOTE : The name of the copy will be the same as the original one.
If there exist a file of the same name in the cache folder, REPLACE IT.

  • LinkCache ( Default : #CurrentPath# )
Set the cache folder of the shortcut file.
The path must exist. And the folder path should contain a "\" in the end of the string.
  • GetIcon ( Default : 0 )
If set to 1, will copy the icon into the cache folder.
The cache folder must exist, which can be set with the option "LinkCache".
If failed to get the icon, return a empty string.
Folders, images (*.png, *.jpg, *.jpeg, *.bmp, *.ico), these files' icon will not be copied.
As for images, we return the file path to use as the icon path.
As for folders, just return a string "(IconCache\)folder.png", WHETHER THE FILE "folder.png" EXIST OR NOT!
If there exist a file of the same name in the cache folder, REPLACE IT.

  • IconCache ( Default : #CurrentPath# )
Set the cache folder of the shortcut file.
The path must exist. And the folder path should contain a "\" in the end of the string.
Remember to add a image "folder.png" in the folder for use.
  • IconSize ( Default : 3 )
Set the size of the icon.
Valid Value :
0 : Small, 16x16
1 : Medium, 32x32
2 : Large, 48x48
3 : ExtraLarge, 256x256
NOTE : For some files who dont have a extralarge icon, get the large icon(48x48) instead.
  • ReturnValue ( Default : Path )
This option define the type of the string value of the measure.
Valid value: Path / WholePath / Name / Extensions / NameAndExt / Icon
The meaning of the value will be introduced later.
NOTE : In most time, I suggest to use the bang command instead of the string value,
but when using lua script, it can be surprisingly useful.

  • Command N
Like the inputtext.dll, when finished choosing file/folder/image, the bangs in the corresponding command is executed.
Some $Variable$ you may use:
$Path$ / $[Path]$ / $Name$ / $Ext$ / $NameAndExt$ / $Icon$
The meaning of the value will be introduced later.

  • "ChooseFile N"
  • "ChooseFolder N"
  • "ChooseImage N"
N is a number, which should correspond with the Option "Command N".
  • "Resolve N PATH"
N is a number, which should correspond with the Option "Command N".
PATH is a string of file path. (DONT CONTAIN ANY "")
This bang enable user to first get a filepath in other method, and then use this plugin to get the information of the file. In the end, execute the "Command N".

Meaning of the value
Lets see the example to show the meaning of the ReturnValue and the $Variables$ :
We assume to choose "AIMP_SHORTCUT.lnk", whose target is "D:\Program\AIMP\AIMP.exe".
ReturnValue | $Variables$ | Sample Value

Path | $Path$ | D:\Program\AIMP\AIMP.exe
WholePath | $[Path]$ | ["D:\Program\AIMP\AIMP.exe"]
Name | $Name$ | AIMP_SHORTCUT
Extensions | $Ext$ | exe (empty if folder)
NameAndExt | $NameAndExt$ | AIMP.exe
Icon | $Icon$ | (IconCache\)AIMP_SHORTCUT_lnk.png

  • Use $[Path]$
The Event Variable $[Path]$ contains "" and [], so when using it in bangs, please write like this : """$[Path]$"""
  • Cache folders
Be sure the path of the cache folder contains a "\" in the end of the string.
The default value #CurrentPath# contains "\" in the end itself.
For example :
LinkCache = #CurrentPath# (OK)
LinkCache = #CurrentPath#LinkCache\ (OK)
LinkCache = #CurrentPath#LinkCache (Not OK)
We dont check if the folder really exist now, so you should take care.
If unfortunately you forgot, and write LinkCache = #CurrentPath#LinkCache, but the parent folder #CurrentPath# does exist, the string "LinkCache" will be seen as the prefix of the file. This means, you will get a file "LinkCacheAIMP.lnk" instead of "AIMP.lnk" in the parent folder.
Similarly, if IconCache = #@#Images\IconCache, a file "IconCachefolder.png" should exist in the folder "#@#Images\".
  • Use various bangs with the same "N"
The "N" is no need bounded with "ChooseFile" or other type of bangs.
You can surely use part or all of the bangs with the same "N". Just as below:

Code: Select all

Command1=[!SetVariable Path "$Path$"][!Update]

Text=Choose File
LeftMouseUpAction=[!CommandMeasure MeasureChoose "ChooseFile 1"]

Text=Choose Folder
LeftMouseUpAction=[!CommandMeasure MeasureChoose "ChooseFolder 1"]
  • Use it in lua script
It is not a good way to simply write CommandN=[!CommandMeasure MeasureScript "MyFunction('$Name$','$Path$','$Icon$')"]
because $Path$, $Icon$ often contain "\".
Therefore, I prefer to use the return value of the measure.
Codes are below. This little trick is also suitable for other plugins, like InputText.dll
If you just need one string of them, you dont need to update the measure.

Code: Select all

Codes in Rainmeter files (.ini)
Command1=[!CommandMeasure MeasureScript "ChooseOver()"]

Codes in lua files (.lua)
function ChooseOver()
    -- Get the Measure
    local Measure=SKIN:GetMeasure('MeasureChoose')
    -- Get Path
    local Path=Measure:GetStringValue()
    -- Get Icon
    local Icon=Measure:GetStringValue()
    -- Get Name
    local Name=Measure:GetStringValue()
You do not have the required permissions to view the files attached to this post.
Last edited by Setsukka on December 8th, 2019, 3:02 pm, edited 5 times in total.
Posts: 1
Joined: October 23rd, 2019, 3:36 pm

Re: FileChoose [Ver.]

Post by dujianaliuli »

Great job. It's amazing. I'm using it. :thumbup: :thumbup:
Posts: 53
Joined: August 26th, 2019, 10:42 am

Re: FileChoose [Ver.]

Post by gkmaz9 »

Thank you. This is very useful. :D
User avatar
Rainmeter Sage
Posts: 11827
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: FileChoose [Ver.1.1.0]

Post by balala »

An extremely useful and interesting plugin for me. Didn't know about it, but now I'm playing with it and I like it very much.
A question however: is there any way to get open certain folder when I run the plugin? I mean that when I use a [!CommandMeasure "MeasureChoose" "ChooseFile 1"] bang, in the opening window the last path is retained. I'd like to can open certain folder, instead of the last one. Is this possible?
Same for the case when I open the plugin to choose a folder (with the [!CommandMeasure "MeasureChoose" "ChooseFolder 1"] bang).

Congratulations to the author, great work.