Macro to rerun a macro

Discussion in 'SolidWorks' started by Wayne Tiffany, Sep 13, 2005.

  1. You know what I would like to have (among other things, of course) is a way
    to have a macro button on my toolbar that when I click it, it runs whatever
    the last macro was that I ran, not including itself. Has anyone looked into
    that? The reason is that I may not have a button or hotkey tied to a
    particular macro, and click-finding it gets old. So, thus my idea. Any
    thoughts out there?

    WT
     
    Wayne Tiffany, Sep 13, 2005
    #1
  2. Wayne Tiffany

    That70sTick Guest

    You could modify each of your macros so that they leave a trail. Each
    macro closes by writing its name into a semipermanent location, either
    a registry location or in a temporary text file.

    Then your "rerun" macro can read the name of the last run macro and run
    it again.

    I have tools for manipulating registry info.
    <http://www.esoxrepublic.com/devtools/>
     
    That70sTick, Sep 13, 2005
    #2
  3. Interesting thought. I downloaded the tools and will investigate when I
    have time - maybe November.....

    WT
     
    Wayne Tiffany, Sep 13, 2005
    #3
  4. Interesting little tidbit I found while waiting for a car body to load.

    In the registry at
    HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\swp
    one will find the name of the last SolidWorks macro run. A couple
    interesting things. To get to the name of the last one run, you have to
    first look at the Value name:MRUList and the data value in there is a string
    of 8 letters that identify the order of the most recent values. So you read
    that value (in this case "ghbfceda") to find that the first in that list
    (meaning the last one chronologically run) is, in this example, g. Then go
    to Value name:g to get the Value data string that holds the name of the
    macro - in this case "C:\Program Files\SolidWorks2005\Macros\scale1.swp".
    Whew!

    The other interesting thing I found is that SW doesn't write a value there
    if the macro is run from a hotkey or a toolbar button - it seems to appear
    only when you "run" one. This is actually very good because I was concerned
    that my macro would try to run itself the next time - not a good thing -
    hardly useful.

    So, if anyone with the inclination has the time (I don't) to work on this,
    here is a head start.

    WT
     
    Wayne Tiffany, Sep 18, 2005
    #4
  5. Wayne Tiffany

    That70sTick Guest

    Interesting information. Where did you come up with this?

    One of the reasons I got hooked on SW API programming is that I found
    it was a good way to get to know SW from the deep inside. This is
    deeper than I've been yet!
     
    That70sTick, Sep 19, 2005
    #5
  6. Sorry about the delay - I was on a server that wasn't responding and I was
    having to do it the hard way (Google) amid working 14 hours per day....

    Anyway, as I said, I was waiting for a car body to load and so spent a bit
    of time sleuthing under the hood. I agree with you on the fact that if you
    do a bit of programming you get a better feel for how SW operates below the
    surface.

    What I did was run a macro and then go look in the registry for that name,
    with the hope that I would find it in a list somewhere. And I did.
    However, it appeared that the list wasn't just a FIFO type of list, and
    that's when I tried a few things and then discovered that the entry goes
    into a placeholder, with the index key being the one to keep track of it.

    Maybe some day I will have time to work on it, but I figured that my piece
    of info might just be that catalyst that sparked enough intrigue in someone
    else (hint, hint) that they might pick up the ball since I don't have time.
    :)

    WT
     
    Wayne Tiffany, Sep 27, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.