import win.ui;
/*DSG{{*/
var winform = win.form(text="wx自动化";right=292;bottom=624)
winform.add(
edit={cls="edit";left=18;top=17;right=269;bottom=479;edge=1;multiline=1;z=1};
static={cls="static";text="添加间隔";left=23;top=502;right=79;bottom=518;transparent=1;z=4};
static2={cls="static";text="~";left=152;top=501;right=166;bottom=521;transparent=1;z=6};
static3={cls="static";text="秒";left=233;top=503;right=250;bottom=521;transparent=1;z=8};
static4={cls="static";text="免费软件";left=100;top=596;right=162;bottom=616;transparent=1;z=9};
停止={cls="button";text="停止 Alt + s";left=126;top=551;right=205;bottom=583;z=3};
开始={cls="button";text="开始";left=37;top=552;right=116;bottom=584;z=2};
间隔={cls="edit";text="3";left=89;top=499;right=137;bottom=522;edge=1;z=5};
间隔a={cls="edit";text="5";left=172;top=500;right=220;bottom=523;edge=1;z=7}
)
/*}}*/
/*
if(winform.edit.text == ""){
winform.edit.text = "微信号一行一个"
}
*/
function main(winform){
import FlaUI.UIA3;
import console;
if(winform.edit.text == ""){
win.msgboxErr("请放入需要添加的微信号","错误")
return ;
}
var 号码 = string.splitEx(winform.edit.text,'\r\n')
console.dumpJson(号码,"\r\n")
//查找窗口,禁用模式匹配语法搜索窗口(首字符为 `@`)
var window = FlaUI.FindWindow("WeChat.exe","@WeChatMainWndForPC","@微信");
if(!window) error("未找到窗口");
//前置窗口
window.Focus();
//查找控件
thread.delay(1000)
for(i=1;#号码;1){
console.log("正在执行",号码[1])
var 确定 = window.FindFirstByXPath(`//Button[@Name="确定"]`);
if(确定){
console.log("确定",mouse.click(确定))
thread.delay(1000)
}
var 清空 = window.FindFirstByXPath(`//Button[@Name="清空"]`);
if(清空){
console.log("清空",mouse.click(清空))
thread.delay(1000)
}
var 通讯录 = window.FindFirstByXPath(`//Button[3][@Name="通讯录"]`);
if(通讯录){
console.log("通讯录",mouse.click(通讯录))
thread.delay(1000)
var 搜索 = window.FindFirstByXPath(`//Edit[@Name="搜索"]`);
if(搜索){
console.log("搜索",mouse.click(搜索))
thread.delay(1000)
key.sendString(号码[i])
thread.delay(1000)
var 联系人 = window.FindFirstByXPath(`//Text[@Name="微信号: < em >`+号码[i]+`</ em >"]`);
if(联系人){
console.log("已经是好友")
}else{
var 查找微信号 = window.FindFirstByXPath(`//Text[@Name="网络查找微信号"]`);
if(查找微信号){
console.log("查找微信号",mouse.click(查找微信号))
thread.delay(1000)
var 弹窗 = FlaUI.FindWindow("WeChat.exe","@ContactProfileWnd","@微信");
if(弹窗) {
var 添加到通讯录 = 弹窗.FindFirstByXPath(`//Button[@Name="添加到通讯录"]`);
if(添加到通讯录){
console.log("添加到通讯录",mouse.click(添加到通讯录))
thread.delay(1000)
var 确定 = window.FindFirstByXPath(`//Button[@Name="确定"]`);
//var 确定 = window.FindFirstByXPath(`//Button[@Name="取消"]`);
if(确定){
var 间隔 = math.random(tonumber(winform.间隔.text) * 1000,tonumber(winform.间隔a.text) * 1000)
console.log("确定",mouse.click(确定),"添加间隔",(间隔/1000),"毫秒")
thread.delay(间隔)
}
}
}else {
console.log("未找到窗口")
}
}
}
}
}
}
console.log("完成")
}
import console;
thrdHandle = null
winform.开始.oncommand = function(id,event){
thrdHandle = thread.create(main,winform )
}
winform.停止.oncommand = function(id,event){
//线程是否再运行
//var act = thread.stillActive(thrdHandle)
//线程恢复运行
//thread.resume(thrdHandle)
//使用线程句柄就可以控制线程,例如下面的函数暂停线程
//thread.suspend(thrdHandle)
//线程停止
if(thrdHandle){
thread.terminate(thrdHandle, 0)
thrdHandle = null
}
}
var hkId;
//删除之前注册的热键,hkId如果是null空值,此函数可忽略不做任何操
winform.unreghotkey(hkId);
//重新注册系统热键;
hkId = winform.reghotkey(
function(id,mod,vk){
if(thrdHandle){
thread.terminate(thrdHandle, 0)
thrdHandle = null
}
winform.msgbox("停止运行")
},1,83
);
winform.show();
win.loopMessage();
return winform;
|