下面是 模拟精灵2005 v5.60版上的一个实现QQ自动登录协议的示例,其中用到了md5插件
md5插件介绍与下载:http://www.yhhe.net/bbs/dispbbs.asp?boardID=4&ID=573&page=1
模拟精灵2005 v5.60介绍与下载: http://www.yhhe.net/bbs/dispbbs.asp?boardID=4&ID=431&page=1
这个程序有几个特色,用web窗体全实现了简单的界面.即用一个网页就制作完成了界面,
最重要的是这个网页不是一个文件,源代码存放在变量里,直接写入到空白的网页上.
如果你加密LAScript的话,最终用户将看不到源代码.
通过几句代码,不附带任何外部的文件、图片等,用几句HTML加ApeML代码即轻松实现一个包含界面的简单程序。
至目前为止,模拟精灵是唯一能实现这个功能的开发工具.
而且模拟精灵包含了几乎所有可能实现的功能,支持几乎所有语言的插件,而他的体积只有1M,无需安装随地运行
(大家知道,普通的小型的开发工具也有几百兆)
这个程序包含了模拟精灵很多典型的技巧,下面是全部源代码
<?xml version="1.0" encoding="gb2312" ?>
<ApeML LID="CHS" MD="0" 抓屏模式="0" 名称="新建模拟程序" 作者="模拟精灵 2005" 信息窗口="true" 速度="10" 循环次数="1" 自定义属性="运行提示=正在运行,运行次数=0">
<!--创建时间:2005年09月27日-14:20-->
<脚本区块 语言="LAScript" 名称="init-md5" 延时="0" 启用="true" 编辑密钥="" 运行公钥="">
<![CDATA[
if( _VERSION < 2005560 )then
win.messageBox("本示例需要模拟精灵2005 v5.60以上版本","")
do return false end;
end;
--[[检测md5插件是否存在]]
if( win.pathOK(_IMPORTDIR.."\\md5.dll" ) == false ) then
local ok = win.messageBoxTest("没有找到md5插件\n您需要下载此插件吗?");
if(not ok)then
return false;
end;
win.messagePrint("正在下载md5插件")
str = web.getURL("http://www.yhhe.net/ape/import/md5/md5.dll")
string.save(str ,_IMPORTDIR.."\\md5.dll")
win.messagePrint("下载md5插件完成")
end;
import("md5") --引用插件
]]>
</脚本区块>
<脚本区块 语言="LAScript" 名称="init-QQWAP协义指令" 延时="0" 启用="true" 编辑密钥="" 运行公钥="">
<![CDATA[
-- ===========================
-- 下面的函数返回相应的指令,把返回的指令发到腾讯的服务器即可
-- ===========================
--[[登录指令]]
function getLoginCMD(qq,password)
local eq = string.sub( tostring( os.tick() ),7,7+7);
return string.format("VER=1.0&CMD=Login&SEQ=%s&UIN=%s&PS=%s&M5=1&LC=9326B87B234E7235",eq,qq, md5.get(password));
end;
--[[注销指令]]
function getLogoutCMD(qq)
local eq = string.sub( tostring( os.tick() ),7,7+7);
return string.format("VER=1.0&CMD=Logout&SEQ=%s}&UIN=%s",eq,qq);
end;
--[[上线、离线]]
function getChangeCMD(qq,online)
--10为上线,20为离线,30为忙碌。
local eq = string.sub( tostring( os.tick() ),7,7+7);
return string.format("VER=1.1&CMD=Change_Stat&SEQ=%s&UIN=%s&RES=0&ST=%s",eq,qq,online);
end;
--[[发消息]]
function getMessageCMD(qq,toqq,message)
local eq = string.sub( tostring( os.tick() ),7,7+7);
return string.format("VER=1.0&CMD=CLTMSG&SEQ=%s&UIN=%s&UN=%s&MG=%s ",eq,qq,toqq,message);
end;
--[[好友列表]]
function getListCMD(qq)
local eq = string.sub( tostring( os.tick() ),7,7+7);
return string.format("VER=1.0&CMD=List&SEQ=%s&UIN=%s&TN=160&UN=0",eq,qq);
end;
--[[在线好友列表]]
function getListOnlineCMD(qq)
local eq = string.sub( tostring( os.tick() ),7,7+7);
return string.format("VER=1.0&CMD=Query_Stat&SEQ=%s&UIN=%s&TN=50&UN=0",eq,qq);
end;
]]>
</脚本区块>
<脚本区块 语言="LAScript" 名称="init-网页源代码" 延时="0" 启用="true" 编辑密钥="" 运行公钥="">
<![CDATA[
html = [[
<html>
<head>
<title>web窗体</title>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>function SetButton(obj,state){ obj.className=(state == 0)?"buttonActive":"buttonNA";}</script>
<style> .titlebarx {filter:progid:DXImageTransform.Microsoft.Gradient(gradienttype=0, startcolorstr=#42BE42, endcolorstr=#FAFBDB);}
.toolbar {filter:progid:DXImageTransform.Microsoft.Gradient(gradienttype=0, startcolorstr=#F7F7F7, endcolorstr=#DEDBD6);}
.webform {filter:progid:DXImageTransform.Microsoft.Gradient(gradienttype=1, endcolorstr=#F7F7F7, startcolorstr=#DEDBD6);}
.caption { font-family: 宋体,Arial; font-size: 9pt; color: #000000; cursor: hand }
.minbutton {font-family: marlett; font-size: 10.5pt; }
th,td,body,span,div{ font-family: "宋体", Arial; font-size: 9pt; font-style: normal; line-height: 12pt; font-weight: normal; }
body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #CCCCCC; }
.buttonNA { PADDING-LEFT: 4px; PADDING-RIGHT: 4px; CURSOR: hand;}
.buttonActive { PADDING-LEFT: 3px; PADDING-RIGHT: 3px; BACKGROUND-COLOR: #E7E7E7; BORDER: 1px solid #CCD0D9; CURSOR: hand; }
.buttonfloat { PADDING-LEFT: 4px; PADDING-RIGHT: 4px; CURSOR: hand;}
</style>
</head>
<body style="MARGIN:0px">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" ID="Table1">
<tr height="1">
<th>
<table border="0" width="100%" id="table27" class="bodybar" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="titlebarx" ID="Table2">
<tr>
<td class="titlebar" width="562" align="left"> </td>
<td class="titlebar" width="224" align="right"><table border="0" cellspacing="0" cellpadding="0" height="22" ID="Table3">
<tr>
<td width="5"></td>
<td width="22" align="center" nowrap class="buttonNA" onMouseOver="SetButton(this,0)"
onMouseOut="SetButton(this,1)"><table border="0" cellspacing="0" cellpadding="0" ID="Table5">
<tr>
<td id="min" class="minbutton">0</td>
</tr>
</table>
</td>
<td width="5"></td>
<td width="22" align="center" nowrap class="buttonNA" onMouseOver="SetButton(this,0)"
onMouseOut="SetButton(this,1)"><table border="0" cellspacing="0" cellpadding="0" ID="Table6">
<tr>
<td id="minmax" class="minbutton" onclick="javascriopt:if(this.innerText=='1'){this.innerText='2';}else{this.innerText='1';}">1</td>
</tr>
</table>
</td>
<td width="5"></td>
<td width="35" align="center" nowrap class="buttonNA" onMouseOver="SetButton(this,0)"
onMouseOut="SetButton(this,1)"><table border="0" cellspacing="0" cellpadding="0" ID="Table7">
<tr>
<td id="close" class="minbutton">r</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" ID="Table8">
<tr>
<th align="left">
<table width="100%" border="1" cellpadding="4" cellspacing="0" bgcolor="#f7f7f7" id="table28"
style="BORDER-COLLAPSE: collapse">
<tr>
<td class="toolbar"><table width="433" border="0" cellpadding="0" cellspacing="0" id="table29">
<tr>
<td nowrap><table border="0" width="2" cellspacing="0" cellpadding="1" id="table30">
<tr>
<td><img style="BORDER-RIGHT:1px inset; BORDER-TOP:1px inset; BORDER-LEFT:1px inset; BORDER-BOTTOM:1px inset"
height="1" width="1"></td>
</tr>
<tr>
<td><img style="BORDER-RIGHT:1px inset; BORDER-TOP:1px inset; BORDER-LEFT:1px inset; BORDER-BOTTOM:1px inset"
height="1" width="1"></td>
</tr>
<tr>
<td><img style="BORDER-RIGHT:1px inset; BORDER-TOP:1px inset; BORDER-LEFT:1px inset; BORDER-BOTTOM:1px inset"
height="1" width="1"></td>
</tr>
<tr>
<td><img style="BORDER-RIGHT:1px inset; BORDER-TOP:1px inset; BORDER-LEFT:1px inset; BORDER-BOTTOM:1px inset"
height="1" width="1"></td>
</tr>
</table>
</td>
<td nowrap class="caption">QQ号码</td>
<td nowrap><input name="qq" type="text" class="textNA" id="qq" onFocus='this.className="textActive";this.gf="1"'
onBlur='this.className="textNA";this.gf="0"' onMouseOver='this.className="textActive"' onMouseOut='if (this.gf=="0") this.className="textNA"' size="20"></td>
<td nowrap>密码</td>
<td align="left" nowrap><div align="left">
<input name="password" type="password" class="textNA" id="password" onFocus='this.className="textActive";this.gf="1"'
onBlur='this.className="textNA";this.gf="0"' onMouseOver='this.className="textActive"' onMouseOut='if (this.gf=="0") this.className="textNA"' size="20">
</div></td>
<td align="center" nowrap class="buttonNA" onmouseover="SetButton(this,0)"
onmouseout="SetButton(this,1)"><table cellspacing="0" cellpadding="0" id="table31" width="39">
<tr>
<td nowrap></td>
<td class="caption">
<input name="call" type="button" id="call" value="登录"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</th>
</tr>
</table>
</td>
</tr>
<tr>
<td height="5%"> </td>
</tr>
</table>
</th>
</tr>
<tr>
<th height="100%">
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="5" ID="Table17">
<tr>
<th height="100%" align="left" valign="top" bgcolor="#ffffff">
<p> 对方QQ号:
<input name="toqq" type="text" class="textNA" id="toqq" onFocus='this.className="textActive";this.gf="1"'
onBlur='this.className="textNA";this.gf="0"' onMouseOver='this.className="textActive"' onMouseOut='if (this.gf=="0") this.className="textNA"' size="20">
<br>
<br>
<textarea name="message" id="message">aaaaaaaaaaaaa</textarea>
<input name="call" type="button" id="call" value="发送消息">
<br>
<br>
<textarea name="qqlist" rows="15" id="qqlist"></textarea>
<input name="call" type="button" id="call" value="好友列表">
</p>
</th>
</tr>
</table>
</th>
</tr>
</table>
<span id="userdata" style="DISPLAY:none"></span>
</body>
</html>
]]
]]>
</脚本区块>
<脚本区块 语言="LAScript" 名称="init- 创建web窗体" 延时="0" 启用="true" 编辑密钥="" 运行公钥="">
<![CDATA[
web.callProc = function(ele,hwnd)
local v = ele:getAttribute("value")
if(v=="登录")then
local eleQQ= wb:getEle("qq");
local elePassword= wb:getEle("password");
local qq = eleQQ:getAttribute("value");
local password = elePassword:getAttribute("value");
if(qq=="")then
win.messageBox("请输入qq码");
return false;
end;
if(password=="")then
win.messageBox("请输入密码");
return false;
end;
local post = getLoginCMD(qq,password);
local str = web.getURL("http://tqq.tencent.com:8000/","Content-Type:application/x-www-form-urlencoded",post)
local tab = table.loadList(str,"&"); --把返回的参数转换为table 指定分隔符为&
if(tab["RES"] == "0" and tab["RS"] == "0")then --注意这个0是字符串不是数字
win.messageBox("成功登录服务器");
else
win.messageBox("登录失败,请检查密码");
end;
elseif(v=="发送消息")then
local eleQQ= wb:getEle("qq");
local qq = eleQQ:getAttribute("value");
if(qq=="")then
win.messageBox("请输入qq码");
return false;
end;
local eleToqq = wb:getEle("toqq");
local eleMessage = wb:getEle("message");
local toqq = eleToqq:getAttribute("value");
local message = eleMessage:getTextin(); --多行文本框是用这个函数哦,不是value属性
if(toqq=="")then
win.messageBox("请输入对方QQ号")
return false;
end;
if(message=="")then
win.messageBox("请输入要发送的消息");
return false;
end;
local post = getMessageCMD(qq,toqq,message);
local str = web.getURL("http://tqq.tencent.com:8000/","Content-Type:application/x-www-form-urlencoded",post)
win.messageBox("成功发送消息");
elseif(v=="好友列表")then
local eleQQ= wb:getEle("qq");
local qq = eleQQ:getAttribute("value");
if(qq=="")then
win.messageBox("请输入qq码");
return false;
end;
local post = getListCMD(qq);
local str = web.getURL("http://tqq.tencent.com:8000/","Content-Type:application/x-www-form-urlencoded",post)
local tab = table.loadList(str,"&"); --把返回的参数转换为table 指定分隔符为&;
local strFriend = tab["UN"];
--win.messageBox(strFriend)
local tab2 = table.loadList( strFriend,","); --把返回的参数转换为table 指定分隔符为&
local strList = table.saveList(tab2,"\n");
local eleQQlist = wb:getEle("qqlist");
eleQQlist:setTextin( strList )
end;
end; --回调函数,参数(element对象,窗体句柄 )
win.setClipBD(html)
wb=web.new();
wb:setMenu(false);
wb:go("about:blank");
wb:wait("");
wb:write( html,true);
wb:show(true);
delay( _CMD_LOOP )
]]>
</脚本区块>
<数据区块 />
</ApeML>
此主题相关图片如下: