[quote][size=2][url=forum.php?mod=redirect&goto=findpost&pid=2739&ptid=1247][color=#999999]我要当反贼 发表于 2023-04-10 16:48[/color][/url][/size]
可以换一种VBS脚本吗[/quote]
可以的,这里提供一种实现与您要求相同的VBS脚本:
Sub OnClick(ByVal Item)
If Item.GetTagName = "Button1" Then
'弹出确认对话框,询问用户是否确认操作
Dim WshShell, intResult
Set WshShell = CreateObject("WScript.Shell")
intResult = WshShell.Popup("是否确认此操作?", 0, "确认操作", vbYesNo + vbQuestion)
If intResult = vbYes Then '如果用户点击了“是”
'将二进制变量tag1置1,并显示提示信息
Item.Tags("tag1").WriteValue(CBool(1))
MsgBox "操作已确认!", vbInformation + vbOKOnly, "提示"
End If
ElseIf Item.GetTagName = "Button2" Then '按钮的名称为Button2
'弹出确认对话框,询问用户是否确认操作
Dim WshShell, intResult
Set WshShell = CreateObject("WScript.Shell")
intResult = WshShell.Popup("是否确认此操作?", 0, "确认操作", vbYesNo + vbQuestion)
If intResult = vbYes Then '如果用户点击了“是”
'将二进制变量tag1置0,并显示提示信息
Item.Tags("tag1").WriteValue(CBool(0))
MsgBox "操作已确认!", vbInformation + vbOKOnly, "提示"
End If
End If
End Sub
请将脚本代码复制到WINCC的VBS脚本编辑器中,并保存该文件。然后,在屏幕设计器中选中按钮控件,右键单击并选择“属性”,在“事件”标签页中,将“OnClick”事件指定为该脚本的名称。这样即可实现您的要求。 |