將IE的右鍵搬到opera裡

2021-04-13 12:04:42 字數 4408 閱讀 4825

function addlink(url,info,location,strcid,strstaturl,strcookie)

var thunderagent = new activexobject("thunderagent.agent");

if (strcid != "")

else

}else

thunderagent.committasks2(1);}}

function oncontextmenu()

else

var strdownloadpage = external.menuarguments.location;

var thedownloadpage = external.menuarguments.document.getelementbyid("thunder_down_pageurl");

if (thedownloadpage != null)

var strstatpage = "";

var thestatpage = external.menuarguments.document.getelementbyid("thunder_stat_pageurl");

if (thestatpage != null)

var strcid = ""

var thecid = external.menuarguments.document.getelementbyid("thunder_cid");

if (thecid != null)

var srcanchor;

if (srcevent.type == "menuextanchor")

while(typeof(srcanchor)=="htmlanchorelement");

addlink(srcanchor.href,srcanchor.innertext,strdownloadpage, strcid, strstatpage,external.menuarguments.document.cookie);

}else if (srcevent.type == "menuextimage")

else

}while(typeof(srcanchor) == "htmlanchorelement");

addlink(srcanchor.href,srcimage.alt,strdownloadpage, strcid, strstatpage);}} 

else if (srcevent.type == "menuextunknown")

else

}if(eventelement != null && eventelement.tagname != null)

else}}

else

}oncontextmenu();

注意主要內容,它是先生成乙個com物件名為"thunderagent ",com註冊名稱為"thunderagent.agent"(很重要).

var thunderagent = new activexobject("thunderagent.agent");

然後呼叫thunderagent 的函式addtask5,committasks2(很重要)

thunderagent.addtask5(url, "", "", info, location, -1, 0, -1,  strcookie, strcid, "", 1, "", -1);

thunderagent.committasks2(1);

指令碼分析完畢,開始程式設計

開啟vc,新建乙個win32控制台程式,設定為unicode環境

**://author: hgyxb

//email: [email protected]

#include "stdafx.h"

#include

using namespace std;

#ifdef   _unicode  

#define   tstring   wstring  

#else  

#define   tstring   string  

#endif 

//設定迅雷com路徑

#define activexpath "d:/program files/green files/thunder network/thunder/comdlls/thunderagent.dll"

#import  activexpath no_namespace

//設定迅雷com的物件型別

typedef iagent cactivex;

//設定com的物件名稱

tstring g_strobjname=l"thunderagent.agent";

cactivex* initactivex(tstring &strobjname)

else

}else

}wstring convertansitounicode(const string stransi)

//獲得剪下板內容

tstring getclipboardtext()

}closeclipboard();

}return str;

}#pragma comment( linker, "/subsystem:/"windows/" /entry:/"wmaincrtstartup/"" )//隱藏視窗

int _tmain(int argc, _tchar* argv)

///在這裡你可以新增你的**了

if (argc>1)

//新增**結束

/::couninitialize();

return 0;

}1.其中迅雷com的路徑根據經驗找,一般和com名相似.

2.com的物件名稱從指令碼中獲得.

3.iagent這個型別是在編譯程式後,debug目錄下會出現thunderagent.tlh檔案(import "thunderagent.dll"後會出現),開啟thunderagent.tlh,裡面全是

定義,定義型別為iagent類,所以用iagent.

4.以下**根據指令碼和thunderagent.tlh檔案裡的定義並且試驗然後如此使用

obj->addtask(argv[1],"","","","",-1,0,-1);//argv[1]為程式接收到的引數

obj->committasks();

obj->release(); 

下面再給乙個案例,新增右鍵呼叫"文語通"朗讀

ir_link.htm(對應ie右鍵"使用「文語通」朗讀鏈結")內容

ir_select.htm(對應ie右鍵"使用「文語通」朗讀選定內容")內容

vc**:

//author: hgyxb

//email: [email protected]

#include "stdafx.h"

#include

using namespace std;

#ifdef   _unicode  

#define   tstring   wstring  

#else  

#define   tstring   string  

#endif 

//將外部程式的com元件(即dll檔案)路徑代替d:/program files/ifly info tek/ireader2.0/ireadercom.dll

#define activexpath "d:/program files/ifly info tek/ireader2.0/ireadercom.dll"

#import  activexpath no_namespace

//將型別iireader改為外部程式的型別

typedef iireader cactivex;

//將外部程式com元件的名稱代替ireadercom.ireader

tstring g_strobjname=l"ireadercom.ireader";

cactivex* initactivex(tstring &strobjname)

else

}else

}wstring convertansitounicode(const string stransi)

//獲得剪下板內容

tstring getclipboardtext()

}closeclipboard();

}return str;

}#pragma comment( linker, "/subsystem:/"windows/" /entry:/"wmaincrtstartup/"" )//隱藏視窗

int _tmain(int argc, _tchar* argv)

///新增**結束

/::couninitialize();

return 0;}

關於IE裡的nextSibling

script varshq shq.cmenu function e script div id div1 onclick shq.cmenu event a href 特色 a div div id div2 div 系統環境 win8,ie11 過程描述 當點選 特色 時,div2的innerh...

給IE的右鍵選單增加功能

var parentwin external.menuarguments var doc parentwin.document var sel doc.selection var rng sel.createrange var str new string rng.text rng.text end...

新增右鍵新建選單裡的內容

當您在windows桌面單擊滑鼠右鍵,選擇 新建 來建立快捷方式或資料夾時,除了快捷方式與資料夾這2個選項之外,還有乙個很長的檔案選單,包含了電腦中安裝的一些應用軟體,您可以很容易地建立檔案列表中所包含型別的新檔案。我們在這裡向您介紹如何通過修改登錄檔來定製滑鼠右鍵快捷選單中的 新建 選單所包含的專...