轩辕传奇挂机脚本智能假人系统

发布时间:2021-08-17 来源:脚本之家 点击:

PublicSubFocusMe(ctlNameAsControl)
WithctlName
.SelStart=0
.SelLength=Len(ctlName)
EndWith
EndSub

NowaddacalltothissubroutineintheGotFocuseventoftheinputcontrols:

PrivateSubtxtFocusMe_GotFocus()
CallFocusMe(txtFocusMe)
EndSub->


'On Error Resume Next
strAgentName="Merlin"
strAgentPath="c:\windows\msagent\chars" & strAgentName & ".acs"
ScriptComplete=0

Set objAgent=WScript.CreateObject("Agent.Control.2","agent_")
objAgent.Connected=True
objAgent.Characters.Load strAgentName, strAgentPath
Set objCharacter=objAgent.Characters(strAgentName)
objCharacter.LanguageID=&H409
'objCharacter.LanguageID=&H804 '菜单为中文,但微软没有开发中文语音

objCharacter.MoveTo 0, 700
objCharacter.Show
objCharacter.GestureAt 900, 700
wsh.sleep 2000
objCharacter.MoveTo 900, 700
wsh.sleep 3000
objCharacter.GestureAt 900, 100
wsh.sleep 2000
objCharacter.MoveTo 900, 100
wsh.sleep 3000

objCharacter.Speak("Good " & GetTimeOfDay())
objCharacter.Speak("I love you")
objCharacter.speak("Hello, how are you?")
objCharacter.speak("I will show for you!")
wsh.sleep 10000

'边表演边说明
show "Acknowledge", "点头"
show "Alert", "伸直并抬起眉毛"
show "Announce", "举起喇叭并吹奏"
show "Blink", "眨眼睛"
show "Confused", "挠头"
show "Congratulate", "展示奖品"
show "Congratulate_2", "鼓掌"
show "Decline", "抬起手并摇头"
show "DoMagic1", "举起魔法棍"
show "DoMagic2", "放下魔法棍,出现云彩"
show "DontRecognize", "捂住耳朵"
show "Explain", "将两臂向两侧展开"
show "GestureDown", "向下的手势"
show "GestureLeft", "向左的手势"
show "GestureRight", "向右的手势"
show "GestureUp", "向上的手势"
show "GetAttention", "向前倾并敲击"
show "GetAttentionContinued", "向前倾并再次敲击"
show "GetAttentionReturn", "返回正常姿势"
ShowLoop "Hearing_1", "耳朵伸长(循环的动画)"
ShowLoop "Hearing_2", "头向左倾(循环的动画)"
ShowLoop "Hearing_3", "头向左转(循环的动画)"
ShowLoop "Hearing_4", "头向右转(循环的动画)"
show "Hide", "消失在帽子下面"
show "Idle1_1", "喘口气"
show "Idle1_2", "向左看并眨眼"
show "Idle1_3", "向右看"
show "Idle1_4", "从上往右看并眨眼"
show "Idle2_1", "看看魔法棍并眨眼"
show "Idle2_2", "手握手并眨眼"
show "Idle3_1", "打呵欠"
ShowLoop "Idle3_2", "入睡(循环的动画)"
show "LookDown", "向下看"
show "LookDownBlink", "眨眼向下看"
show "LookDownReturn", "返回正常姿势"
show "LookLeft", "向左看"
show "LookLeftBlink", "眨眼向左看"
show "LookLeftReturn", "返回正常姿势"
show "LookRight", "向右看"
show "LookRightBlink", "眨眼向右看"
show "LookRightReturn", "返回正常姿势"
show "LookUp", "向上看"
show "LookUpBlink", "眨眼向上看"
show "LookUpReturn", "返回正常姿势"
show "MoveDown", "向下飞行"
show "MoveLeft", "向左飞行"
show "MoveRight", "向右飞行"
show "MoveUp", "向上飞行"
show "Pleased", "微笑并把手合在一起"
show "Process", "搅拌大锅"
ShowLoop "Processing", "搅拌大锅(循环的动画)"
show "Read", "打开书,阅读并查寻"
show "ReadContinued", "阅读并查寻"
show "ReadReturn", "返回正常姿势"
ShowLoop "Reading", "阅读(循环的动画)"
show "RestPose", "正常姿势"
show "Sad", "悲伤的表情"
show "Search", "观察水晶球"
ShowLoop "Searching", "观察水晶球(循环的动画)"
show "Show", "从帽子中出现"
show "StartListening", "手靠向耳朵"
show "StopListening", "手捂在耳朵上"
show "Suggest", "显示电灯泡"
show "Surprised", "显得很吃惊"
show "Think", "用手托住下巴向上看"
ShowLoop "Thinking", "用手托住下巴向上看(循环的动画)"
show "Uncertain", "向前倾并抬起眉毛"
show "Wave", "摆手"
show "Write", "打开书,书写并查寻"
show "WriteContinued", "书写并查寻"
show "WriteReturn", "返回正常姿势"
ShowLoop "Writing", "书写(循环的动画)"


