Copy to clipboard in a captive portal

Good afternoon,

I am doing a project with an ESP8266 NodeMcu board.
I want to edit the WifiManager library to add a button in which when pressed (with Android and Iphone) it must copy the MAC address of the ESP8266 board, but I don't know to start.

I have seen several C ++ functions to use the ClipBoard, maybe there is a simpler way.
For example:

void toClipboard(HWND hwnd, const std::string &s){
	OpenClipboard(hwnd);
	EmptyClipboard();	
	HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,s.size()+1);
	if (!hg){
		CloseClipboard();
		return;
	}
	memcpy(GlobalLock(hg),s.c_str(),s.size()+1);
	GlobalUnlock(hg);
	SetClipboardData(CF_TEXT,hg);
	CloseClipboard();
	GlobalFree(hg);
}

Thank you so much!

the WiFiManager UI is a webpage so modify the source code of the page to include the button. there is no c++

most of the page source is in strings_en.h and it uses simple html form and javascript

I'm trying to Add a button to copy a link ([www.google.com/MACadress] to the clipboard, but it's not working. I'm trying to add two const char on the WifiManager.h:

const char HTTP_GENERATE_O2BASE_LINK_SCRIPT[] PROGMEM  = "<script>async function copyLink(){document.querySelector('#button').addEventListener('click', async function(event){             return await navigator.clipboard.writeText('https://www.google.com!').then(() => console.log('Coppied!'));         });}</script>";
                                                            
const char HTTP_GENERATE_O2BASE_LINK[] PROGMEM  = "<br/><button id='button'>Generate O₂BASE Link</button>";

And add it to the page on WifiManager.cpp:

String page = FPSTR(HTTP_HEADER);

  page.replace("{v}", "Options");

  page += FPSTR(HTTP_IMAGE);

  page += FPSTR(HTTP_SCRIPT);

  page += FPSTR(HTTP_GENERATE_O2BASE_LINK_SCRIPT);

  page += FPSTR(HTTP_STYLE);

  page += _customHeadElement;

  page += FPSTR(HTTP_HEADER_END);

  page += String(F("<h1>"));

  page += _apName;

  page += String(F("</h1>"));

  page += FPSTR(HTTP_PORTAL_OPTIONS);

  page += FPSTR(HTTP_GENERATE_O2BASE_LINK);

  page += FPSTR(HTTP_END);

isn't that the same question as in

I've merged your cross-posts @osfuco1.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide you will find at the top of every forum category. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.