DonationCoder.com Forum

DonationCoder.com Software => Find And Run Robot => Mouser's Zone => FARR Plugins and Aliases => Topic started by: nontroppo on September 10, 2005, 09:51 AM

Title: NirCmd Setup, a guide of sorts
Post by: nontroppo on September 10, 2005, 09:51 AM
OK, here is a preliminary guide to use NirCmd. The most complex part really is the Regex, because we want to be able to optionally specify options, but not be forced to. So here is the regex:

cmd(?:\s|)([^\s]*)(?:\s|)([^\s]*)(?:\s|)([^\s]*)(?:\s|)([^\s]*)

Don't get too scared! This is basically just composed of two sections repeated 4 times:

(?:\s|)
The "?:" simply stops anything captured being used by FARR in the $$# bits. "\s" means white space (like a space or tab) and "|" means or, and as there is nothing after it it means "or nothing". In English that chunk means match one whitespace or nothing, but don't capture it. We want to be able to match nothing because we may just want to type in "cmd" without anything else.

([^\s]*)
The "[^\s]" means any character EXCEPT a whitespace, and the * means 0 or more of the previous characters. So this means match 0 or more characters as long as they are not whitespaces. As we dont use "?:", then these will get captured into $$1, $$2, $$3 and $$4 for each of these blocks.

This pairing is repeated 4 times to give us the chance to put in up to 4 variables to NirCmd. OK, here are some commands (change c:\windows\ to wherever you put nircmd.exe):

screensaver | c:\windows\nircmd.exe screensaver
lock PC | c:\windows\nircmd.exe lockws
monitor (on/off/low) $$1 | c:\windows\nircmd.exe monitor $$1
setres (width) (height) (depth) $$1 $$2 $$3 | c:\windows\nircmd.exe setdisplay $$1 $$2 $$3
changevol(+#/-#) $$1 | c:\windows\nircmd.exe changesysvolume $$1
mute (0/1) $$1 | c:\windows\nircmd.exe mutesysvolume $$1
reboot | c:\windows\nircmd.exe qboxcom "Do you want to reboot ?" "question" exitwin reboot
raise (window) $$1 | c:\windows\nircmd.exe win activate stitle "$$1" $$2
settop (window) (0/1) $$1 $$2 | c:\windows\nircmd.exe win settopmost stitle "$$1" $$2
compliment $$1 | c:\windows\nircmd.exe infobox "Wow $$1, you're really great!"

Now you'll notice some commands don't need any additional input, yet others do. In this scheme when you activate FARR, you first type "cmd" to activate the group, now typing in additional info will start to fill out the fields for the various options.

One important point is you need to turn off digit keys for launching as it will interfere with several nircmd's (see below as I could get digit escaping to work)

So an example:

cmd 1 F6 - mutes volume
cmd 0 F6 - unmutes volume
cmd mouser (then click compliment as it is after F9) - compliments mouser! ;)

Please add your own NirCmd's to this thread.

to mouser:
I had a couple of problems: 1st although c:\windows\ is in my system path, FARR did not find nircmd.exe there; shouldn't FARR look for apps in the system path? 2nd was that I tried using \1 to escape numbers so I didn't need to turn off digit launching - however typing in the "\" seems to stop the group from working - the titles all get removed and numbers keys then stop working...
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on September 10, 2005, 10:59 AM
great! going to try it now myself!
and it sounds like that regex string will actually be useful to other commands as well, so thats cool.

i will try to fix both issues you raised and post a new version.
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on September 10, 2005, 11:12 AM
the other alternative would be to have a separate group for each nircommand, so for example:

regexp = "nirvolume (.*)"
result list:
"nircmd volume $$1 | c:\windows\nircmd.exe changesysvolume $$1"

advantages:
you only get the 1 item in your results list and can hit enter to launch it instead of # key
you dont have to worry about having too many commands to fit in results list.

disadvantages:
you have to create more groups
you cant just type cmd to get list of all commands (though if you prefix all by nir that would help)
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on September 10, 2005, 12:17 PM
thanks nontroppo, the nirccommand stuff is working great here! fun!

ps. new version is up which should fix the 2 issues pointed out here.
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on September 10, 2005, 12:17 PM
ps.  does the nickname "nontroppo" mean anything?
Title: Re: NirCmd Setup, a guide of sorts
Post by: nontroppo on September 10, 2005, 12:50 PM
Yes, I had originally done single commands, but I like regex so the all-in-one flexible list was more fun! As you say, that regex can be used for any command that expects 0 or more additional entries.

