on 08-25-2011 6:52 PM
Dear, I have a question if it is possible to solve?
I need the script to recognize that there is a dialog box and perform the actions at the time: if, see below:
If IsObject(vbApplicationModal) Then
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
Else
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
End If
I tried the following types, but without success:
If DialogBox = vbApplicationModal Then
If vbApplicationModal Then
If vbApplicationModal = show Then
If vbApplicationModal = appear Then
If dlgAnswer = vbApplicationModal Then
If dlgAnswer Then
If dlgAnswer = DialogBox Then
If 0 Then
If 1 Then
If DialogBox Then
If showMessageBox Then
If box Then
I await your help. Thank you very much.
Hi Jeronimo
that's possible ...
if session.findbyid("wnd[1]").text = "Information / Error" Then ' <- here goes the text of the Dialogbox !
session.findbyid("wnd[1]").sendvKey 0
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
else
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
end if
in other words ...
you only can check if there is a Dialogbox (weither it's modal or unmodal)
But you can check for it's caption.
Perhaps you have to check for an Error on runtime via on error resume next
and then to close the Dialog...
greetings
Thomas Br
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Thomas, got the first part of "if" when the dialog box appears.
But when there is the Script dialog box does not recognize the "Else".
-
-
If session.findbyid("wnd[1]/usr/txt[1]").text = "Fornecedor 10025818 será Inativado,devido ao" Then
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
Else
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
End If
-
-
I'm sending you the whole code for you to have an idea. Greetings, Thank you.
'****************************************************************************
' File: YSLOFLOCAL.VBS (WSH sample in VBScript)
' Author: (c) Jerônimo Barbosa dos Santos
' Showing a simple dialog box
'****************************************************************************
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
Set fso = CreateObject("Scripting.FileSystemObject")
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
Msgbox("INÍCIO DO PROCESSO")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFile = fso.GetFile("U:Documents and SettingsMeus documentosScriptsEXC_FORN_FAMILIA.TXT")
Const ForReading = 1, ForWriting = 2, ForAppendig = 8
Set f=fso.OpenTextFile("U:Documents and SettingsMeus documentosScriptsEXC_FORN_FAMILIA.TXT", ForReading, True)
Dim z
z = 1
Do While f.AtEndOfStream <> True And z<=5000
strRetorno = f.ReadLine
z=z+1
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/N"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "YSLOFLOCAL"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxt[0]").text = strRetorno
session.findById("wnd[0]/usr/ctxt[1]").text = "0300"
session.findById("wnd[0]/usr/ctxt[2]").text = "10025818"
session.findById("wnd[0]/usr/ctxt[2]").setFocus
session.findById("wnd[0]/usr/ctxt[2]").caretPosition = 8
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").setCurrentCell -1,""
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "NOME_FORN"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "LIFNR"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "STATUS"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "YY_TIPO_TEXTO"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "YY_BLOQUEIO"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "STCD1"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "BLOQ_CORP"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "CREA"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "PETRONECT"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "CRCC"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "DESC_TEXTO"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "YY_DATA_BLOQ"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "CITY1"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "REGIO"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "YY_TIPO_CONTR"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectColumn "YY_APROVADOR"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "DELLINHA"
If session.findbyid("wnd[1]/usr/txt[1]").text = "Fornecedor 10025818 será Inativado,devido ao" Then
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
Else
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
End If
Loop
Msgbox("FIM DO PROCESSO")
f.close
All right, lets try it so:
snip
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "DELLINHA"
If session.findbyid("wnd[1]/usr/txt[1]").text = "Fornecedor 10025818 será Inativado,devido ao" Then
session.findById("wnd[1]/tbar[0]/btn[0]").press
End if
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
session.findById("wnd[1]/usr/btn[0]").press
Loop
Msgbox("FIM DO PROCESSO")
f.close
/snap
should do the "trick" ...
Hello friend, a friend of ours in the area of Information Technology and Communication, presented the following solution for the "if." I also hope to serve others. Thank you very much for your help!
If DialogBox = vbApplicationModal Then
If Not session.findById("wnd[1]/tbar[0]/btn[0]", False) Is Nothing Then
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
If Not session.findById("wnd[1]/usr/btn[0]", False) Is Nothing Then
session.findById("wnd[1]/usr/btn[0]").press
End If
Else
session.findById("wnd[0]/usr/cntlTREE_CONTAINER_0200/shellcont/shell").pressToolbarButton "SAVE"
If Not session.findById("wnd[1]/usr/btn[0]", False) Is Nothing Then
session.findById("wnd[1]/usr/btn[0]").press
End If
End If
End If
End If
Edited by: Jeronimo Santos on Aug 31, 2011 10:04 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.