CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008
    Posts
    4

    Help with setTimeout and others

    Hello experts,

    I was able to have windows' phone dialer, dial phone numbers in (on IE webpages), bu simply highlighting the number and right clicking. I added a context menu item "PHONE". clicking on "PHONE" would open a hidden webpage that:
    Copied the highlighted phone number to the clipboard and opened another hidden window that executed Dialer.exe, waited a few milliseconds then pasted the clipboard into the dial number field of the dialer and activated the Dial button. Then after a delay, closed all windows involved in the routine.
    I used the following code stored in 2 htm documents.

    Numb.htm

    <script language="javascript"type="text/javascript">
    {var SelectedText =window.external.menuArguments.document.selection.createRange().text;
    window.clipboardData.setData("Text",SelectedText);}
    window.open('C:/numba.htm',"mywindow","menubar=0,statusbar=0,toolbar=0,scrollbars=0,location=0,center=0,resizable=0,width=1,height=1,left=400,top=250");
    var wsh = new ActiveXObject('WScript.Shell');
    wsh.SendKeys ("{TAB}");
    wsh.SendKeys ("{ENTER}");
    </SCRIPT>

    The last 2 sendkeys were to get rid of the security warning box about running script that windows generated.
    ____________________

    and numba.html

    <script language="javascript"type="text/javascript">
    var wsh = new ActiveXObject('WScript.Shell');
    wsh.Run("C:\\WINDOWS\\Dialer.exe");
    setTimeout("wsh.Sendkeys ('^V')",250);
    setTimeout("wsh.Sendkeys ('{ENTER}')",260);
    setTimeout("wsh.Sendkeys ('%{F4}')",8500);
    setTimeout("wsh.Sendkeys ('%{F4}')",8600);
    setTimeout("wsh.Sendkeys ('%{F4}')",8800);
    </SCRIPT>


    I decided to go to Netscape, but that does not have modifiable context menus.

    Can you rewrite the above script (or give the same function) in .js,
    I would like to activate it by setting up a hotkey to a shortcut to the .js file stored on the desktop, but this takes the focus off the webpage and I don't thin the scripted copy function will work

    So far I found that WSH dosen't like:
    <script language="javascript"type="text/javascript">

    and also

    gives an "object expected error
    at the settimeout statement

  2. #2
    Join Date
    Jun 2009
    Posts
    113

    Re: Help with setTimeout and others

    I see you've answered this yourself in a different post. The thing with script files is that they are implicitly in one language or another, so a file ending in .JS is pure JavaScript, there's no need for a tag to say what script language it is, ditto for a .VBS being pure VBscript.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured