Internet Explorer Context menu

Started by archimede, September 27, 2013, 09:19:01 AM

Previous topic - Next topic

archimede

How I can add a call in the Internet Explorer context menu?
That call would be active when I set a text in a web page; I want make a WB program that read the selected text in a web page, is it possible?

Deana

Have you considered using the PopMenu tool to handle this?

Steps:

  • Open IE and make sure it is the active window.
  • Left-click on PopMenu in the System Tray.
  • Select the menu option: Edit menu for Windows Internet Explorer
  • This will open the customizeable menu file that is associated with IE called IEFrame.mnw
  • Add IE COM code below

Code (winbatch) Select
; IEFrame.mnw

Get Webpage Data
         objShell = CreateObject("Shell.Application")
         objInstances = objShell.windows
         objIE = 0
         If objInstances.Count > 0 ; make sure we have instances open.
             ForEach objIE In objInstances
                sName = StrLower(objIE.FullName)
                If StrIndex( sName, 'iexplore.exe', 1, @FWDSCAN ) != 0 ; internet explorer not windows explorer.
                 ret = AskYesNo( "Found instance of Internet Explorer ":objIE.LocationURL, "Would you like to view html?" )
                 If ret
                    objInstances = 0
                    objShell = 0
                    Break
                 EndIf
               EndIf
             Next
         EndIf
         If objIE == 0
            Pause('Notice', 'Unable to locate any running instances of InternetExplorer')
         EndIf
         
         objDoc = objIE.Document
         objMainhtml = objDoc.GetElementsbyTagname("HTML").item(0)
         html = objMainhtml.innerhtml
         Pause('Webpage data', html)
         objMainhtml = 0
         objDoc = 0
         objIE = 0


This should help you get started.
Deana F.
Technical Support
Wilson WindowWare Inc.

archimede

Very interesting.
I not know popup menu.
Do you know a mode to delete that context menu call?

Deana

Quote from: archimede on September 27, 2013, 10:07:44 AM
Very interesting.
I not know popup menu.
Do you know a mode to delete that context menu call?

I am sorry I do not understand the question.

If you no longer want the customized popmenu menu item to display, you can simply delete the associated IEFrame.mnw in your WinBatch System subdirectory.
Deana F.
Technical Support
Wilson WindowWare Inc.

archimede

The problem is I no know popmenu.
I prefer, if it is possible, to add a call to the IE context menu; is it possible?
For example at this address
http://msdn.microsoft.com/en-us/library/aa753589(v=vs.85).aspx
is possible to see how add a call to the IE context menu but is not clear (for me) how that call can call an application (for example a WB application)...

DAG_P6

Based on a somewhat cursory scan of the documentation, including the reference to External Content, it appears to me that the IE context menu is limited to things that you can do within the context of a browser. It might be possible to run a program by way of a file:// URI. However, an attempt to invoke a file on a local machine is likely to run afoul of the Internet Explorer security zone scheme, since the file URI will be seen as part of either the My Computer or Local Intranet security zone, both of which are more restricted than the Internet zone. That being the case, I would expect such an attempt to raise an alarm about the current page attempting to open a page in the more restricted zone (My Computer or Local Intranet).

You might be able to suppress the security zone warning if you can put the host in question in the Trusted Sites zone, which has the fewest restrictions. However, putting whole hosts into the Trusted Sites zone is a step that should be carefully considered and used sparingly. For example, of the thousands of hosts that I visit, I have maybe five or six in the Trusted zone.
David A. Gray
You are more important than any technology.

Deana

Yes you will need to fiddle with IE security settings... which can potentially make your system vulnerable. Please proceed at your own caution.

Maybe give these steps a try:

Launch regedit:
Create a registry key: HKCU\Software\Microsoft\Internet Explorer\MenuExt\SampleMenuItem.
For the Default value specify:  "C:\Program Files\IEContextScript\SampleMenuItem.htm"
Create a new DWORD value named "Contexts" and give it the value of 1.

Save the following as C:\Program Files\IEContextScript\SampleMenuItem.htm

Quote<SCRIPT LANGUAGE="JavaScript">
alert("Hello");
//var parentwin = external.menuArguments; var doc = parentwin.document;
//var sel = doc.selection; var rng = sel.createRange(); var str = new String(rng.text);
var oShell = new ActiveXObject("Shell.Application");
// Replace with your executable name
oShell.ShellExecute("C:\\Program files (x86)\\WinBatch\\System\\WinBatch.exe", "C:\\Program Files (x86)\\IEContextScript\\SampleMenuItem.wbt");
oShell = null;
</SCRIPT>

Now Launch the Internet Explorer web browser.
Click the "Tools" menu and then click "Internet Options."
Click the "Security" tab.
Click to select "Local Intranet" from the listed zones and then click the "Custom Level" button.
Scroll down to the "Scripting" options.
Click to select "Enable" next to the "Active Scripting" option.
Click the "OK" button and then click "Yes" to approve the new scripting setting.
Click "Apply" and "OK." Restart the Internet Explorer.
Deana F.
Technical Support
Wilson WindowWare Inc.

archimede

I tested it.
I works.
Thank you very much