本帖最后由 吾奶常煽赵子龙 于 2025-9-22 10:33 PM 编辑
[Lua] 纯文本查看 复制代码 tipScanner = tipScanner or CreateFrame("GameTooltip", "MyTooltipScanner", UIParent, "GameTooltipTemplate")
tipScanner:SetOwner(UIParent, "ANCHOR_NONE")
function GetItemTooltipText(itemLinkOrId)
tipScanner:ClearLines();
tipScanner:SetHyperlink(itemLinkOrId);
local textLines = {}
for i = 1, tipScanner:NumLines() do
local leftText = _G["MyTooltipScannerTextLeft" .. i];
if leftText then
table.insert(textLines, leftText:GetText() or "");
end
end
return textLines;
end
用上面这个方法可以获取到鼠标放到该物品上时的提示文本内容。用法:
[Lua] 纯文本查看 复制代码 function CheckHasKeyword(itemLink, keyword)
local textLines = GetItemTooltipText(itemLink);
for _, text in ipairs(textLines) do
if text:find(keyword, 1, true) then
return true;
end
end
return false;
end
if CheckHasKeyword(itemLink, "你好查找为文本内容") then
print("发现目标文本内容")
end
|