您的位置:首页 > 其它

简单qq聊天机器人(查找使指定窗口获得焦点->向焦点窗口发送字符->发送)

2010-04-09 11:01 316 查看
<html>
<head>
<title>QQ聊天机器人</title>
</head>
<body>
聊天内容,每句一行
<textarea id=chatText style="width:100%; height:100px;">
</textarea>
要发送的窗口的标题<input id=winTitle>
<input type=button value=开始发送信息 onclick="clickSend(1)">
<input type=button value=停止发送信息 onclick="clickSend(0)">
<textarea>
程序作用:向已打开的聊天模式的qq窗口自动发送设定的语句,(可添加功能:可利用模拟按键的方式复制对方发送过来的信息,再读取剪贴板中的内容到程序中分析,最后智能的回答)
实现办法:利用wscript.shell实现模拟按键的方式达到发送,复制等聊天时要用到的方法,其它功能可变通通过按键实现.
</textarea>
</body>

<script>

var wshshell = new ActiveXObject("WScript.Shell");
var sendTimer;

function clickSend(how)
{//发送函数
if (how)
{
document.title = "开始发送,请别动";
clearInterval(sendTimer);
sendTimer = setInterval("sendText();", 3000);
}else
{
document.title = "已停止发送";
clearInterval(sendTimer);
}
}

function sendText()
{
wshshell.AppActivate(winTitle.value);
var theText = chatText.value;
wshshell.SendKeys (theText);
wshshell.SendKeys ("%(s)");
}

</script>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