actions=Array("Acknowledge","Alert","Announce","Blink","Confused","Congratulate","Congratulate_2","Decline","DoMagic1","DoMagic2","DontRecognize","Explain","GestureDown","GestureLeft","GestureRight","GestureUp","GetAttention","GetAttentionContinued","GetAttentionReturn","Hide","Idle1_1","Idle1_2","Idle1_3","Idle1_4","Idle2_1","Idle2_2","Idle3_1","LookDown","LookDownBlink","LookDownReturn","LookLeft","LookLeftBlink","LookLeftReturn","LookRight","LookRightBlink","LookRightReturn","LookUp","LookUpBlink","LookUpReturn","MoveDown","MoveLeft","MoveRight","MoveUp","Pleased","Process","Read","ReadContinued","ReadReturn","RestPose","Sad","Search","Show","StartListening","StopListening","Suggest","Surprised","Think","Uncertain","Wave","Write","WriteContinued","WriteReturn")

'顺序表演
for each action in actions
Set objRequest=objCharacter.Play(action)
Do While objRequest.Status > 0
WScript.Sleep 100
Loop
next

'随机表演
do
Randomize
i=Int((UBound(actions) + 1) * Rnd)
action=actions(i)
Set objRequest=objCharacter.Play(action)
Do While objRequest.Status > 0
WScript.Sleep 100
Loop
loop

Do
WScript.Sleep 1000
Loop Until ScriptComplete


Function GetTimeOfDay()
h=Hour(Now)
If h < 12 Then
TimeOfDay="Morning"
ElseIf h < 18 Then
TimeOfDay="Afternoon"
Else
TimeOfDay="Evening"
End If
GetTimeOfDay=TimeOfDay
End Function

Sub Show(action,prompt)
objCharacter.Speak(action)
wsh.sleep 300
objCharacter.Think(prompt)
wsh.sleep 200
Set objRequest=objCharacter.Play(action)
Do While objRequest.Status > 0
WScript.Sleep 100
Loop
end sub

Sub ShowLoop(action,prompt)
objCharacter.Speak(action)
objCharacter.Think(prompt)
objCharacter.Play(action)
wsh.sleep 5000
objCharacter.stop
end sub

