Page 1 of 1

Script measure: New SKIN:Bang() syntax

Posted: May 21st, 2012, 8:32 am
by poiru
Executing bangs through Lua is often cubersome, because the concatenation operator (i.e. ..) must be used repeatedly and because quotes must be properly escaped. As a result, you often end up with ugly lines such as:

Code: Select all

SKIN:Bang("!SetVariable " .. varName .. " \"" .. varValue "\"")
SKIN:Bang('!SetOption MeterTitle' .. i .. ' LeftMouseUpAction """!Execute [\" '.. tLinks[currentItem] .. '\"]"""')
In recent Rainmeter 2.3 betas, we've introduced an alternative form of SKIN:Bang() that greatly simplifies this. The line above can now be used rewritten as:

Code: Select all

SKIN:Bang("!SetVariable", varName, varValue)
SKIN:Bang('!SetOption', 'MeterTitle' .. i, 'LeftMouseUpAction', '[' .. tLinks[currentItem] .. ']')
In other words, instead of concatenating the bang parameters and escaping quotes, you can simply pass all parameters as actual parameters of the function. The result is much easier to both read and write.

Do note that in the "improved" !SetOption example, !Execute has been removed as it is now deprecated.

Re: Script measure: New SKIN:Bang() syntax

Posted: May 25th, 2012, 12:21 am
by XANCI
Launching external application will fail

Code: Select all

SKIN:Bang('#@#RainRGB4.exe','VarName=ColorMain'..sP,'FileName=#CUSFILE#')
SKIN:Bang('control.exe','ncpa.cpl')

Re: Script measure: New SKIN:Bang() syntax

Posted: May 25th, 2012, 12:30 am
by jsmorley
XANCI wrote:Launching external application will fail

Code: Select all

SKIN:Bang('#@#RainRGB4.exe','VarName=ColorMain'..sP,'FileName=#CUSFILE#')
SKIN:Bang('control.exe','ncpa.cpl')
The comma delimited parameters in the SKIN:Bang function are for parameters to Rainmeter bangs, not for parameters to external applications. Since what you are doing takes no Rainmeter parameters as such (like a !SetOption would for instance), you just need:

SKIN:Bang('[control.exe ncpa.cpl]')

Note that even though we got rid of !Execute, you should still use the brackets [] around Rainmeter bangs that call external applications.