I'll go off and test the new version.  :)

And non troppo is Italian for "not too much", but my definition comes from its use in classical music, whereby it is used by a composer to relativise a direction for the musicians; "Lento ma non troppo" means slowly, but not to slowly or slowly, more or less. It fits into my polemic for relativism and deconstruction.
Title: Re: NirCmd Setup, a guide of sorts
Post by: lanux128 on September 21, 2005, 04:04 AM
hi there nontroppo,

is it possible to do the same thing with autohotkey scripts? i mean, to create group containing ahk scripts which by selecting them will call up autohotkey to execute the script...

thanks in advance...

best regards,
lanux
Title: Re: NirCmd Setup, a guide of sorts
Post by: rjbull on September 21, 2005, 09:45 AM
Would people who like nircmd also like Steve Gibson's Wizmo?

=== begin quote ===
Wizmo is a multipurpose miscellaneous Windows utility that provides an array of single-click functions that are missing from Windows. Triggered by a single mouse click, it can do things like power down your system's displays, activate your screen saver, change or mute the audio volume, restart, reboot, or shutdown your system, and much more. It even includes a rather cool built-in "Graviton" screen saver that simulates the motion of any number of mutually gravitationally attracted celestial objects.
=== end quote ===
 
Gibson Research  http://www.grc.com  then find the freeware section
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on September 21, 2005, 10:58 AM
i'm just finishing importing+exporting+pasting of group aliases files, so it will be easy to share these aliases, so yeah, keep 'em coming!
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on July 02, 2007, 08:13 PM
now that we have standalone alias files, with ability to specify custom icons, i think it would be WONDERFUL if someone could volunteer to create a nice full nircmd alias file, and nontroppo has done most of the work already.  i know hamradio would help find+make icons for it if help is needed.

anyone want to volunteer?
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on July 04, 2007, 02:26 PM
Here's a starter alias pack for nircmd, based on nontroppo's aliases above.

It includes some icons by hamradio, and the nircmd.exe itself, all ready to go -- just put it in your AliasGroups\Installed directory of farr and restart (or maybe just open up options and close options will reload new aliases).

You can see now the idea of alias packs as totally self-contains addons you can install into your farr and share with others.

Note that we still need people to improve this alias file and add some more icons, etc., so by all means please improve it and send it or post it to me so it can be official.

Title: Re: NirCmd Setup, a guide of sorts
Post by: jgpaiva on July 17, 2007, 07:17 PM
Here's my (slightly modified) version of the alias above.

[ You are not allowed to view attachments ]

I added entries for shutdown/reboot/logoff/standby, made each of the entries become an isolated item (so that you don't have to type "cmd" at the beggining), added icons for the new ones, and now "cmd" works both as a list and as a practical example of how to use each of the alias.

Try it!

[edit] changed one little thing: the "lock pc" alias wasn't working, it had to be changed to "lockpc" [/edit]
[edit2] fixed error mentioned below about standby [/edit]
[edit3] "stole" image that lanux had below. Hope lanux won't get mad at me ;) [/edit3]

[edit4]Download removed. Please see this thread (https://www.donationcoder.com/forum/index.php?topic=9365.msg69700#msg69700) for more info [/edit4]
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on July 17, 2007, 07:21 PM
love it!!!  :-*
Title: Re: NirCmd Setup, a guide of sorts
Post by: lanux128 on July 17, 2007, 07:40 PM
looks cool! great job, jgpaiva.. :Thmbsup:

[ You are not allowed to view attachments ]
Title: Re: NirCmd Setup, a guide of sorts
Post by: edbro on July 17, 2007, 08:18 PM
I'm having a bit of trouble trying to find where I'm supposed to put this. Right now I have the entire nircmd folder in the /Aliasgroups/Mycustom folder. The "nircmd icons" folder is in the "nircmd" folder. I'm not getting all the commands to show up and the icons don't show at all. Am I doing this correctly? Do I need to configure anything inside FARR to tell it about the new alias group?
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on July 17, 2007, 08:46 PM
thats a fine place to put it, BUT you might want to put the subdir in the Installed folder directory since its not something you are supposed to be editing.

then just go to FARR options and close options, that should get FARR to rediscover all alias files.
Title: Re: NirCmd Setup, a guide of sorts
Post by: edbro on July 17, 2007, 08:58 PM
Well, I must be doing something wrong. I put the entire nircmd folder in /Aliasgroups/installed and this is what I get:
[ You are not allowed to view attachments ]
The alias shows up in FARR options as shown here:
[ You are not allowed to view attachments ]
Why don't I get the full set of commands with the icons?

Edit: I also have trouble with this inline attachment thing. The images are in the opposite order. This way of attaching images is pretty screwy. You can't preview them and it is impossible to see from the code exactly what you have attached.
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on July 17, 2007, 09:03 PM
what version of FARR do you have?
Title: Re: NirCmd Setup, a guide of sorts
Post by: lanux128 on July 17, 2007, 09:17 PM
edbro, i think you have an existing nircmd alias under the name "cmd", if i'm not mistaken.. disable that alias then the new one will be ok.. :)
Title: Re: NirCmd Setup, a guide of sorts
Post by: lanux128 on July 17, 2007, 09:22 PM
btw, the screenshots provided a clue - check the difference.. :) each of them have slightly different items..

new (jgpaiva's version)
(https://www.donationcoder.com/forum/index.php?action=dlattach;topic=884.0;attach=19960;image)

old (non-troppo's version)
(https://www.donationcoder.com/forum/index.php?action=dlattach;topic=884.0;attach=19964;image)
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on July 17, 2007, 09:29 PM
ah that would make sense.. a competing cmd command.
Title: Re: NirCmd Setup, a guide of sorts
Post by: edbro on July 17, 2007, 09:46 PM
Okay, I got it now. Yes, it was competing commands causing the problem. The real problem is the way Vista handles the %programfiles% directory. It will not allow any program to write to any directory inside program files. What it does is redirect all writes to a virtualstore directory buried deep inside the Users directory. I had manually copied some plugins and alias groups into the program files directory. Some stuff was mirrored in the virtualstore directory. When DCUpdater does its stuff, all the updates get written to the virtual store directory. It was a real mess. I ended up uninstalling/reinstalling FARR and manually cleaning up the duplicated items out of program files.
Title: Re: NirCmd Setup, a guide of sorts
Post by: mouser on July 17, 2007, 11:48 PM
When DCUpdater does its stuff, all the updates get written to the virtual store directory. It was a real mess.

oh that is really not cool.
i specifically named the program dcupdate launches to unpack the files in a manner that i thought should make vista ask the user to elevate the rights of the unpacker so that they are installed in the real program files directory..  i am going to have to make some changes if its not doing that.

but wait.. the updater doesnt modify the aliases.. thats only done by the full install tool.

i think you may have misdiagnosed this particulat problem (though the virtual store may be implicated in other issues with farr).
i think this is more of a case of an old version of farr having the nircmd alias and the new version didnt deleted it just added one.  new users shouldnt experience this problem.
Title: Re: NirCmd Setup, a guide of sorts
Post by: jgpaiva on July 19, 2007, 06:30 AM
Just informing that i made a little change on the nircmd alias above... please update :)
Title: Re: NirCmd Setup, a guide of sorts
Post by: nontroppo on July 23, 2007, 11:59 AM
well done jgpaiva!

There is a bug in the standby command - it exits windows instead!?

Wow, FARR 2 is looking damn fine overall, alias system changes are very welcome. :beer: to mouser
Title: Re: NirCmd Setup, a guide of sorts
Post by: jgpaiva on July 23, 2007, 12:05 PM
There is a bug in the standby command - it exits windows instead - maybe that was in my version!?
You're absolutelly right!!
I've corrected it :) thanks! ;)
Title: Re: NirCmd Setup, a guide of sorts
Post by: nontroppo on July 23, 2007, 12:10 PM
There is something annoying though (been a while sonce I've been using FARR so I may just be rusty).

I type "cmd st" - gives me Nircmd standby command as the first entry - I just want to press F1 or [ENTER], but that replaces the text with Standby and I have to press F1 or [ENTER] a second time. I assume this is to do with the alias list having two repeated aliases, but when I press F1 I simply want that one to run.
Title: Re: NirCmd Setup, a guide of sorts
Post by: jgpaiva on July 23, 2007, 01:16 PM
Actually, that's related to the way the alias is made.
Any of those entries works like that, because now you can just type "standby" to standby the computer, the "cmd" alias is only there to serve as a list in case you forget the name of the other entries.