MSN爬楼梯和Monkey Testing --from屋顶上的木帷幕

类别:编程语言 点击:0 评论:0 推荐:

其实,我只是自己写了一个小程序让MSN Messenger以很短的间隔连续的改变online/offline的状态而以。而且,程序也没有深入用到MSN的Protocol或者SDK,也没有用SendMessage/FindWindow之类的,只是用SendKeys写了个VBScript:

LoopCount = 5 'Show 5 signed-in windows Set WshShell= WScript.CreateObject("WScript.Shell") WshShell.AppActivate "MSN Messenger" 'send "alt+f, m, f, alt+f, m, o" For i = 1 to LoopCount WshShell.SendKeys "%f" WshShell.SendKeys "m" WshShell.SendKeys "f" WScript.Sleep 500 WshShell.SendKeys "%f" WshShell.SendKeys "m" WshShell.SendKeys "o" WScript.Sleep 500 Next

如果用Visual Basic 6.0写也很方便的,只要改动一点点地方:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Command1_Click() LoopCount = 5 'Show 5 signed-in windows Set WshShell = CreateObject("WScript.Shell") WshShell.AppActivate "MSN Messenger" 'send "alt+f, m, f, alt+f, m, o" For i = 0 To Int(Val(Me.Text1.Text)) WshShell.SendKeys "%f" WshShell.SendKeys "m" WshShell.SendKeys "f" Sleep 500 WshShell.SendKeys "%f" WshShell.SendKeys "m" WshShell.SendKeys "o" Sleep 500 Next End Sub

如果运行的不是MSN Messenger而是Windows Messenger 4.7/5.0,把AppActivate的参数改掉就可以了。我挺喜欢这个小把戏的,一次出现5个登录窗口,很醒目的。不过,希望大家不要恶意使用不断的爬,这样会变成DDoS攻击,增加对服务器的负载的,负载大了以后服务器性能变差也会影响别人使用的。如果老是在别人那里出现一堆登录窗口也是不礼貌的,是一种污染。

其实,换个角度看,这就是一个Monkey Testing程序(还够不上完全Smart Monkey的程度)。这也是Windows程序的GUI自动测试的一个最简单的实例

本文地址:http://com.8s8s.com/it/it26317.htm