- How to Open Selected Text from Internet Explorer into Notepad
This tutorial will show you how to open in Notepad a selected text from the IE7 context menu.
How to Open Selected Text from Internet Explorer into Notepad
Adding a function in the context menu is quite easy.
You noticed that many apps offer some context menu facilities, to do so they mainly use an activex/addon installed with their program.
An IE context menu item is usually linked to a htm/html file wich includes scripts, links to activex, etc... and use a personalized dll.
In fact we have to write a script, embed it or name it as a htm file and ask the registry to write an entry in the context menu which on click links to the htm file.
Due to UAC, the htm file will ask to open a VBS file which will do the job.
A prompt will ask you if you accept to run the script.
Personally i place the htm file in the common files folder where i created a folder named "Registry" just to remember it better, but it could be anywhere.
The VBS file should be in %windir% so that it can be called from anywhere.
Then, the last thing to do is to add the registry key which will modifiy the IE context menu.
The added context menu items are in:
1/ We will start by the htm file:
We want to add in the context menu an item which when clicked opens Notepad with a selected text writen in.
So we have to make a script which copy the selected text into the clipboard.
<SCRIPT> var CheckForSelection = window.external.menuArguments.document.selection.createRange().text; window.clipboardData.setData("Text",CheckForSelection); </SCRIPT>
Well, now we have to run a vbs script which will do the rest of the job.
We will call this VBScript OpenNP, we will make it after this step.
<SCRIPT LANGUAGE="VBScript"> Set WshShell = CreateObject("WScript.Shell") WshShell.Run "%windir%\OpenNP.vbs",1,False Set WshShell = Nothing </SCRIPT>
We just copy these 2 scripts above in notepad and save as OpenNP.htm in: C:\Program Files\Common Files\Registry
2/ It is time now to make the script which will open Notepad and paste the selected text in it.
Set WshShell = CreateObject("WScript.Shell") WshShell.Run "%Windir%\notepad.exe", 1 WScript.Sleep 1000 WshShell.SendKeys "^v" Set WshShell = Nothing
Of course, for notepad the "%windir%" is useless, i just put it to make it more understandable. Writing "notepad" is enough, therefore if you prefer to use wordpad, just replace "%Windir%\notepad.exe" by "wordpad" and instead of naming the registry key "Open In Notepad", name it "Open In Wordpad".
And if you prefer WinWord or Uedit, do as above but in some cases you will have to increase the sleep time (value in ms).
We just copy these lines above in notepad and save as OpenNP.vbs in: C:\Windows
3/ To finish, we write the new key in the registry.
Create a new key named: Open In Notepad and give as default value: File://C:\Program Files\Common Files\Registry\OpenNP.htm
Close Regedit, open IE and test. (select a text, right click and "Open in Notepad").
If you are as lazy as i am, all files are in the attached zip file.
View attachment 4464 < Click To Download
- Extract OpenNP.htm to C:\Program Files\Common Files\Registry
- Extract OpenNP.vbs to C:\Windows
- Run OpeninNP.reg to write the context menu key in the registry
Last edited by a moderator: