Page 1 of 3

Eject USB

Posted: March 20th, 2021, 9:00 pm
by Sam12345
Can rainmeter eject a USB?
I was randomly messing with a skin and I wondered if I could add to a skin that on one click it would eject a USB drive.
It is difficult for me to eject with the normal windows ejector, as I have removed the right part of my toolbar. In its place, I have a launcher, which I would like to add an ejector. Is it possible?

Re: Eject USB

Posted: March 20th, 2021, 9:31 pm
by balala
Sam12345 wrote: March 20th, 2021, 9:00 pm Can rainmeter eject a USB?
I was randomly messing with a skin and I wondered if I could add to a skin that on one click it would eject a USB drive.
It is difficult for me to eject with the normal windows ejector, as I have removed the right part of my toolbar. In its place, I have a launcher, which I would like to add an ejector. Is it possible?
Nativelly not, but a third party app or a plugin might help.
In the Disks skin of my Mirage, I used the UDisk plugin for this (by cfixd), which is excelent. Previously I tried out some other apps as well, but I'm much more satisfied by this plugin.
If interested, try it out and let us (me) know if questions arise.

Re: Eject USB

Posted: March 21st, 2021, 8:15 pm
by Sam12345
balala wrote: March 20th, 2021, 9:31 pm let us (me) know if questions arise.
Iv'e been attempting to use this Plugin, but once again, i require your assistance... :oops:
This is the code I have so far, but clicking on the image doesn't do anything

Code: Select all

[MeasureUDisk]
Measure=Plugin
Plugin=UDisk
Drive=Removable
Mode=Normal
;-------------------------------------------------------------
;-------------------------------------------------------------
[MeterEjectUSB]
Meter=Image
ImageName=#@#Pictures.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterEjectUSB ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterEjectUSB ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=[!CommandMeasure MeasureUDisk Remove]
Minor point, when I added DriveMeasure=MeasureUDisk to the measures section it crashed and closed Rainmeter :confused:

Re: Eject USB

Posted: March 21st, 2021, 8:20 pm
by Sam12345
I just noticed, I get this in the error log

Re: Eject USB

Posted: March 21st, 2021, 8:43 pm
by balala
Sam12345 wrote: March 21st, 2021, 8:15 pm Iv'e been attempting to use this Plugin, but once again, i require your assistance... :oops:
This is the code I have so far, but clicking on the image doesn't do anything

Code: Select all

[MeasureUDisk]
Measure=Plugin
Plugin=UDisk
Drive=Removable
Mode=Normal
;-------------------------------------------------------------
;-------------------------------------------------------------
[MeterEjectUSB]
Meter=Image
ImageName=#@#Pictures.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterEjectUSB ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterEjectUSB ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=[!CommandMeasure MeasureUDisk Remove]
Replace the LeftMouseUpAction option of the [MeterEjectUSB] meter with the following one: [!CommandMeasure "MeasureUDisk" "Remove_X:"]. Make sure you're using the correct drive letter in the bang.
Sam12345 wrote: March 21st, 2021, 8:15 pm Minor point, when I added DriveMeasure=MeasureUDisk to the measures section it crashed and closed Rainmeter :confused:
The DriveMeasure option has to be added to the child measures, not to the parent measure, which I believe you did. If I'm right, this can indeed cause Rainmeter to crash, because an infinite loop is created.
Sam12345 wrote: March 21st, 2021, 8:20 pm I just noticed, I get this in the error log
There might be some erros in your code probably. Post the whole code please.

Re: Eject USB

Posted: March 21st, 2021, 9:03 pm
by Sam12345
balala wrote: March 21st, 2021, 8:43 pm Replace the LeftMouseUpAction option of the [MeterEjectUSB] meter with the following one: [!CommandMeasure "MeasureUDisk" "Remove_X:"]. Make sure you're using the correct drive letter in the bang.
I want it to eject all drives, can that be done?
balala wrote: March 21st, 2021, 8:43 pm Post the whole code please.

Code: Select all

[Rainmeter]
Update=100
Author=Connect-R, Sam P

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterBg]
Meter=Shape
X=0
Y=0
AntiAlias=1

;-------------------------------------------------------------
;-------------------------------------------------------------

