1

我正在 Blueprism 中的一个小项目上工作,在 mspaint.exe 上绘制一些示意图。由于 BP 允许我们在类似的附加应用程序之间切换,我想从 mspaint 的第一个窗口切换到第二个窗口。但是由于两者都没有以任何文件名保存,因此两者的窗口文本都是“无标题 - 绘画”。

在 Blueprism 中,当为一个 exe 打开多个实例时,它们都具有相同的窗口标题,无法附加到任何打开的实例。

尝试使用完全匹配或通配符匹配以及子索引选择(其中任何一个+导航阶段中的进程名称)进行附加,所有打开的实例都响应为真。我认为,exe(mspaint)没有给OS提供实例编号,以便BP可以识别它。

在导航阶段,给出子索引,给出异常:
“多个应用程序符合条件”。

如果标题相同并且无法获得子索引,那么附加窗口的常用方法是什么?有什么方法可以获得独特的窗口句柄并使用它?

4

1 回答 1

0

您可以在附加阶段通过 PID 附加到目标应用程序。这样做非常非常棘手,并且会导致繁琐的过程,所以虽然是的,你可以做到,但我真的会重新审视你的设计,并确保你做出正确的设计选择。

在此处输入图像描述

此处的图像是我绘制的快速示意图,可以满足您的需求。您可以使用实用程序环境启动过程启动应用程序,并通常为其提供目标应用程序的路径

C:\Windows\System32\mspaint.exe

一旦启动,您就可以识别每个实例的 PID 并附加到它们。当您附加时,请确保您控制您的分离/附加决策,因为一个对象一次只能附加到一个实例,因此要么有一个单独的对象来规避这一点,要么让您的操作具有非常结构化的定义良好的标准来不断管理附加和分离在您在两个应用程序之间切换时。

做图像的 XML 代码在这里,请阅读注释。还有一个示例附加阶段(其中有一个故意的错误)。您应该能够足够轻松地单步执行其他代码。只需将其复制粘贴到您的图表区域即可。

<process name="__selection___test" type="object" runmode="Exclusive">
<stage stageid="62af981b-d1b4-425d-9beb-5dd9663ded2b" name="Attach" type="Navigate">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        -270
    </displayx>
    <displayy>
        210
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <step>
        <element id="859d3912-cecd-4456-9be2-9bd6a73f8717" />
        <action>
            <id>
                AttachApplication
            </id>
            <arguments>
                <argument>
                    <id>
                        WindowTitlesCollection
                    </id>
                    <value>
                    </value>
                </argument>
                <argument>
                    <id>
                        WindowTitle
                    </id>
                    <value>
                    </value>
                </argument>
                <argument>
                    <id>
                        ProcessName
                    </id>
                    <value>
                    </value>
                </argument>
                <argument>
                    <id>
                        ProcessID
                    </id>
                    <value>
                        put your process id here
                    </value>
                </argument>
                <argument>
                    <id>
                        Username
                    </id>
                    <value>
                    </value>
                </argument>
                <argument>
                    <id>
                        ChildIndex
                    </id>
                    <value>
                    </value>
                </argument>
            </arguments>
        </action>
    </step>
</stage>
<stage stageid="3b3fbe62-76da-4757-846e-30deaee86f35" name="get process information" type="Action">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        15
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <inputs>
        <input type="collection" name="Process Names" narrative="The names of the processes to get memory statistics for" expr="[Processes]" />
    </inputs>
    <outputs>
        <output type="collection" name="Process Statistics" narrative="A collection of process statistics including the working set and the virtual memory size" stage="Process Statistics" />
    </outputs>
    <onsuccess>
        ba3fa046-a5c9-4bd2-b15d-26946e25c160
    </onsuccess>
    <resource object="Utility - DXW - Environment" action="Read Memory Stats" />