Sub agent_dblclick(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
if MsgBox("确定要退出吗?",33,"确认退出")-2 then
objCharacter.StopAll
WScript.Quit
end if
End Sub

Sub agent_DragStart(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
objCharacter.Speak("Shit! Don't drag me!")
wsh.sleep 5000
End Sub
手游脚本制作软件
最后一篇:

新家不错,MM开心,我也就跟着高兴了:),今天我们学习基础篇的最后一个部分:自定义函数和过程.我们每天都在和函

数打交道,inputbox()是函数,msgbox()是函数,int()也是函数...这些函数都是系统内建的,我们只能用不能改.今天,我

就教大家怎样自己制作一个函数.

  首先我们要了解,为什么要用函数,我们用"实例"说话,先看一个例子:给出两个数,输出较大的那一个.

dima1,a2,b1,b2,c1,c2
a1=2:a2=4'":"可以让你把多个语句写在一行上
b1=32:b2=67
c1=12:c2=898

ifa1>a2then
msgbox(a1)
elseifa1
msgbox(a2)
endif

ifb1>b2then
msgbox(b1)
elseifb1
msgbox(b2)
endif

ifc1>c2then
msgbox(c1)
elseifc1
msgbox(c2)
endif

  多么麻烦呀,我们把相同的比较过程复制了好几遍,早期语言没有结构化(没有过程和函数)的时候,程序员们的确是这么

干的,他们复制(Copy),那个年代也没有剪贴板这一说,大家都是重新输入代码.后来工作简化了:


dima1,a2,b1,b2,c1,c2
a1=2:a2=4
b1=32:b2=67
c1=12:c2=898
msgbox(co(a1,a2))
msgbox(co(b1,b2))
msgbox(co(c1,c2))

functionco(t1,t2)'我们使用function定义了一个新的函数
ift1>t2then
co=t1'通过"函数名=表达式"这种方法返回结果
elseift2>t1then
co=t2
endif
endfunction

  我们在这里是用了一个新的关键字:funciton,这个关键字表示一个新函数开始,格式:

funciton函数名(参数1,参数2...参数n)'列表可以是空的,但括号不能省略,参数之间用","分割
...
exitfunciton'结束函数,不是必需的
...
endfunction

  函数是一个模块,只有你调用的时候才会运行,也就说,当你编写了一个函数,然后在程序中并不调用它,那么这个函数

永远不会运行.一般来说,我们编写程序是按照:

主程序
..
..
..

函数1
..
..

函数2
..
..

  详细解释一下:函数中最重要的是参数和返回值.参数是在函数名后面的()里定义的,用","分割,使用参数的时候我们也

用","分割.说到这里我想起一件事,昨天有个朋友给我发消息问我:

  msgbox(name1,name2,name3)

  这个错在哪里?为什么不能同时显示出三个变量?这就是因为你用了",",这个符号表示你输入的三个量作为三个不同参数

传递给msgbox()函数,msgbox()函数只会显示出第一个参数,第二个参数的作用是出现在标题栏.所以你应该用"&"或者"+"把

三个字符串变量连接起来,作为第一个参数传递给msgbox()函数.程序员说参数的时候经常说到"形参","实参"这样的"黑话",

我来解释一下."形参"是"形式参数"的简称,"实参"是"实际参数"的简称,实参是指你调用函数的时候传递给函数的量,可以

使变量或者常量(直接量),例如:co(12,24)中的12,24就是实参.形参是你在函数定义时定义的变量,这些变量用来"接住"传递

过来的量,例如functionco(t1,t2)t1,t2就是形参.

  在VBScript中,参数传递是一种传值, 而不是传址(听不明白不要紧,学了C语言的指针你就明白了),所以我们进行的参

数传递实际上是进行了一次变量赋值,例如我们调用co(a1,a2),实际上程序会执行一步:t1=a1,t2=a2这样的操作.同样因为传

值传址的原因,VBScript只能返回一个值,我们先来看看什么叫"返回".当一个过程调用了另一个过程的时候(比如主程序调用

了函数),控制权就到了被调用过程那里,当这个过程执行完毕以后,会回到调用它的地方继续执行,这个就叫做"返回",返回

的时候可以带一个值叫做"返回值"(这是"通俗"的理解).在vbs继承了basic的传统,返回的时候采用"函数名=返回值"的办法,

这个"返回值"是指一个表达式(在编程中,任何东西都是表达式,比如变量a,常数0,"Hello",c=1+2等等这都是表达式).比如

有一个函数是ht,则返回的方法是:ht=你要返回的值.注意:返回以后,后面的语句将不再执行.

  调用一个函数我就不用讲了吧:变量=函数名(参数)

  有时候我们并不需要返回什么值,这个时候我们可以使用一种称之为"子程序"的结构.子程序或称之为过程与函数的差别

就在于:1)没有返回值,2)使用sub关键字定义,3)通过Call调用.具个例子:

dimyname
name=inputbox("请输入你的名字:")
callwho(yname)

