哪种脚本更适合PTC Integrity应用程序的自动化 [英] Which script is better for automation of PTC Integrity application

查看:203
本文介绍了哪种脚本更适合PTC Integrity应用程序的自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个脚本,该脚本将打开Windows应用程序并使用该应用程序执行某些任务.我在下面列出了要自动化的活动:

I want to create one script that will open the windows application and use that application to perform some task. I have listed out the activity that I want to automate below:

应用程序就是PTC的完整性.它与其中包含许多具有唯一ID的文件的数据库服务器链接.因此,我需要使用ID来打开文档并将其导出.

Application is PTC integrity. It is linked with database server that has lot of files in it which have unique ID. So I need to use ID to open the document and export it.

步骤:

  1. 打开应用程序.
  2. 使用ID打开文档.
  3. 将文档导出为某些特定格式.

我想知道使用哪个脚本来自动化此过程,即,给我ID数组,该脚本将打开应用程序,然后使用ID打开文档并导出它们,直到导出所有ID.使用Excel VBA可以做到.

I want to know which scripting to be used to automate this process, i.e., I give array of IDs , the script will open the application and then open the document using IDs and export them till all the IDs are exported. Using Excel VBA can it be done.

推荐答案

是的,您可以在VBA中执行此操作. 您的VBA可以通过使用PTC Integrity命令行界面的Shell命令来调用批处理文件.

Yes you can do this in VBA. Your VBA can call a batch file via the Shell command that uses PTC Integrity Command Line Interface.

要导出文档,可以使用"im exportissues" CLI命令.

To export a document you can use the 'im exportissues' CLI command.

要同步调用批处理文件,可以使用下面的ShellandWait函数或查看相关的StackOverflow问题.

To call a batch file synchronously you can use the ShellandWait function below or see related StackOverflow question.

    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess _
    As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle _
    As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

    Sub ShellAndWait(ByVal program_name As String, _
                             Optional ByVal window_style As VbAppWinStyle = vbNormalFocus, _


                Optional ByVal max_wait_seconds As Long = 0)
'http://www.vbforums.com/showthread.php?t=505172
' Example:
' Private Sub Form_Load()
'  Me.Show
'  ShellAndWait "Notepad.exe", , 3
'  Me.Caption = "done"
' End Sub
Dim lngProcessId As Long
Dim lngProcessHandle As Long
Dim datStartTime As Date
Const WAIT_TIMEOUT = &H102
Const SYNCHRONIZE As Long = &H100000
Const INFINITE As Long = &HFFFFFFFF

    ' Start the program.
    On Error GoTo ShellError
    lngProcessId = Shell(program_name, window_style)
    On Error GoTo 0

    DoEvents

    ' Wait for the program to finish.
    ' Get the process handle.
    lngProcessHandle = OpenProcess(SYNCHRONIZE, 0, lngProcessId)
    If lngProcessHandle <> 0 Then
        datStartTime = Now
        Do
          If WaitForSingleObject(lngProcessHandle, 250) <> WAIT_TIMEOUT Then
            Exit Do
          End If
          DoEvents
          If max_wait_seconds > 0 Then
            If DateDiff("s", datStartTime, Now) > max_wait_seconds Then Exit Do
          End If
        Loop
        CloseHandle lngProcessHandle
    End If
    Exit Sub

ShellError:
End Sub

这篇关于哪种脚本更适合PTC Integrity应用程序的自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