[styleText1]
style=Text
Font=Segoe UI
FontSize=11
FontWeight=
Fontcolor=255, 255, 255, 255
Center=CenterBottom


;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureRecycleBin]
Measure=PLUGIN
RecycleType=COUNT
Drives=ALL

[MeasureBinAction]
Measure=Calc
Formula=MeasureRecycleBin
IfAboveAction=! [!HideMeter MeterBinEmpty][!ShowMeter MeterBinFull]
IfAboveValue=0
IfEqualAction=! [!HideMeter MeterBinFull][!ShowMeter MeterBinEmpty]
IfEqualValue=0

[MeasureWiFiPercent]
Measure=PLUGIN
Plugin=WifiStatus.dll
WiFiInfoType=QUALITY
Substitute=" ":""
UpdateDivider=1

[MeasureIconCalc]
Measure=CALC
Formula=((100 >= MeasureWiFiPercent) && (90 <= MeasureWiFiPercent) ? 5 : ((90 > MeasureWiFiPercent) && (60 <= MeasureWiFiPercent) ? 4 : ((60 > MeasureWiFiPercent) && (30 < MeasureWiFiPercent) ? 3 : ((30 >= MeasureWiFiPercent) && (10 < MeasureWiFiPercent) ? 2 : ((MeasureWiFiPercent <= 10) && (0 < MeasureWiFiPercent) ? 1 : 0)))))
UpdateDivider=1

[MeasureUser]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=USER_NAME

[MeasureText]
Measure=String

[MeasureUDisk]
Measure=Plugin
Plugin=UDisk
Drive=Removable

;-------------------------------------------------------------
;-------------------------------------------------------------
300


[MeterText]
Meter=STRING
MeterStyle=styleText1
MeasureName=MeasureText
Text=Sam P
X=0r
Y=4
AntiAlias=1


[MeterMyComputer]
Meter=Image
ImageName=#@#My Computer.png
X=60r
Y=0
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterMyComputer ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterMyComputer ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=Explorer Shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

[MeterLogOff]
Meter=Image
ImageName=#@#ShutDown.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterLogOff ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterLogOff ImageTint 255,255,255][!Redraw]
LeftMouseDoubleClickAction=[rundll32.exe user32.dll,LockWorkStation "run"]


[MeterBinEmpty]
Meter=Image
ImageName=#@#Empty.png
X=50r
Y=r
W=25
Hidden=0
AntiAlias=1
MouseOverAction=[!SetOption MeterBinEmpty ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterBinEmpty ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=! [::{645FF040-5081-101B-9F08-00AA002F954E}]

[MeterBinFull]
Meter=Image
ImageName=#@#Full.png
X=r
Y=r
W=25
Hidden=1
AntiAlias=1
MouseOverAction=[!SetOption MeterBinFull ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterBinFull ImageTint 255,255,255][!Redraw]
RightMouseDownAction=! [! "MeasureRecycleBin EmptyBin"]
LeftMouseUpAction=! [::{645FF040-5081-101B-9F08-00AA002F954E}]

[MeterGoogle]
Meter=Image
ImageName=#@#Google.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterGoogle ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterGoogle ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=! ["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"]

[MeterWiFi]
Meter=Image
MeasureName=MeasureIconCalc
ImageName=#@#/%1.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterWiFi ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterWiFi ImageTint 255,255,255][!Redraw]
PreserveAspectRatio=1
DynamicVariables=1
LeftMouseUpAction=!["control.exe" "ncpa.cpl"]

[MeterEjectUSB]
Meter=Image
ImageName=#@#Pictures.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterEjectUSB ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterEjectUSB ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=[!CommandMeasure "MeasureUDisk" "Remove:"]

Re: Eject USB

Posted: March 22nd, 2021, 8:43 pm
by balala
Sam12345 wrote: March 21st, 2021, 9:03 pm I want it to eject all drives, can that be done?
Of corse. Replace the LeftMouseUpAction option of the [MeterEjectUSB] meter (LeftMouseUpAction=[!CommandMeasure "MeasureUDisk" "Remove:"]) with the following one: LeftMouseUpAction=[!CommandMeasure "MeasureUDisk" "RemoveDrive"].
Sam12345 wrote: March 21st, 2021, 9:03 pm

Code: Select all

[Rainmeter]
Update=100
Author=Connect-R, Sam P

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterBg]
Meter=Shape
X=0
Y=0
AntiAlias=1