</stage>
<stage stageid="ef10a40e-34d6-4645-9e3e-c2abfa823b38" name="Working Set" type="Data">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        135
    </displayx>
    <displayy>
        15
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <datatype>
        number
    </datatype>
    <initialvalue />
    <private />
    <alwaysinit />
</stage>
<stage stageid="731b76e6-98a8-4e7f-879e-e576aecd82d8" name="Process Statistics" type="Collection">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        135
    </displayx>
    <displayy>
        105
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <datatype>
        collection
    </datatype>
    <private />
    <alwaysinit />
    <collectioninfo>
        <field name="Process Name" type="text" />
        <field name="PID" type="number" />
        <field name="Working Set" type="number" />
        <field name="Virtual Memory" type="number" />
    </collectioninfo>
</stage>
<stage stageid="6ffde746-c61b-45cc-83fe-b86f86cdd8af" name="Processes" type="Collection">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        135
    </displayx>
    <displayy>
        60
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <datatype>
        collection
    </datatype>
    <private />
    <alwaysinit />
    <collectioninfo>
        <field name="Processes" type="text" />
    </collectioninfo>
    <initialvalue>
        <row>
            <field name="Processes" type="text" value="mspaint" />
        </row>
    </initialvalue>
</stage>
<stage stageid="ba3fa046-a5c9-4bd2-b15d-26946e25c160" name="Note3" type="Note">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        now we have the first PID
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        75
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        2c96c44a-38c9-449d-93a2-e06e5280560f
    </onsuccess>
</stage>
<stage stageid="2c96c44a-38c9-449d-93a2-e06e5280560f" name="record PSID" type="Calculation">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        120
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        aacc1662-0c73-4dc6-a49c-aae3d2bc2485
    </onsuccess>
    <calculation expression="[Process Statistics.PID]" stage="First mspaint PID" />
</stage>
<stage stageid="586fd363-1640-4ef7-ab19-1352cc9b8861" name="First mspaint PID" type="Data">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        135
    </displayx>
    <displayy>
        165
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <datatype>
        text
    </datatype>
    <initialvalue />
    <private />
    <alwaysinit />
</stage>
<stage stageid="a7f6bfb6-5cd3-4f10-8e23-82e271515278" name="get process information" type="Action">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        240
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <inputs>
        <input type="collection" name="Process Names" narrative="The names of the processes to get memory statistics for" expr="[Processes]" />
    </inputs>
    <outputs>
        <output type="collection" name="Process Statistics" narrative="A collection of process statistics including the working set and the virtual memory size" stage="Process Statistics" />
    </outputs>
    <onsuccess>
        5b9affa9-98db-4014-98b7-4a7b559b5cd1
    </onsuccess>
    <resource object="Utility - DXW - Environment" action="Read Memory Stats" />
</stage>
<stage stageid="5b9affa9-98db-4014-98b7-4a7b559b5cd1" name="Note3" type="Note">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        now we have the second PID so we loop to find it
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        300
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        b6c496da-d5b7-4ebb-9a99-98c5fc3f29c2
    </onsuccess>
</stage>
<stage stageid="1109b7bc-dbbe-4c1c-9af1-5da02bf2a229" name="record PSID" type="Calculation">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        480
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        2ca14198-33a5-43db-b9ad-6970797c2b36
    </onsuccess>
    <calculation expression="[Process Statistics.PID]" stage="First mspaint PID" />
</stage>
<stage stageid="aacc1662-0c73-4dc6-a49c-aae3d2bc2485" name="Launch Application" type="Action">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        180
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <inputs>
        <input type="text" name="Application" narrative="The application or short cut to start" expr="&quot;C:\Windows\System32\mspaint.exe&quot;" />
        <input type="text" name="Arguments" narrative="Any arguments needed for the app" expr="" />
    </inputs>
    <onsuccess>
        a7f6bfb6-5cd3-4f10-8e23-82e271515278
    </onsuccess>
    <resource object="Utility - DXW - Environment" action="Start Process" />
