Start a program within a macro

Questions and answers about 3Dconnexion devices on Windows.

Moderator: Moderators

Post Reply
mbartlett21
Posts: 6
Joined: Sun Feb 13, 2022 6:10 pm

Start a program within a macro

Post by mbartlett21 »

I currently have a macro to help fill out revision tables (partially hand-crafted), and I would like it to run another program that I have that types the date. I have a program located in %userprofile%/.../type-date.exe that I would like to call. Is there any way I can do this?

Code: Select all

    <MacroEntry>
      <ID>For Manufacture</ID>
      <Sequence>
        <!-- 1[tab] -->
        <KeyPress>1E</KeyPress>
        <KeyRelease>1E</KeyRelease>
        <KeyPress>2B</KeyPress>
        <KeyRelease>2B</KeyRelease>
        <Pause>100</Pause>
        <!-- ISSUED -->
        <KeyPress>E1</KeyPress>
        <KeyPress>C</KeyPress>
        <KeyRelease>C</KeyRelease>
        <KeyPress>16</KeyPress>
        <KeyRelease>16</KeyRelease>
        <KeyPress>16</KeyPress>
        <KeyRelease>16</KeyRelease>
        <KeyPress>18</KeyPress>
        <KeyRelease>18</KeyRelease>
        <KeyPress>8</KeyPress>
        <KeyRelease>8</KeyRelease>
        <KeyPress>7</KeyPress>
        <KeyRelease>7</KeyRelease>
        <Pause>50</Pause>
        <!--  FOR -->
        <KeyPress>2C</KeyPress>
        <KeyRelease>2C</KeyRelease>
        <KeyPress>9</KeyPress>
        <KeyRelease>9</KeyRelease>
        <KeyPress>12</KeyPress>
        <KeyRelease>12</KeyRelease>
        <KeyPress>15</KeyPress>
        <KeyRelease>15</KeyRelease>
        <Pause>50</Pause>
        <!--  MANUFACTURE -->
        <KeyPress>2C</KeyPress>
        <KeyRelease>2C</KeyRelease>
        <KeyPress>10</KeyPress>
        <KeyRelease>10</KeyRelease>
        <KeyPress>4</KeyPress>
        <KeyRelease>4</KeyRelease>
        <KeyPress>11</KeyPress>
        <KeyRelease>11</KeyRelease>
        <KeyPress>18</KeyPress>
        <KeyRelease>18</KeyRelease>
        <KeyPress>9</KeyPress>
        <KeyRelease>9</KeyRelease>
        <KeyPress>4</KeyPress>
        <KeyRelease>4</KeyRelease>
        <KeyPress>6</KeyPress>
        <KeyRelease>6</KeyRelease>
        <KeyPress>17</KeyPress>
        <KeyRelease>17</KeyRelease>
        <KeyPress>18</KeyPress>
        <KeyRelease>18</KeyRelease>
        <KeyPress>15</KeyPress>
        <KeyRelease>15</KeyRelease>
        <KeyPress>8</KeyPress>
        <KeyRelease>8</KeyRelease>
        <KeyRelease>E1</KeyRelease>
        <!-- [tab] -->
        <KeyPress>2B</KeyPress>
        <KeyRelease>2B</KeyRelease>
        <Pause>100</Pause>
        <!-- [Ctrl[V]] -->
        <!-- Insert the date. I would like to say something like RunProgram(type-date.exe) or something -->
        <KeyPress>E0</KeyPress>
        <KeyPress>19</KeyPress>
        <KeyRelease>19</KeyRelease>
        <KeyRelease>E0</KeyRelease>
        <!-- [tab] -->
        <KeyPress>2B</KeyPress>
        <KeyRelease>2B</KeyRelease>
        <Pause>100</Pause>
        <!-- *** -->
        <KeyPress>E1</KeyPress>
        <KeyPress>10</KeyPress>
        <KeyRelease>10</KeyRelease>
        <KeyPress>10</KeyPress>
        <KeyRelease>10</KeyRelease>
        <KeyPress>10</KeyPress>
        <KeyRelease>10</KeyRelease>
        <KeyRelease>E1</KeyRelease>
        <!-- [enter] -->
        <KeyPress>28</KeyPress>
        <KeyRelease>28</KeyRelease>
        <Pause>50</Pause>
        <!-- [esc] -->
        <KeyPress>29</KeyPress>
        <KeyRelease>29</KeyRelease>
      </Sequence>
      <!--
        1E = 1
        2A = bksp
        2B = tab
        E1 = shift
        c = I
        16 = S
      -->
    </MacroEntry>
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Start a program within a macro

Post by jwick »

That's an impressive macro!
There may be new functionality in an upcoming driver which may be able to do this. I'd have to look into it.

Currently I suggest one of four approaches, in order of difficulty:
1) Insert such a long delay in the macro, that you can press a different button that runs your program during the Pause. Or assign three buttons 1) start of macro , 2) run program 3) end of macro.
2) If this is for Excel, write a macro using its macro mechanism, and execute that from a kb shortcut assigned to a 3D mouse key. This is likely to be the most reliable.
3) Write an independent script (VB, or whatever) that does what you want and assign that to a key.
4) Write a driver extension (e.g., in C) which the driver will call directly when you press the button. In that code you can do whatever you want. This isn't much different from #2.
Post Reply