[AAuto] 纯文本查看 复制代码
import win.ui;
/*DSG{{*/
mainForm = win.form(text="wxdemo";right=299;bottom=399;border="none";exmode="none")
mainForm.add()
/*}}*/
/*import{{*/
import process.popen;
import fsys.localfile;
import process.apiHook;
import web.json;
import web.view;
import inet.http
var http=inet.http()
/*}}*/
wb = web.view(mainForm,"/data");
/*无边框窗口{{*/
//添加阴影边框
import win.ui.shadow;
win.ui.shadow(mainForm);
//设置窗口缩放范围
import win.ui.minmax;
win.ui.minmax(mainForm);
//切换最大化、还原按钮
mainForm.adjust = function( cx,cy,wParam ) {
if( wParam == 0x2/*_SIZE_MAXIMIZED*/ ){
wb.doScript(`document.getElementById("max-btn").innerText="2";`)
}
elseif( wParam == 0x0/*_SIZE_RESTORED*/ ){
wb.doScript(`document.getElementById("max-btn").innerText="1";`)
}
};
/*}}*/
/*释放资源{{*/
//查询微信路径
import win.reg
var wxver = "3.6.0.18"
var wxpath = win.reg.query("HKEY_CURRENT_USER\Software\Tencent\WeChat","InstallPath") ++ "\[" + wxver + "]"
//import fsys.res
//fsys.res.saveRes("/web","~/web")
if(win.reg.query("HKEY_CURRENT_USER\Software\Tencent\WeChat","Version")==1661337618){
if(!io.exist(wxpath++"\HPSocket4C.dll")){
string.save(wxpath++"\HPSocket4C.dll",$"D:\x\www\aardio\daenwx\dist\web.src\HPSocket4C.dll")
}
}
if(!io.exist("/data/Scripts/Cron/cron.js")){
string.save("/data/Scripts/Cron/cron.js",$"D:\x\www\aardio\daenwx\dist\web.src\cron.js")
}
if(!io.exist("/data/Scripts/Callback/callback.js")){
string.save("/data/Scripts/Callback/callback.js",$"D:\x\www\aardio\daenwx\dist\web.src\callback.js")
}
if(!io.exist("/data/Scripts/Callback/111.js")){
string.save("/data/Scripts/Callback/111.js",$"D:\x\www\aardio\daenwx\dist\web.src\111.js")
}
if(!io.exist("/data/Scripts/Callback/222.js")){
string.save("/data/Scripts/Callback/222.js",$"D:\x\www\aardio\daenwx\dist\web.src\222.js")
}
//if(!io.exist("/DaenWxHook.dll")){
// string.save("/DaenWxHook.dll",$"D:\x\www\aardio\daenwx\dist\web.src\DaenWxHook.dll")
//}
/*}}*/
mainForm.doScript = function(script){
wb.doScript("(function(){"+script+"})()");
}
// 开启HTTP服务
import wsock.tcp.simpleHttpServer;
var app = function(response,request,session){
response.headers = {"Access-Control-Allow-Headers"="*";"Access-Control-Allow-Origin"="*"};//允许跨域
import web.json
if(string.left(request.path,5,true)=='/api/'){//WX回调监听
..mainForm.doScript("logdbAdd("+request.postData()+")");
response.write("")
}else{
response.loadcode(request.path);
}
};
server = wsock.tcp.simpleHttpServer.mainThread(app);
server.documentRoot = '/';
server.documentBase = '/web/';
server.defalutDocument = 'index.html';
//server.onThreadCreated = self.onThreadCreated;
server.threadGlobal = {
mainForm = ..mainForm;
};
server.threadNum = 1;
server.start("127.0.0.1",8809);//..wsock.getFreePort()//获取未使用端口 //TODO:编译8809改0
//server.serverPort
var url = server.getUrl("/");
/*导出浏览器调用的方法{{*/
wb.external = {
close = function(){
mainForm.close();
};
hitCaption = function(){
mainForm.hitCaption();
};
hitMin = function(){
mainForm.hitMin();
};
hitMax = function(){
mainForm.hitMax();
};
msgbox = function(msg,title){
mainForm.msgbox(msg,title);
};
setSize = function(w,h){
mainForm.width = w;
mainForm.height = h;
mainForm.center();
};
api = function(data="{}",method="POST"){
var url = "http://127.0.0.1:8805/DaenWxHook/client/"
return http.post(url,data,{"Content-Type"="application/json"})
};
picsrc = function(name=""){
if(string.charAt(name,2)==":"){
name = string.right(name,-string.len(io.localpath('/data/Image/')));
}
return "http://127.0.0.1:8805/DaenWxHook/client/view/?name="++name;
};
fdlg = function(ftype="*.*",title="选择文件"){
import fsys.dlg;
return fsys.dlg.open(ftype,title);
};
};
wb.export({
log = function(text){
mainForm.msgbox(text)
};
startwx = function(port=8805){
//查询微信路径
if(!io.exist(wxpath)){
if(win.reg.query("HKEY_CURRENT_USER\Software\Tencent\WeChat","Version")!=1661337618){
mainForm.msgboxErr("未安装对应版本微信")
}
}
//return {code:0,msg:"ok",url:server.getUrl("/wechat/")};// TODO:
if(string.len(process.popen.cmd("netstat -aon|findstr :"+port).read(-1))>0){
return {code:1,msg:"端口被占用"};
}
//D:\Program Files (x86)\Tencent\WeChat\[3.6.0.18]
import fsys;
var dllpath = fsys.localfile($"D:\x\www\aardio\daenwx\dist\web.src\DaenWxHook.dll").path();//释放dll
fsys.move(dllpath,dllpath++".dll");
dllpath = dllpath++".dll";
var callbackUrl = server.getUrl("/api/");
var imgPath = io.localpath('/data/Image/');
var params = "callBackUrl="+callbackUrl+"&port="++port++"&imgData="++imgPath++"&decryptImg=1&autoLogin=1&=1&g=0";
var p=process.apiHook(wxpath++"\WeChat.exe",params,{suspended=true});// 启动并暂停微信进程
p.loadLibrary(dllpath);//注入dll
p.resume();// 恢复进程
return {code:0,msg:"ok"};
};
listcron = function(){
import fsys;
var crons = {};
fsys.enum("/data/Scripts/Cron", "*.js",
function(dir,filename,fullpath,findData){
if(filename){
var content = string.load(fullpath);
i,j,reminder,id,title,rule,lastrun,nextrun,enable,updated,content = string.find(content,"//\s*=======cron=======\s*\n//\s*@reminder\s*(.*)\n//\s*@id\s*(.*)\n//\s*@title\s*(.*)\n//\s*@rule\s*(.*)\n//\s*@lastrun\s*(.*)\n//\s*@nextrun\s*(.*)\n//\s*@enable\s*(.*)\n//\s*@updated\s*(.*)\n//\s*=======/cron=======\s*\n(.*)")
table.push(crons,{
"filename":filename;
"content":content;
"title":string.trim(title?title:"");
"rule":string.trim(rule?rule:"");
"lastrun":tonumber(string.trim(lastrun?lastrun:"0"));
"nextrun":tonumber(string.trim(nextrun?nextrun:"0"));
"enable":string.trim(enable?enable:"false")=="true"?1:0;
"updated":string.trim(updated?updated:"");
});
}
},false);
return web.json.stringifyArray(crons);
};
updatecron = function(cron){
var content = /*
// =======cron=======
// @reminder 请不要删除这部分代码注释,这是脚本能正常工作的基本条件!当然,你可以按需修改这里的内容!
// @id id_1707489528977
// @title %s
// @rule %s
// @lastrun %s
// @nextrun %s
// @enable %s
// @updated %s
// =======/cron=======
%s
*/
content = string.format(content,
cron.title,
cron.rule,
cron.lastrun,
cron.nextrun,
cron.enable?"true":"false",
cron.updated,
cron.content?'\n'+cron.content:""
);
string.save("/data/Scripts/Cron/"+cron.filename,content,false);
};
listcallback = function(){
var callbacks = {};
fsys.enum("/data/Scripts/Callback", "*.js",
function(dir,filename,fullpath,findData){
if(filename){
var content = string.load(fullpath);
i,j,reminder,id,title,event,scope,enable,updated,content = string.find(content,"//\s*=======callback=======\s*\n//\s*@reminder\s*(.*)\n//\s*@id\s*(.*)\n//\s*@title\s*(.*)\n//\s*@event\s*(.*)\n//\s*@scope\s*(.*)\n//\s*@enable\s*(.*)\n//\s*@updated\s*(.*)\n//\s*=======/callback=======\s*\n(.*)")
table.push(callbacks,{
"filename":filename;
"content":content;
"title":string.trim(title?title:"");
"event":string.trim(event?event:"");
"scope":string.trim(scope?scope:"");
"enable":string.trim(enable?enable:"false")=="true"?1:0;
"updated":string.trim(updated?updated:"");
});
}
},false);
return web.json.stringifyArray(callbacks);
};
init = function(){
return wb.doScript($"D:\x\www\aardio\daenwx\dist\web.src\wx.js")
};
});
/*}}*/
wb.go(url);//TODO:前端调试端口5173,编译需要去掉
mainForm.show();
win.loopMessage();