</stage>
<stage stageid="b6c496da-d5b7-4ebb-9a99-98c5fc3f29c2" name="loop PIDs found" type="LoopStart">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        360
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        f00d91ee-116d-44e1-8d42-a7cb23c9983e
    </onsuccess>
    <groupid>
        f4c4a30f-44b1-4c6a-a632-a1b46719e8d1
    </groupid>
    <looptype>
        ForEach
    </looptype>
    <loopdata>
        Process Statistics
    </loopdata>
</stage>
<stage stageid="2ca14198-33a5-43db-b9ad-6970797c2b36" name="loop PIDs found" type="LoopEnd">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
        
        
        
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        540
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        cb91afa2-8a34-4fda-82a6-d95335ce534e
    </onsuccess>
    <groupid>
        f4c4a30f-44b1-4c6a-a632-a1b46719e8d1
    </groupid>
</stage>
<stage stageid="ec0a4f36-ac09-4959-82c9-1bedadb63258" name="Second msPaint PID" type="Data">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        180
    </displayx>
    <displayy>
        480
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <datatype>
        text
    </datatype>
    <initialvalue />
    <private />
    <alwaysinit />
</stage>
<stage stageid="cb91afa2-8a34-4fda-82a6-d95335ce534e" name="Note4" type="Note">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        now perform your attach functions. remember an object can only attach to one thing at a time so either make a new object to have one for each instance or make one object and have strict control over your attach and detach functions
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        600
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
</stage>
<stage stageid="f00d91ee-116d-44e1-8d42-a7cb23c9983e" name="Is it the same PID?" type="Decision">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        420
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <decision expression="[Process Statistics.PID]=[First mspaint PID]" />
    <ontrue>
        cafab8cb-4d5e-48d9-872f-07f3a6b4cd65
    </ontrue>
    <onfalse>
        1109b7bc-dbbe-4c1c-9af1-5da02bf2a229
    </onfalse>
</stage>
<stage stageid="cafab8cb-4d5e-48d9-872f-07f3a6b4cd65" name="Anchor1" type="Anchor">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
    </narrative>
    <displayx>
        90
    </displayx>
    <displayy>
        420
    </displayy>
    <displaywidth>
        10
    </displaywidth>
    <displayheight>
        10
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        9eabbb67-c740-4376-b9e9-4ec0db2ef909
    </onsuccess>
</stage>
<stage stageid="9eabbb67-c740-4376-b9e9-4ec0db2ef909" name="Anchor2" type="Anchor">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
    </narrative>
    <displayx>
        90
    </displayx>
    <displayy>
        540
    </displayy>
    <displaywidth>
        10
    </displaywidth>
    <displayheight>
        10
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <onsuccess>
        2ca14198-33a5-43db-b9ad-6970797c2b36
    </onsuccess>
</stage>
<stage stageid="ee281457-bd05-497a-b11d-01aff60efc6b" name="Launch Application" type="Action">
    <subsheetid>
        6baeaef9-1401-45ea-8782-baec374c4b4c
    </subsheetid>
    <loginhibit />
    <narrative>
        Dexter was here 21/03/2020 don't delete me maybe i'll work with you someday we can laugh about this description.
    </narrative>
    <displayx>
        15
    </displayx>
    <displayy>
        -45
    </displayy>
    <displaywidth>
        60
    </displaywidth>
    <displayheight>
        30
    </displayheight>
    <font family="Segoe UI" size="10" style="Regular" color="000000" />
    <inputs>
        <input type="text" name="Application" narrative="The application or short cut to start" expr="&quot;C:\Windows\System32\mspaint.exe&quot;" />
        <input type="text" name="Arguments" narrative="Any arguments needed for the app" expr="" />
    </inputs>
    <onsuccess>
        3b3fbe62-76da-4757-846e-30deaee86f35
    </onsuccess>
    <resource object="Utility - DXW - Environment" action="Start Process" />
</stage>
</process>
于 2020-03-21T01:00:53.527 回答