MatchResult:getText()
一致に関連付けられたラベルまたはテキストを返します。
説明
getText() メソッドは、一致した結果に関連付けられた文字列ラベルを返します。これは次の場合に特に便利です:
- 認識されたテキストが返されるテキストベースの検索(OCR)を実行する場合
- どのテンプレートが一致したかを識別したい、ラベル付きテンプレートを扱う場合
一致に関連付けられたラベルがない場合、このメソッドは空の文字列を返します。
シグネチャ
getText(): string
戻り値
string - 一致に関連付けられたラベルまたはテキスト。ない場合は空の文字列。
例
-- OCR テキスト検索の例
local result = Screen:find("hello World", FinderParams():setDetectionType("TEXT"))
if result then
local text = result:getText()
toast("見つかったテキスト: " .. text)
end
-- 特定のテキストをチェックする例
local result = Screen:find("submit", FinderParams():setDetectionType("TEXT"))
if result then
local label = result:getText()
if label == "submit" then
toast("送信ボタンが見つかりました!")
end
end