Reply
Thu 6 Mar, 2008 02:30 pm
can anyone modify the following code so that windows phone dialer will open with the highlighted text(phone number) pasted into the dial field. Presently the dialer opens with a blank field, when I highlight a phone number and right click on the context menu handler I added called "PHONE"
I am guessing that the variable +searchtext contains the number to be dialed.
The following code which I am trying to use, was written for another phone dialing program and I just substituted "dialer.exe" at the end of the script hoping the highlighted number would be pasted into the windows dialer.exe program.
I'm guessing dialer.exe does not recognize some of the script commands, so the +searchtext info isn't being pasted into the dial field or possibly there is no command to paste the data into the field or there are specific commands that the original program responds to, but the dialer.exe program doesn't. I know very little about java script
Java script as follows.
<SCRIPT>
var parentWin = external.menuArguments;
var doctxt = parentWin.document.body.createTextRange();
var searchtext = new String("");
var good = new String("0123456789-() .");
var x = parentWin.event.clientX;
var y = parentWin.event.clientY;
var clicked;
searchtext = parentWin.document.selection.createRange().text;
if (searchtext == "")
{
doctxt.moveToPoint(x, y);
//-- find a character at mouse click -----
doctxt.moveStart("character", -1);
doctxt.moveEnd("character", 0);
searchtext = doctxt.text;
clicked = searchtext;
//-- move the beginning to the first 'bad' character
while ( good.indexOf(searchtext.charAt(0))!= -1 && searchtext.charAt(0) != '')
{
doctxt.moveStart("character", -1);
searchtext = doctxt.text;
}
doctxt.moveStart("character", 1);
searchtext = doctxt.text;
//-- move the end to the last 'good' character ---
while ( good.indexOf(searchtext.charAt(searchtext.length-1))!=-1 && searchtext.charAt(searchtext.length-1) != '')
{
doctxt.moveEnd("character", 1);
searchtext = doctxt.text;
}
doctxt.moveEnd("character", -1);
searchtext = doctxt.text;
}
//alert ("Selected text is: '" + searchtext + "'");
var wsh = new ActiveXObject('WScript.Shell');
wsh.Run('"C:\\WINDOWS\\DIALER.exe" /'+searchtext);
</SCRIPT>