Combining VBScript, Opera and Javascript for effective functions.
Monday, 18. December 2006, 01:34:47
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



ilyabirman # 19. December 2006, 18:38
shoust # 17. January 2007, 20:37
Lex1 # 27. January 2007, 09:19
Platform Windows, Item, "Download Selection with oGet"="Execute program, "D:\Opera\scripts\clip2txt.exe","%u",,"Save" & Go to Page, "javascript:(function(){var lnks, text, re, rearray; var a_links=''; var t_links=''; var html_selection=document.createElement('div'); html_selection.appendChild(window.getSelection().getRangeAt(0).cloneContents()); lnks = html_selection.getElementsByTagName('a'); for(var i=0, li; li=lnks[i]; i++){a_links+= '<a href=\''+li.href+'\'>'+li.innerText+'</a>'}; text=html_selection.innerText.replace(/h..p:\/\//gi,'http://').replace(/f.p:\/\//gi,'ftp://'); re=/((?:https|http|ftp|mms|rtsp):\/\/[^\s\x22<>\{\}\'\(\)]+)/gi; while(rearray=re.exec(text)){t_links+= '<a href=\''+rearray[1]+'\'></a>'}; prompt('Please wait...', a_links+t_links);})()""
And vbs (This simple send Ctrl+C and Esc)
AyushJ # 5. March 2007, 08:02
btw, you can combine the keys in one line:
Wsh.SendKeys("^a^c^{F4}")
shoust # 5. March 2007, 19:54
AyushJ # 6. March 2007, 05:28
hallvors # 23. July 2007, 16:04