A little background. I have a mapping program running in an Embedded IE browser. IE exposes IHTMLDocument2 = interface(IHTMLDocument) which I use to call external (desktop) methods. Works great but Google will stop supporting IE shortly and Edge does not support external calls.
interface IMyExternal: IDispatch
{
[id(0x000000C9)]
HRESULT _stdcall ShowQtrMinBounds([in] BSTR QtrNorth, [in] BSTR QtrSouth, [in] BSTR QtrEast, [in] BSTR QtrWest);
[id(0x000000CA)]
HRESULT _stdcall ShowMarker([in] BSTR MsgStream, [in] BSTR ticketID);
[id(0x000000CD)]
HRESULT _stdcall ManageQtrGrid([in] BSTR functionName, [in] BSTR retState);
[id(0x000000CE)]
HRESULT _stdcall SaveQtrMinutes([in] BSTR qtrMinuteCode);
[id(0x000000CF)]
HRESULT _stdcall WhoIsHere([in] BSTR qtrMinuteCode);
};
To get around this, I've decided write to a file. I spin a thread looking for the textFile which should be named the same as the Methods. The file content will be the arguments.
My problem is that I am not that sophisticated of a JS developer. I've searched for usable script to get me started. I've found:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<table>
<tr><td>Text to Save:</td></tr>
<tr>
<td colspan="3">
<textarea id="inputTextToSave" cols="20" rows="5"></textarea>
</td>
</tr>
<tr>
<td>Filename to Save As:</td>
<td><input id="inputFileNameToSaveAs"></input></td>
<td><button onclick="saveTextAsFile()">Save Text to File</button></td>
</tr>
</table>
<script type="text/javascript">
function saveTextAsFile()
{
var textToWrite = document.getElementById("inputTextToSave").value;
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
if (window.webkitURL != null)
{
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
}
downloadLink.click();
}
</script>
</body>
</html>
Above works in principle but I cannot use it in practice. I cannot use user inputs. Here is a typical call.
function whoBeHere(point) {
var LeftLat = (Math.floor(point.lat() / llOffset) * llOffset);
var LeftLng = (Math.floor(point.lng() / llOffset) * llOffset);
var qtrMinute = ddToQM(LeftLat, LeftLng);
external.WhoIsHere(qtrMinute);
}
I need to have my script write to a file, in the case of the above, it would be named "WhoIsHere" and its contents would be "qtrMinute = 34.0, 82.44"
I've looked at Node.JS but this has to happen client side.
More info. My program creates a grid over googlemaps I call Quarter Minutes. My users selects qtr mins using the mouse in a process I call fencing.
function SaveQtrMin() {
for (var m in qtrArray) {
external.SaveQtrMinutes(qtrArray[m].qtrMinute);
}
}
Write now I call a COM object I've instantiated from IE's Winapi.ActiveX. It exposes methods that permit me to write to the desktop. SaveQtrMinutes(qtrArray[m].qtrMinute) is a COM object I wrote in Delphi 10 years ago. Google is restricting access to Google Maps from IE so my COM object will cease to function.
So, to make it work, I decided that rather than call my Delphi method, which Edge does not support, I would simply write to file.
I can monitor when a file is written by spinning a thread that looks in the folder for a file. If it finds one, it will run the procedure written in the file.
Think that you clicked on restaurant on in Google Maps. I want the browser to write out the restaurant name to a file.
I will have a process running that continually looks in that folder and if it a file, it will open it and respond to it somehow.
Thanks