Combining VBScript, Opera and Javascript for effective functions.
Monday, 18. December 2006, 01:34:47
Although VBScript is seemed to be a language only windows users can use, it can come in useful when automating commands in Opera can be a pain.
Here is example code of a VBScript,save this as copy.vbs and save it in your main program files > opera folder, what the script does is it looks for the active window title, then sends the key commands to copy the content and close the tab creating the content. One is for the selection source bookmarklet which is found here: http://my.opera.com/community/forums/topic.dml?id=140523
Here is an example to put in menu.ini file to run the VBScript first then run the javascript code.
This javascript function copies selected links to the clipboard, or copies all links of the page if no selection or the selection contains no links.
These are just examples of how VBScript can help Windows Opera users extend Opera's functionalities a tiny bit more
DIM Wsh,ArgObj,var1
Set ArgObj = WScript.Arguments
Set Wsh = WScript.CreateObject("WScript.Shell")
var1 = ArgObj(0)
if var1 = "source" then
Do Until Wsh.AppActivate ("Selection source for")
WScript.Sleep 500
Loop
Wsh.SendKeys "^a"
Wsh.SendKeys "^c"
Wsh.SendKeys "^{F4}"
else
Do Until Wsh.AppActivate ("Links Selected for")
WScript.Sleep 500
Loop
Wsh.SendKeys "^a"
Wsh.SendKeys "^c"
Wsh.SendKeys "^{F4}"
end if
Set Wsh = nothing
WScript.Quit
Here is example code of a VBScript,save this as copy.vbs and save it in your main program files > opera folder, what the script does is it looks for the active window title, then sends the key commands to copy the content and close the tab creating the content. One is for the selection source bookmarklet which is found here: http://my.opera.com/community/forums/topic.dml?id=140523
Here is an example to put in menu.ini file to run the VBScript first then run the javascript code.
Item, "Copy selected links/All links" = Execute Program, "copy.vbs","selectlinks" & Go to page, "javascript:(function(){ var html_selection=document.createElement('div'); var yay=[]; if(document.getSelection()){ html_selection.appendChild(window.getSelection().getRangeAt(0).cloneContents()); } if(!html_selection.getElementsByTagName('a')[0]) { document.designMode='on';document.execCommand('selectall', false, null);html_selection.appendChild(window.getSelection().getRangeAt(0).cloneContents());document.links[0].focus();document.designMode='off'; } var hmm=html_selection.getElementsByTagName('a'); for(var i=0;i<hmm.length;i++) {yay[i]=hmm[i].href};var ty=window.open();ty.document.write('<title>Links Selected for '+location.href+'</title>'+yay.toString().replace(/\,/g,'
'));ty.document.close();})(); "
This javascript function copies selected links to the clipboard, or copies all links of the page if no selection or the selection contains no links.
These are just examples of how VBScript can help Windows Opera users extend Opera's functionalities a tiny bit more


