ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE. Software > FARR Plugins and Aliases

NirCmd Setup, a guide of sorts

(1/6) > >>

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...

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.

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"

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.

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)

thanks nontroppo, the nirccommand stuff is working great here! fun!

ps. new version is up which should fix the 2 issues pointed out here.

ps.  does the nickname "nontroppo" mean anything?


[0] Message Index

[#] Next page

Go to full version