You can't "programatically" send text to the clipboard. You need the frame to display the text that you then select and CTRL-C to get it onto the clipboard.
You can create a frame with an EditBox and automaticaly set it to select some text (EditBox:HighlightText(start, end)) so you just need to CTRL-C to copy to the clipboard.
Edit: I missed the bit where you were asking for a popup frame if that was the only way.
You can paste the following into the website
addon.bool.no and give it a unique title (GetGold?) to create/download a small addon to do this.
/gg will show/hide the frame with your current gold/silver/copper (the button will toggle current character/all characters) ready to copy (CTRL-C).Pasting the text into an editor will paste the numbers but not the icons.
Notes
Using a text editor (eg. NotPad):
The following line will need to be added (after the other lines starting with ##) to the addons .TOC file located in the addons folder (THE ADDON WILL NOT WORK PROPERLY WITHOUT THIS):
## SavedVariables: GG_DATA
Will only show total gold for characters you have logged on to.
Will show gold for deleted character unless you edit the addons SavedVariables file and delete the characters information:
File Location:
[WoW folder]\[game version folder eg. _retail_]\WFT\Account\[your account name]\SavedVariables\[addon name].lua
|
Lua Code:
local f = CreateFrame("Frame", "GetGoldDisplayFrame", UIParent, BackdropTemplateMixin and "BackdropTemplate")
f:SetPoint("CENTER")
f:SetMovable(true)
f:SetUserPlaced(true)
local CTData, CTName
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("PLAYER_MONEY")
f:SetScript("OnEvent", function(self, event)
if event == "PLAYER_MONEY" then
CTData.gold = GetMoney()
return
end
GG_DATA = GG_DATA or { characters={} }
CTName = UnitName("player")
CTData = CTName .. "-" .. GetNormalizedRealmName()
if not GG_DATA.characters[CTData] then
GG_DATA.characters[CTData] = { }
end
CTData = GG_DATA.characters[CTData]
CTData.gold = GetMoney()
end)
local TotalText = "Total Gold is:"
local PlayerText = "Gold for %s:"
local function ShowGold(self, playergold)
local Total = 0
if not playergold then
self.Title:SetText(TotalText)
self.GetFor:SetText(CTName)
for k, v in pairs(GG_DATA.characters) do
Total = Total + v.gold
end
else
self.Title:SetText(format(PlayerText, CTName))
Total = CTData.gold
self.GetFor:SetText("All")
end
self.Text:SetText(GetMoneyString(Total, true))
self.Text:HighlightText()
self.Text:SetFocus()
self:Show()
end
local function GetGold(msg)
if f.Title then
if f:IsShown() then
f:Hide()
return
end
ShowGold(f)
return
end
local backdrop = {
bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
edgeFile = "Interface/GLUES/Common/Glue-Tooltip-Border",
tile = true,
edgeSize = 8,
tileSize = 8,
insets = {
left = 2,
right = 2,
top = 2,
bottom = 2,
},
}
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")
f:SetClampedToScreen(true)
f:SetScript("OnDragStart", function(self) self:StartMoving() end)
f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
f:SetBackdrop(backdrop)
f:SetSize(220, 100)
f.Title = f:CreateFontString()
f.Title:SetFontObject(GameFontNormal)
f.Title:SetPoint("TOP", 0, -5)
f.Title:SetText("Total Gold is:")
f.Close = CreateFrame("Button", "$parentClose", f, "UIPanelCloseButton")
f.Close:SetSize(24, 24)
f.Close:SetPoint("TOPRIGHT")
f.Text = CreateFrame("EditBox", nil, f)
f.Text:SetFontObject(GameFontNormal)
f.Text:SetSize(190, 24)
f.Text:SetJustifyH("CENTER")
f.Text:SetPoint("CENTER", 0, 10)
f.Text:SetMultiLine(false)
f.Text:SetScript("OnEscapePressed", function(self)
self:ClearFocus()
self:GetParent():Hide()
end)
f.GetFor = CreateFrame("Button", "$parentGetFor", f, "UIPanelButtonTemplate")
f.GetFor:SetSize(100, 30)
f.GetFor:SetText("All")
f.GetFor:SetPoint("BOTTOM", 0, 10)
f.GetFor:SetScript("OnClick", function(self)
self.Player = not self.Player
ShowGold(f, self.Player)
end)
ShowGold(f)
end
SLASH_GG1 = "/gg"
SlashCmdList.GG = GetGold
--[[ Notes
-- Using a text editor (eg. NotPad):
-- The following line will need to be added (after the other lines starting with ##) to the addons .TOC file located in the addons folder (THE ADDON WILL NOT WORK PROPERLY WITHOUT THIS):
## SavedVariables: GG_DATA
-- Will only show total gold for characters you have logged on to.
-- Will show gold for deleted character unless you edit the addons SavedVariables file and delete the characters information:
-- File Location:
[WoW folder]\[game version folder eg. _retail_]\WFT\Account\[your account name]\SavedVariables\[addon name].lua
]]--