It is currently April 25th, 2024, 4:36 pm

NirCmd Tutorial

Tips and Tricks from the Rainmeter Community
DumbDude1994
Posts: 43
Joined: November 12th, 2009, 2:04 am

NirCmd Tutorial

Post by DumbDude1994 »

Introduction
NirCmd is a program created by NirSoft. There is more information about it at http://www.nirsoft.net/utils/nircmd2.html. What it lets Rainmeter do is send commands to your computer much like the command prompt does. Along with that it can do things that the command prompt cannot do, like open your disc drive or creating a shortcut on the desktop.

Installation
Since NirCmd isn’t included in Rainmeter you need to download it and put it somewhere simple. I downloaded it from http://www.softpedia.com/get/System/System-Miscellaneous/NirCmd.shtml. Extract the folder and put it in the Rainmeter addons folder (C:\Program Files\Rainmeter\Addons for most users). After placing it in the folder run nircmd.exe and click copy to windows directory. Now you can use NirCmd with rainmeter.

Usage
NirCmd should be put into a meter in your skin under a bang or command such as LeftMouseUpAction or RightMouseDownAction. For example LeftMouseUpAction=!execute["#ADDONSPATH#NirCmd\NirCmd.exe" PUTCOMMANDHERE]. LeftMouseUpAction being what thing is happening to set off the !execute. The execute telling rainmeter to do what is in the brackets. “#ADDONSPATH#NirCmd\NirCmd.exe” is the program to execute and PUTCOMMANDHERE is where you will put the command that’s for later. (This can also be put in the [Rainmeter] section if you want to be able to click anywhere on the skin for it to work)

For Later (aka the commands)
The commands are what you are sending to NirCmd. Here are some of the commands but there is no way that I could describe how to use and put in every command, there are simply too many. You can find all of them at the first link I provided.

Sendkeys-used to send keystrokes to Windows applications. List at http://cpap.com.br/orlando/SendKeysMore.asp.
Example-["#ADDONSPATH#NirCmd\NirCmd.exe" sendkey 0xB5 press] this will open Windows Media Player (for me, it might open a different media player for you)

Infobox-opens a message box with a title and message. (infobox “message” “title”)
Example- ["#ADDONSPATH#NirCmd\NirCmd.exe" infobox “this is a message box” “message”]

Open Program-Opens a program and optionally hides it from view (if hide is on the only way to close is task manager). (exec show/hide “program path”)
Example- ["#ADDONSPATH#NirCmd\NirCmd.exe” exec show “c:\ Program Files\7-Zip\7zFM.exe”]

Normal Command Prompt Entry- Used to send commands that the command prompt can use normally.
Example-["#ADDONSPATH#NirCmd\NirCmd.exe” execmd "command"]

Speak Words-Tells the system to speak from a file or text. (speak text/file “textspoken/filepath”)
Example- ["#ADDONSPATH#NirCmd\NirCmd.exe” speak text “This is text.”]

Test Skin
Make a folder in your skins folder and label it NirCmd Tester. In that folder make a file named NirCmd.ini and a file named text.txt paste this code into the NirCmd.ini file

Code: Select all

[Rainmeter]
DynamicWindowSize=1

[MeasureCommandToBeSent]
Measure=Plugin
Plugin=WebParser.dll
Url=file://#CURRENTPATH#\text.txt
RegExp="(?siU)<cmd>(.*)</cmd>"
StringIndex=1
UpdateRate=.2

[MeterCommand]
MeasureName=MeasureCommandToBeSent
Meter=STRING
StringEffect=BORDER
FontEffectColor=0,0,0,255
SolidColor=0,0,0,1
X=0
Y=0
FontColor=255,255,255,255
FontFace="Trebuchet MS"
FontSize=16
AntiAlias=1
StringIndex=1
LeftMouseUpAction=!execute ["#ADDONSPATH#NirCmd\NirCmd.exe" [MeasureCommandToBeSent]]

[MeterOpentxt]
Meter=String
AntiAlias=1
StringEffect=BORDER
FontEffectColor=0,0,0,255
SolidColor=0,0,0,1
Text=OPEN
LeftMouseUpAction=!Execute ["#CURRENTPATH#text.txt"]["#ADDONSPATH#NirCmd\NirCmd.chm"]
X=0
Y=4R
FontSize=30
FontColor=255,255,255,255
and type <cmd></cmd> into the text.txt file and save it. Open the skin and you can now click OPEN. This opens the NirCmd Help file and the text.txt file (if it isn't open already) so you can copy/paste the commands from Command Reference between the <cmd>and</cmd> tags in the text.txt file. Save it and then click the text that appears a few seconds later. That will execute your command with NirCmd to tell you if you did it right.

(if there are any grammatical errors message me don't post them here)
Last edited by dragonmage on September 16th, 2010, 6:37 am, edited 4 times in total.
Reason: Added some space between the command examples for readability. Some improvements to the skin. Will add some instructions for using NirCmd scripts soon.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: NirCmd Tutorial

Post by jsmorley »

Looks like good information. Let's have dragonmage, who is our current nircmd guy, take a look to see if he has anything he would add / change and I will get this added to Tips and Tricks on the main site.

Thanks for this!
DumbDude1994
Posts: 43
Joined: November 12th, 2009, 2:04 am

Re: NirCmd Tutorial

Post by DumbDude1994 »

Yeah if it wasn't for dragonmage I wouldn't have even known about NirCmd.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: NirCmd Tutorial

Post by dragonmage »

I have some things to add, but don't have the time to do so now. DumbDude would you mind if I just edit your original post or would you rather me make a separate post?
DumbDude1994
Posts: 43
Joined: November 12th, 2009, 2:04 am

Re: NirCmd Tutorial

Post by DumbDude1994 »

I'd actually prefer you edited the first post. (easier for someone to read)
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: NirCmd Tutorial

Post by dragonmage »

I made some changes to the skin, but also discovered that using webparser to get the command does not allow for using #CURRENTPATH# (or any builtin Variables for that matter). So I may have to do a separate skin for demonstrating how to use scripts in NirCmd.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: NirCmd Tutorial

Post by dragonmage »

Completely reworked the skin, so the tutorial needs a major rewrite.
DumbDude1994
Posts: 43
Joined: November 12th, 2009, 2:04 am

Re: NirCmd Tutorial

Post by DumbDude1994 »

grr i havent been active in the forms or done anything lately involving rainmeter so im gonna have to relearn everything so meh time to get on tht
User avatar
Church Punk
Posts: 25
Joined: September 17th, 2010, 9:26 am

Re: NirCmd Tutorial

Post by Church Punk »

why isnt this pinned? i think we all skinners (newbies and experienced) need these to be sticky :)
Image
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: NirCmd Tutorial

Post by dragonmage »

Things like this will eventually be going into the main site. Most of us have just been stretched to thin these last months.