Variables 変数

A variable is a string of text that is associated with a short, memorable name. Variable names can be used in most options throughout the skin, in place of the associated text.変数は短い、思い出に残る名に関連付けられているテキスト文字列です。変数名は、関連するテキストの代わりに、スキン全体のほとんどのオプションで使用できます。

Variables are helpful when a certain string is repeated many times throughout the skin. By referencing the variable name instead of the full string, the amount of "redundant" code is reduced, as is the overall size of the skin. Variables also simplify the task of changing values. A variable string can be modified in a single location, and without recreating the entire option in which it is used.変数は、特定の文字列がスキン全体に何度も繰り返される場合に役立ちます。完全な文字列ではなく変数名を参照することで、スキンの全体的なサイズと同様に、 "冗長な"コードの量が削減されます。変数は値を変更する作業も単純化します。可変文字列は、それが使用されているオプション全体を再作成することなく、単一の場所で変更できます。

[Variables] section[変数]セクション

Each skin may have a special section called [Variables]. Each option in [Variables] defines a variable name. Unlike most other option names in Rainmeter, variable names are not limited to a specific list. They can have any valid name, as long as they do not conflict with Rainmeter's built-in variables.各スキンは[変数]と呼ばれる特別なセクションを持つことができます。[変数]の各オプションは変数名を定義します。Rainmeterの他のほとんどのオプション名とは異なり、変数名は特定のリストに限定されません。Rainmeterの組み込み変数と競合しない限り、それらは任意の有効な名前を持つことができます

[Variables]
MyVar1=This is a string!
MyVar2=So is this!
Red=255
Green=150
Blue=0
Alpha=90

Using Variables変数を使う

Variable names are referenced in other options in one of two ways:変数名は、2つの方法のいずれかで他のオプションで参照されます。

Normal variables syntax

  • #VarName#

