Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
#include "_ClickSysTray.au3"
#include <IE.au3>
;---------part 1-------------------------------
dim $process1 = "Mobile Partner.exe"
dim $title1 = "Mobile Partner"
dim $linkbtntxt_wait_link = "连接"
dim $linkbtntxt_link_ok = "断开"
dim $p1win2_title = "网络连接提示"
;wait for 60 seconds at most
TrayTip("", "等待拨号连接程序", 5, 1)
$w1wh = WinWait($title1, $linkbtntxt_wait_link, 60)
If NOT ProcessExists($process1) Then
MsgBox(0, "请检查", "【3G拨号程序" & $title1 & "】还没启动么?请先启动再运行该脚本。")
Exit
EndIf
if $w1wh <> 0 Then
$wintext = WinGetText($title1)
;do nothing when is online
If StringInStr($wintext,$linkbtntxt_wait_link)>0 Then
;等拨号窗口稳定点
TrayTip("", "3G网络拨号准备", 5, 1)
Sleep(5000);5 secs
;active window, make sure focuse it
WinActivate($title1, $linkbtntxt_wait_link)
Sleep(1000)
;open menu: File
Send("!f");alt + f
Sleep(200)
;chose menu:link
Send("c")
;wait linking small window
;wait until it dispear
Do
Sleep(2500)
TrayTip("", "3G网络已拨号,等待反馈……", 5, 1)
Until not WinExists($p1win2_title)
;While WinExists($p1win2_title)
; TrayTip("", "3G网络已拨号,等待反馈……", 5, 1)
; Sleep(1000)
;WEnd
;等窗口更新状态
Sleep(1000)
;MINIMIZE the window
TrayTip("", "连接成功后最小化窗口", 5, 1)
Sleep(1000)
;WinSetState($title1, $linkbtntxt_link_ok, @SW_MINIMIZE);多点参数不可靠
WinSetState($title1, "", @SW_MINIMIZE)
Else
TrayTip("", "拨号已经连接", 5, 1)
WinSetState($title1, "", @SW_MINIMIZE)
Sleep(1000)
EndIf
EndIf
;---------part 2-------------------------------
dim $process2 = "TCCWatcher.exe"
dim $title2 = "移动警务安全接入VPN客户端"
If NOT ProcessExists($process2) Then
;MsgBox(0, "请检查", "【" & $title2 & "】还没启动么?请先启动再运行该脚本。")
;Exit
TrayTip("请检查", "【" & $title2 & "】还没启动么?请先启动再运行该脚本。", 5, 1)
Sleep(3000)
Else
;active window, make sure focuse it
TrayTip("", "自动接入VPN", 5, 1)
WinActivate($title2)
Sleep(1000)
Send("111111");pwd
Sleep(200)
Send("{ENTER}");do link
Sleep(8000);拨号后多等一会儿
dim $logintimeslitmit=5
While $logintimeslitmit>0
TrayTip("", "已经拨号VPN,等待反馈……", 5, 1)
Sleep(3500)
$wintext = WinGetText($title2,"")
;if faild to login ,retry it
ConsoleWrite($wintext & @CRLF )
If StringInStr($wintext,"失败")>0 Then
Send("{ENTER}");do link
TrayTip("", "拨号VPN失败,再试试……", 5, 1)
Sleep(2000)
$logintimeslitmit=$logintimeslitmit-1
if $logintimeslitmit<1 Then
;MsgBox(0, "请检查", $title2 & "已经连续尝试几次了,还是连不上。")
;Exit
TrayTip("请检查", $title2 & "已经连续尝试几次了,还是连不上。", 5, 1)
$logintimeslitmit=$logintimeslitmit-1
ExitLoop
EndIf
ElseIf StringInStr($wintext,"成功")>0 OR WinActive($title2)==0 or WinGetState($title2)==5 or StringInStr($wintext,"稍后")<1 Then;
TrayTip("", "拨号VPN完成。", 5, 1)
Sleep(1200)
$logintimeslitmit=$logintimeslitmit-1
ExitLoop
;MsgBox(0, "恭喜", "拨号、连接VPN都OK啦!")
;Exit
EndIf
WEnd
EndIf
Sleep(8000);等久点安全点
;---------part 3-------------------------------
TrayTip("", "移动应用管理与代理,启动安全服务。", 5, 1)
Sleep(200);等太久,夜长梦多
_ClickSysTrayIcon("移动应用管理与代理","Right")
Sleep(200)
Send("r")
Sleep(6000);等久点安全点
;---------part 4-------------------------------
TrayTip("", "打开网页", 5, 1)
$oIE = _IECreate ("http://www.gd",0,1,0)
Sleep(6000)
$title4="输入口令"
$txtwin4= "请输入设备的用户口令"
TrayTip("", "等待“输入设备的用户口令”的窗口", 5, 1)
$w4wh = WinWait($title4, $txtwin4, 20)
if $w4wh <> 0 Then
TrayTip("", "自动输入设备的用户口令", 5, 1)
;active window, make sure focuse it
WinActivate($title4, $txtwin4)
Sleep(200)
Send("111111");pwd
Sleep(200)
Send("{ENTER}");do link
Sleep(1200)
Else
TrayTip("", "等待“输入设备的用户口令”的窗口,超时退出。", 5, 1)
Sleep(2000)
EndIf
;确保最小化
WinSetState($title1, "", @SW_MINIMIZE)