;-------------------------------------------------------------
;-------------------------------------------------------------

[styleText1]
style=Text
Font=Segoe UI
FontSize=11
FontWeight=
Fontcolor=255, 255, 255, 255
Center=CenterBottom


;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureRecycleBin]
Measure=PLUGIN
RecycleType=COUNT
Drives=ALL

[MeasureBinAction]
Measure=Calc
Formula=MeasureRecycleBin
IfAboveAction=! [!HideMeter MeterBinEmpty][!ShowMeter MeterBinFull]
IfAboveValue=0
IfEqualAction=! [!HideMeter MeterBinFull][!ShowMeter MeterBinEmpty]
IfEqualValue=0

[MeasureWiFiPercent]
Measure=PLUGIN
Plugin=WifiStatus.dll
WiFiInfoType=QUALITY
Substitute=" ":""
UpdateDivider=1

[MeasureIconCalc]
Measure=CALC
Formula=((100 >= MeasureWiFiPercent) && (90 <= MeasureWiFiPercent) ? 5 : ((90 > MeasureWiFiPercent) && (60 <= MeasureWiFiPercent) ? 4 : ((60 > MeasureWiFiPercent) && (30 < MeasureWiFiPercent) ? 3 : ((30 >= MeasureWiFiPercent) && (10 < MeasureWiFiPercent) ? 2 : ((MeasureWiFiPercent <= 10) && (0 < MeasureWiFiPercent) ? 1 : 0)))))
UpdateDivider=1

[MeasureUser]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=USER_NAME

[MeasureText]
Measure=String

[MeasureUDisk]
Measure=Plugin
Plugin=UDisk
Drive=Removable

;-------------------------------------------------------------
;-------------------------------------------------------------
300


[MeterText]
Meter=STRING
MeterStyle=styleText1
MeasureName=MeasureText
Text=Sam P
X=0r
Y=4
AntiAlias=1


[MeterMyComputer]
Meter=Image
ImageName=#@#My Computer.png
X=60r
Y=0
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterMyComputer ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterMyComputer ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=Explorer Shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

[MeterLogOff]
Meter=Image
ImageName=#@#ShutDown.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterLogOff ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterLogOff ImageTint 255,255,255][!Redraw]
LeftMouseDoubleClickAction=[rundll32.exe user32.dll,LockWorkStation "run"]


