|
'$include "PcmConst.sbh"
Option Compare Text
Option Base 0
'logon on pcm with account (strname,strpass)
Function logon% (strName$ , strPass$)
Dim iSqa1 as integer
On Error goto errLb
logon = 1
iSqa1 = SQAFindObject("\;Name=frmLogin")
IF iSqa1 <> SQASuccess THEN
goto errLb
END IF
Window SetContext, "Name=frmLogin", ""
Window MoveTo, "", "Coords=247,0"
EditBox Left_Drag, "Name=txtAccount", "Coords=2,12,89,11"
InputKeys strName
EditBox Left_Drag, "Name=txtPassword", "Coords=3,14,169,7"
InputKeys strPass
PushButton Click, "Name=cmdOK"
Exit Function
errLb:
logon = 0
End Function
Function OpenPcm%(strName$ , strPass$)
dim iSqa%
dim iCall%
On Error goto errLb
OpenPcm=1
iSqa = SQAFindObject("\;Name=frmNConsole")
IF iSqa <> SQASuccess THEN
SQAShellExecute "C:\Program Files\PCmain\Console\PCMConsole.exe","",""
iSqa = SQAWaitForObject("\;Name=frmNConsole",20000)
IF iSqa <>SQASuccess THEN
SQALogMessage sqaFail, "無法開啟pcmconsole", "初始化"
Goto errLb
END IF
Window SetContext, "Name=frmNConsole", ""
Window SetPosition, "", "Coords=0,0,247,553;Status=NORMAL"
TreeView Click, "Name=TreeView1;\;ItemText=vantech->a", ""
ELSE
iSqa = SQAFindObject("\;Name=frmLogin")
IF iSqa <> SQASuccess THEN
Window SetContext, "Name=frmNConsole", ""
Window SetPosition, "", "Coords=0,0,247,553;Status=NORMAL"
Window MoveTo, "", "Coords=4,0"
TreeView Click, "Name=TreeView1;\;ItemText=vantech->a", ""
iSqa = SQAFindObject("\;Name=frmLogin")
IF iSqa <> SQASuccess THEN
Window SetContext, "Name=frmNConsole", ""
Window SetPosition, "", "Coords=0,0,247,553;Status=NORMAL"
Window MoveTo, "", "Coords=4,0"
MenuSelect "工具(T)->重新登入(G)"
end if
end if
end if
iCall = logon(strName, strPass)
if iCall =0 then Goto errLb
Exit Function
errLb:
OpenPcm=0
END FUNCTION
以上代碼我將他做成了一個lib,用來在腳本中調用,我的腳本是這樣子的
Sub Main
Dim Result As Integer
'Initially Recorded: 2005/11/15 上午 10:19:25
'Script Name: PCM06-01
result=openpcm("a","a")
if result=0 then
exit sub
end if
end sub
執行後總是失敗 |
|