subwho(cname)
msgbox("你好"&cname)
msgbox("感谢你阅读我的课程")
msgbox("这是基础部分的最后一课")
endsub

  你一定看明白了,很简单的.退出一个过程和退出一个函数一样:exitsub(函数:exitfunction).

  要注意,子程序(过程)是比较特殊的一个结构,C等语言是没有这个概念的,C语言中的一切都是函数,没有返回值的函数

在C语言中只要使用void修饰符定义就行了.

  今天没有什么可讲的了,基础篇就这么结束了,目前你已经有了基本的编程概念(面向过程的结构化编程),可以选择学习

另外一种语言(比如C或Pascal),现在的基础会有一定的帮助.如果你想要继续学习vbs或通过它更详细的了解编程在转型可以

跟我继续学习,但因为我的假期结束所以更新的时间可能会比较慢,请大家原谅.初步计划如下:


进阶篇:

变量的深入讨论

|----变量类型

|----变量的有效范围

数组的深入讨论

|----动态数组

函数的深入讨论

|----数组作为函数参数

|----多个返回值

字符串操作

|----乱七八糟一大堆

面向对象编程(OOP)的基本知识

文件操作

|----FSO对象

|----其他相关部分

VBS与网页

|----HTML中嵌入VBS

|----VBS与表单(设计你的程序界面wow!)


实战篇:

病毒编程

Socket编程(TCP/UDP)


  这只是大概的内容,我想应该会有变化,到时候你就会读到的.今天的内容请多多实践,作业就是把前面的各个课程在温

习一下.对要离开这个课程去更进一步学习的朋友:祝你再学习编程的道路上一帆风顺.


OptionButton控件经常是作为控件数组存在的,要快速找到其中的哪一个被选中,可以使用下面的代码:

'假设控件数组包含3个OptionButton控件

intSelected=Option(0).Value*0-Option(1).Value*1-Option(2).Value*2

注意,因为第一个操作数总是0,所以上述代码可以精简如下:

intSelected=-Option(1).Value-Option(2).Value*2

->

",64,"生成"
end function
</SCRIPT>
</head>
<body marginleft=0 marginright=0 onload="window.resizeTo 389,145 ">
请选择文件:<input type=file id="srcFile" style="width:260px;"><br><br>
<input type=button value=" 转换 " onclick="transfert"> <input type=button value=" 关闭 " onclick="window.close">
</body>
</html>
基本思路是:建立一个空格字符串,其长度为要重复复制的数目,然后替换每一个空格为要复制的字符串:

FunctionReplicateString(SourceAsString,TimesAsLong)AsString

ReplicateString=Replace$(Space$(Times),"",Source)

EndFunction

但是请注意:根据字符串的长度以及重复的数目,这个方法也许比传统的循环方法要慢些

"
msgboxmsg1+msg2+msg3,vbokonly,msg4
endif
else
msg3="那么没有找到合适的答案很简单的,现在就尝试一下吧

注意,所有的属性是只读的痛苦海岸3全图请在声明区中放入以下声明

ConstGWL_EXSTYLE=(-20)
ConstWS_EX_TRANSPARENT=&H20&
ConstSWP_FRAMECHANGED=&H20
ConstSWP_NOMOVE=&H2
ConstSWP_NOSIZE=&H1
ConstSWP_SHOWME=SWP_FRAMECHANGEDOrSWP_NOMOVEOrSWP_NOSIZE
ConstHWND_NOTOPMOST=-2

PrivateDeclareFunctionSetWindowLongLib"user32"Alias"SetWindowLongA"(ByValhwndAsLong,ByValnIndexAsLong,ByValdwNewLongAsLong)AsLong
PrivateDeclareFunctionSetWindowPosLib"user32"(ByValhwndAsLong,ByValhWndInsertAfterAsLong,ByValxAsLong,ByValyAsLong,ByValcxAsLong,ByValcyAsLong,ByValwFlagsAsLong)AsLong

在Form_Load使用的范例如下:

PrivateSubForm_Load()
SetWindowLongMe.hwnd,GWL_EXSTYLE,WS_EX_TRANSPARENT
SetWindowPosMe.hwnd,HWND_NOTOPMOST,0&,0&,0&,0&,SWP_SHOWME
Me.Refresh
EndSub->


'SAP设置脚本
'编写:SCZ2005.04.20
'最后修改日期:2005.04.22
'必须存在目录:BW(补丁文件)和登入界面
'========================================================================
'全局变量、处理过程
'========================================================================
WScript.Echo"该脚本只能正常运行在WIN2000/XP/2003的操作系统管理员权限下,按'确定'继续"
SetobjFSO=CreateObject("Scripting.FileSystemObject")'文件系统对象
strWindir=GetWindir()'获取WINDOWS目录
strSystem=GetSystemPath()'获取System目录
strSapPath=GetSAPPath()'SAPFrontEnd目录
strSapGuiPath=strSapPath&"SAPgui"'SapGui目录
strSapBWPath=strSapPath&"BW"'BW目录
strHostPath=GetHostFilePath()'host文件所在目录
strServicesPath=GetServicesPath()'services文件所在目录

CallCopyFiles()'复制文件
CallModifyHost(strHostPath)'修改HOST文件
CallModifyServices(strServicesPath)'修改SERVICES文件
CallSetEvn(strSapGuiPath)'设置环境变量
CallSetTCPIP(strServicesPath)'修改TCPIP参数
WScript.Echo"BW设置处理完毕,请手动安装SAP系统补丁"



'========================================================================
'通过注册获取SAPFrontEnd目录
'========================================================================
FunctionGetSAPPath()
ConstHKEY_LOCAL_MACHINE=&H80000002
strComputer="."
SetobjReg=GetObject("winmgmts:{impersonationLevel=impersonate}!"&_
strComputer&"ootdefault:StdRegProv")

strKeyPath="SOFTWARESAPSAPShared"
strEntryName="SAPdestdir"
objReg.GetStringValueHKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
GetSAPPath=strValue
IfIsNull(strValue)Then
Wscript.Echo"SAP注册信息读取失败,SAP未安装或系统已损坏,安装终止"
Err.Raise(507)
Err.Clear
EndIf
EndFunction


'========================================================================
'获取WINDOWS目录
'========================================================================
FunctionGetWindir()
ConstWindowFolder=0
SetGetWindir=objFSO.GetSpecialFolder(WindowFolder)
EndFunction


'========================================================================
'获取SYSTEM目录
'========================================================================
FunctionGetSystemPath()
ConstSystemFolder=1
SetGetSystemPath=objFSO.GetSpecialFolder(SystemFolder)
EndFunction


'========================================================================
'获取HOST文件所在目录
'========================================================================
FunctionGetHostFilePath()
GetHostFilePath=strSystem&"driversetc"
EndFunction


'========================================================================
'获取Services文件所在目录
'========================================================================
FunctionGetServicesPath()
GetServicesPath=strSystem&"driversetc"
EndFunction

'========================================================================
'复制文件
'========================================================================
FunctionCopyFiles()
IfNOTobjFSO.FolderExists(strSapBWPath)Then
WScript.Echo"BW组件未安装,请先安装SAP的BW组件,再运行该脚本"
Err.Raise(507)
Err.Clear
EndIf

CallClearAttribs(strSapBWPath)

objFSO.CopyFile"登陆界面*.ini",strWindir
objFSO.CopyFile"BWgssntlm.dll",strSapGuiPath&"gssntlm.dll"
objFSO.CopyFile"BWsncgss32.dll",strSystem&"sncgss32.dll"

strBakFolder=strSapBWPath&"ak"
IFNOTobjFSO.FolderExists(strBakFolder)Then
objFSO.CreateFolder(strBakFolder)
Else
CallClearAttribs(strBakFolder)
EndIf

objFSO.CopyFilestrSapBWPath&"*.xla",strBakFolder
objFSO.CopyFile"BW*.xla",strSapBWPath
EndFunction

'========================================================================
'去除文件只读属性
'========================================================================
FunctionClearAttribs(strFolder)
CallClearFileAttrib(strFolder&"sapbex.xla")
CallClearFileAttrib(strFolder&"sapbexc.xla")
CallClearFileAttrib(strFolder&"sapbexs.xla")
CallClearFileAttrib(strFolder&"sapbex0.xla")
CallClearFileAttrib(strSystem&"sncgss32.dll")
EndFunction

'========================================================================
'去除文件只读属性
'========================================================================
FunctionClearFileAttrib(strFile)
IfobjFSO.FileExists(strFile)Then
Setf=objFSO.GetFile(strFile)
f.Attributes=0
EndIf
EndFunction

'========================================================================
'修改HOST文件
'========================================================================
FunctionModifyHost(strHostPath)
strHostFile=strHostPath&"hosts"
strHostBak=strHostPath&"hosts.bak"
ConstForReading=1,ForWriting=2,ForAppending=8
objFSO.CopyFilestrHostFile,strHostBak
SetobjFile=objFSO.OpenTextFile(strHostFile,ForReading,False)
strContents=objFile.ReadAll
objFile.Close

SetobjFile=objFSO.OpenTextFile(strHostFile,ForAppending,False)
objFile.WriteBlankLines1
compResult=Instr(strContents,"192.168.0.136")
IfcompResult=0ThenobjFile.WriteLine("192.168.0.136"&Chr(9)&"bwprd")
compResult=Instr(strContents,"192.168.0.135")
IfcompResult=0ThenobjFile.WriteLine("192.168.0.135"&Chr(9)&"bwdev")
compResult=Instr(strContents,"192.168.0.171")
IfcompResult=0ThenobjFile.WriteLine("192.168.0.171"&Chr(9)&"bwqas")
objFile.close
EndFunction

'========================================================================
'修改SERVICES文件
'========================================================================
FunctionModifyServices(strServicesPath)
strServicesFile=strServicesPath&"services"
strServicesbak=strServicesPath&"services.bak"
ConstForReading=1,ForWriting=2,ForAppending=8
objFSO.CopyFilestrServicesFile,strServicesbak
SetobjFile=objFSO.OpenTextFile(strServicesFile,ForReading,False)
strContents=objFile.ReadAll
objFile.Close

SetobjFile=objFSO.OpenTextFile(strServicesFile,ForAppending,False)
objFile.WriteBlankLines1
compResult=Instr(strContents,"sapmsP01")
IfcompResult=0ThenobjFile.WriteLine("sapmsP01"&Chr(9)&"3600/tcp")
objFile.Close
EndFunction

'========================================================================
'设置环境变量
'------------------------------------------------------------------------
FunctionSetEvn(strSapGuiPath)
strComputer="."
SetobjWMIService=GetObject("winmgmts:"&strComputer&"ootcimv2")
SetcolItems=objWMIService.ExecQuery("Select*fromWin32_Environmentwherename='SNC_LIB'")
Found=False

ForEachobjItemincolItems
IfUCase(objItem.Name)="SNC_LIB"Then
Found=True
objItem.VariableValue=strSapGuiPath&"gssntlm.dll"
objItem.Put_
EndIf
Next

If(Found=False)Then
SetoEvn=objWMIService.Get("Win32_Environment").Spawninstance_
oEvn.Name="SNC_LIB"
oEvn.VariableValue=strSapGuiPath&"gssntlm.dll"
oEvn.SystemVariable=True
oEvn.UserName="<SYSTEM>"
oEvn.Status="OK"
SetoPath=oEvn.Put_
EndIf

EndFunction

'========================================================================

'========================================================================
'设置TCP/IP参数
'------------------------------------------------------------------------
FunctionSetTCPIP(strServicesPath)
ConstHKEY_LOCAL_MACHINE=&H80000002
strComputer="."
SetobjReg=GetObject("winmgmts:{impersonationLevel=impersonate}!"&_
strComputer&"ootdefault:StdRegProv")

strKeyPath="SYSTEMCurrentControlSetServicesTcpipParameters"
strEntryName="DataBasePath"
objReg.SetStringValueHKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strServicesPath
EndFunction
'========================================================================

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号