Nested variables syntax

  • [#VarName]

When the skin is loaded or refreshed, Rainmeter replaces the variable reference with the corresponding string. Variables are inserted "literally," which means they can be mixed with other variables or regular text.

[MeterMyVar1]
Meter=String
Text=The value of "MyVar1" is: #MyVar1#
FontColor=#Red#,#Green#,#Blue#,#Alpha#

[MeterMyVar2]
Meter=String
Text=The value of "MyVar2" is: #MyVar2#
FontColor=#Red#,#Green#,#Blue#,#Alpha#

Variables can also be used to define other variables:変数は他の変数を定義するためにも使用できます。

[Variables]
MyVar1=rainmeter
MyVar2=http://www.#MyVar1#.net/

Changing Variables変数を変更する

The !SetVariable bang can be used to change variable values dynamically. !SetVariable can also be used to create a variable that does not already exist in the [Variables] section.!はSetVariable bangが変数の値を変更するために使用することができ、動的に!SetVariableを使用して、[Variables]セクションにまだ存在していない変数を作成することもできます。

[!SetVariable "MyVar1" "This is a new string!"]

Alternatively, the !WriteKeyValue bang can be used to add or change values in [Variables]. The skin must be refreshed to apply changes made by !WriteKeyValue.あるいは、!WriteKeyValue bangを使用して[Variables]の値を追加または変更することもできます。!WriteKeyValueによって行われた変更を適用するには、スキンを更新する必要があります。

[!WriteKeyValue "Variables" "MyVar2" "New value"]

Dynamic Variables動的変数

A variable whose value changes while the skin is active is called a dynamic variable. Dynamic variables allow a skin to store, retrieve and display ever-changing information without refreshing the skin.スキンがアクティブな間に値が変化する変数は、動的変数と呼ばれます。動的変数は、スキンがなくて刻々と変化する情報を格納、取得および表示することができますさわやかなスキンを。

Dynamic variables can only be used in a measure or meter by setting the option DynamicVariables=1.動的変数は、オプションを設定することによってメジャーまたはメーターでのみ使用できますDynamicVariables=1

Note that any [MeasureName] used in a bang as a Section Variable is automatically dynamic, and DynamicVariables=1 is not required.セクション変数[MeasureName]としてbangで使用されるものはすべて自動的に動的であり、必須ではありません。DynamicVariables=1

In addition, there are some [Sections] and plugins which do not support dynamic variables at this time. The following are sections where dynamic variables cannot be used:さらに、現時点で動的変数をサポートしていない[Sections]とプラグインがいくつかあります。動的変数を使用できないセクションは次のとおりです。

When a meter or measure has dynamic variables enabled, Rainmeter uses marginally more processor power. This difference is negligible for most skins, but it may be noticeable in very large, complex skins with many dynamic variables, or on image meters with very large images. For this reason, it is recommended to use dynamic variables only when necessary, and use alternatives such as !SetOption in other cases.メーターまたはメジャーで動的変数が有効になっていると、Rainmeterはわずかに多くのプロセッサパワーを使用します。この違いはほとんどのスキンでは無視できますが、多くの動的変数を含む非常に大きく複雑なスキン、または非常に大きいイメージを持つイメージメータでは、それが顕著になることがあります。このため、必要な場合にのみ動的変数を使用し、それ以外の場合は!SetOptionなどの代替手段を使用することをお勧めします。

Built-In Variables組み込み変数

Rainmeter automatically creates a number of helpful variables for each skin. These variables do not need to be defined in the [Variables] section. Some built-in variables are dynamic.Rainmeterは自動的に各スキンに役立つ変数をいくつか作成します。これらの変数は、[変数]セクションで定義する必要はありません。いくつかの組み込み変数は動的です。

For a complete list, see Built-In Variables.完全なリストについては、組み込み変数を参照してください。

Section Variablesセクション変数

Some measure and meter properties can also be referenced as dynamic variables by using the section name in brackets [], as in [SectionName]. These section variables can also be modified by certain parameters, as in [SectionName:P1,P2].いくつかの尺度メータ特性もとして参照することができる動的括弧でセクション名を使用して、変数[]のように、[SectionName]。これらのセクション変数は、のように特定のパラメータで変更することもできます[SectionName:P1,P2]

For more, see Section Variables.詳しくは、セクション変数を参照してください。

Event Variablesイベント変数

Some action options allow the use of special variables that are related to the specific event that triggers the action. These variables are referenced by surrounding the name with dollar signs ($), as in $Foo$. Event variables are evaluated at the time the action is triggered, used to execute the action, and then immediately discarded. For example, when using a command with the InputText plugin, the event variable $UserInput$ refers to the string that was entered into a text input box by the user.一部のアクションオプションでは、アクションをトリガーする特定のイベントに関連した特別な変数を使用できます。これらの変数は$、のようにドル記号()で名前を囲??むことによって参照され$Foo$ます。イベント変数は、アクションがトリガーされたときに評価され、アクションの実行に使用されてからすぐに破棄されます。たとえば、InputTextプラグインでコマンドを使用する場合、イベント変数$UserInput$はユーザーによってテキスト入力ボックスに入力された文字列を参照します。

Environment Variables環境変数

Windows environment variables can be referenced as variables in Rainmeter by using the variable name contained between percent signs (%), such as %APPDATA% or %SystemDrive%. To see a complete list of environment variables available on your system, open a Windows command prompt (cmd.exe) and type set.Windows 環境変数は、パーセント記号(%)の間に含まれる変数名を使用して、%APPDATA%またはのようにRainmeterで変数として参照できます%SystemDrive%。システムで使用可能な環境変数の完全なリストを見るには、Windowsのコマンドプロンプト(cmd.exe)を開いて入力しますset

Escaping Variables変数のエスケープ

Rainmeter always attempts to replace #Name# or [Name] with a value, if "Name" refers to an existing variable, meter or measure. To prevent a variable reference from being replaced, escape the "Name" of the variable with asterisks (*).「名前」が既存の変数、メーター、またはメジャーを参照している場合、Rainmeterは常に値の置き換え#Name#または[Name]値の試行を行います。変数参照が置き換えられないようにするには、アスタリスク(*)を使用して変数の「名前」をエスケープします。

Normal variables

  • #*VarName*#
  • [*MeasureName*]

Nested variables

  • [#*VarName*]
  • [&*MeasureName*][&*MeasureName*]

These are replaced with the literal strings without the *, rather than the resolved values. The !SetOption bang can use these escape characters to protect variable references when setting options on dynamic meters or measures.これらは*解決された値ではなく、なしのリテラル文字列に置き換えられます。!のSetOptionメソッドの bangがダイナミックメートル措置に関するオプションを設定するときに、変数の参照を保護するためにこれらのエスケープ文字を使用することができます。

関連記事

スポンサーリンク

Viewの表示・非表示を切り替える方法

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る