[MeterBinEmpty]
Meter=Image
ImageName=#@#Empty.png
X=50r
Y=r
W=25
Hidden=0
AntiAlias=1
MouseOverAction=[!SetOption MeterBinEmpty ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterBinEmpty ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=! [::{645FF040-5081-101B-9F08-00AA002F954E}]

[MeterBinFull]
Meter=Image
ImageName=#@#Full.png
X=r
Y=r
W=25
Hidden=1
AntiAlias=1
MouseOverAction=[!SetOption MeterBinFull ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterBinFull ImageTint 255,255,255][!Redraw]
RightMouseDownAction=! [! "MeasureRecycleBin EmptyBin"]
LeftMouseUpAction=! [::{645FF040-5081-101B-9F08-00AA002F954E}]

[MeterGoogle]
Meter=Image
ImageName=#@#Google.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterGoogle ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterGoogle ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=! ["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"]

[MeterWiFi]
Meter=Image
MeasureName=MeasureIconCalc
ImageName=#@#/%1.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterWiFi ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterWiFi ImageTint 255,255,255][!Redraw]
PreserveAspectRatio=1
DynamicVariables=1
LeftMouseUpAction=!["control.exe" "ncpa.cpl"]

[MeterEjectUSB]
Meter=Image
ImageName=#@#Pictures.png
X=50r
Y=r
W=25
AntiAlias=1
MouseOverAction=[!SetOption MeterEjectUSB ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterEjectUSB ImageTint 255,255,255][!Redraw]
LeftMouseUpAction=[!CommandMeasure "MeasureUDisk" "Remove:"]
I see a few problems in this code:
  • Remove the orphan exclmation marks, from options like IfAboveAction and IfEqualAction of the [MeasureBinAction] measure
    (IfAboveAction=! [!HideMeter MeterBinEmpty][!ShowMeter MeterBinFull] and IfEqualAction=! [!HideMeter MeterBinFull][!ShowMeter MeterBinEmpty]), because they are not needed and in fact are preventing the options in which are they used, to work. They are causing the Invalid bang: ! error mesaages in the log, which can be seen on the image you've posted previously. Such exclamation marks are existing in more places (on meters like [MeasureBinAction], [MeterBinEmpty], [MeterBinFull] and[MeterGoogle]), you should remove all of them.
  • The [MeasureText] measure (which has a single Measure=String option, without any other), seems completely useless.
  • The [MeasureRecycleBin] measure is missing the Plugin= option and as such, it causes an error message in the log. Add back the missing Plugin=RecycleManager option. Additionally note that even if it indeed was a plugin, in meantime RecycleManager became a measure, so you could replace the Measure=Plugin and the missing Plugin=RecycleManager options with the single Measure=RecycleManager option.
  • The MouseOverAction and MouseLeaveAction options of meters like [MeterMyComputer], [MeterLogOff], [MeterBinEmpty], [MeterBinFull], [MeterGoogle], [MeterWiFi] or [MeterEjectUSB] are missing, an otherwise needed, [!UpdateMeter "MeterMyComputer"] bang. These options were looking initially this way (I'm posting here only the options of the [MeterMyComputer] meter, but the other ones are the same):

    Code: Select all

    [MeterMyComputer]
    ...
    MouseOverAction=[!SetOption MeterMyComputer ImageTint 255,255,255,100][!Redraw]
    MouseLeaveAction=[!SetOption MeterMyComputer ImageTint 255,255,255][!Redraw]
    Correctly and completely, these options should look this way:

    Code: Select all

    [MeterMyComputer]
    ...
    MouseOverAction=[!SetOption MeterMyComputer ImageTint 255,255,255,100][!UpdateMeter "MeterMyComputer"][!Redraw]
    MouseLeaveAction=[!SetOption MeterMyComputer ImageTint 255,255,255][!UpdateMeter "MeterMyComputer"][!Redraw]
    See the added [!UpdateMeter "MeterMyComputer"] bangs in both options. Without them, the [!Redraw] bang are completely useless, because redrawing the skin, without updating the appropriate meter (in this case [MeterMyComputer]), is useless, or even harmful, executing a bang, which makes no sense without an update.

Re: Eject USB

Posted: March 22nd, 2021, 9:18 pm
by Sam12345
balala wrote: March 22nd, 2021, 8:43 pm Of corse. Replace the LeftMouseUpAction option of the [MeterEjectUSB] meter (LeftMouseUpAction=[!CommandMeasure "MeasureUDisk" "Remove:"]) with the following one: LeftMouseUpAction=[!CommandMeasure "MeasureUDisk" "RemoveDrive"].
Thanks :thumbup:
balala wrote: March 22nd, 2021, 8:43 pm I see a few problems in this code:
  • Remove the orphan exclmation marks, from options like IfAboveAction and IfEqualAction of the [MeasureBinAction] measure
    (IfAboveAction=! [!HideMeter MeterBinEmpty][!ShowMeter MeterBinFull] and IfEqualAction=! [!HideMeter MeterBinFull][!ShowMeter MeterBinEmpty]), because they are not needed and in fact are preventing the options in which are they used, to work. They are causing the Invalid bang: ! error mesaages in the log, which can be seen on the image you've posted previously. Such exclamation marks are existing in more places (on meters like [MeasureBinAction], [MeterBinEmpty], [MeterBinFull] and[MeterGoogle]), you should remove all of them.
I was editing the code and I saw that using something like !action ir something wasn't needed, when removing them I must have left the ! in. :great:
balala wrote: March 22nd, 2021, 8:43 pm [*]The [MeasureText] measure (which has a single Measure=String option, without any other), seems completely useless.
A relic of some code I was experimenting with... I forgot to remove the whole thing - thanks for pointing it out :thumbup:
balala wrote: March 22nd, 2021, 8:43 pm [*]The [MeasureRecycleBin] measure is missing the Plugin= option and as such, it causes an error message in the log. Add back the missing Plugin=RecycleManager option. Additionally note that even if it indeed was a plugin, in meantime RecycleManager became a measure, so you could replace the Measure=Plugin and the missing Plugin=RecycleManager options with the single Measure=RecycleManager option.
The original code was last updated in 2018 as far as I can tell, probably before it became a measure
balala wrote: March 22nd, 2021, 8:43 pm [*]The MouseOverAction and MouseLeaveAction options of meters like [MeterMyComputer], [MeterLogOff], [MeterBinEmpty], [MeterBinFull], [MeterGoogle], [MeterWiFi] or [MeterEjectUSB] are missing, an otherwise needed, [!UpdateMeter "MeterMyComputer"] bang. These options were looking initially this way (I'm posting here only the options of the [MeterMyComputer] meter, but the other ones are the same):

Code: Select all

[MeterMyComputer]
...
MouseOverAction=[!SetOption MeterMyComputer ImageTint 255,255,255,100][!Redraw]
MouseLeaveAction=[!SetOption MeterMyComputer ImageTint 255,255,255][!Redraw]
Correctly and completely, these options should look this way:

Code: Select all

[MeterMyComputer]
...
MouseOverAction=[!SetOption MeterMyComputer ImageTint 255,255,255,100][!UpdateMeter "MeterMyComputer"][!Redraw]
MouseLeaveAction=[!SetOption MeterMyComputer ImageTint 255,255,255][!UpdateMeter "MeterMyComputer"][!Redraw]
See the added [!UpdateMeter "MeterMyComputer"] bangs in both options. Without them, the [!Redraw] bang are completely useless, because redrawing the skin, without updating the appropriate meter (in this case [MeterMyComputer]), is useless, or even harmful, executing a bang, which makes no sense without an update.[/list]
I done it, but I don't see much difference :confused:

Thanks for your help! :rosegift: :thumbup:
PS. What do you use to to make symbols for rainmeter skins? :Whistle

Re: Eject USB

Posted: March 22nd, 2021, 9:34 pm
by balala
Sam12345 wrote: March 22nd, 2021, 9:18 pm Thanks :thumbup:
Did it work?
Sam12345 wrote: March 22nd, 2021, 9:18 pm I was editing the code and I saw that using something like !action ir something wasn't needed, when removing them I must have left the ! in. :great:
It happens, but the problem is that the remaining exclamation mark cause the options not to work and add error messages in the log.
Sam12345 wrote: March 22nd, 2021, 9:18 pm The original code was last updated in 2018 as far as I can tell, probably before it became a measure
Doesn't matter, you can use it as a plugin, but don't forget to add the Plugin=RecycleManager option.
Sam12345 wrote: March 22nd, 2021, 9:18 pm I done it, but I don't see much difference :confused:
The difference is that the meter is updated immediately, it doesn't wait the next update cycle to update. Indeed don't really see a difference, but as said !Redraw alone, without !UpdateMeter (or !ShowMeter / !HideMeter) doesn't make too much sense.
Sam12345 wrote: March 22nd, 2021, 9:18 pm PS. What do you use to to make symbols for rainmeter skins? :Whistle
What kind of symbols are you talking about?

Additional question: why do you update the skin ten times per second (using the Update=100 option in the [Rainmeter] section). There is nothing (at least as far as I can say), which justifys this. I think the default Update=1000 would be perfect in this case.

Re: Eject USB

Posted: March 22nd, 2021, 9:42 pm
by Sam12345
balala wrote: March 22nd, 2021, 9:34 pm Did it work?
Yup, thanks :thumbup:
balala wrote: March 22nd, 2021, 9:34 pm The difference is that the meter is updated immediately, it doesn't wait the next update cycle to update. Indeed don't really see a difference, but as said !Redraw alone, without !UpdateMeter (or !ShowMeter / !HideMeter) doesn't make too much sense.
I thought it felt snappier, but I told my self it was my imagination :?
balala wrote: March 22nd, 2021, 9:34 pm What kind of symbols are you talking about?
For example, I want to create an image for the USB ejector as the one now isn't good. I could just download a photo of the internet and resize it, but I want to make one that matches the rest of the skin.
balala wrote: March 22nd, 2021, 9:34 pm why do you update the skin ten times per second (using the Update=100 option in the [Rainmeter] section). There is nothing (at least as far as I can say), which justifys this. I think the default Update=1000 would be perfect in this case.
O.O I don't remember changing that, I must have done it by mistake. Thanks for pointing it out :thumbup: