Macro to rerun a macro

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

Reply to
Wayne Tiffany
Loading thread data ...

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.

Reply to
That70sTick

Interesting thought. I downloaded the tools and will investigate when I have time - maybe November.....

WT

Reply to
Wayne Tiffany

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

Reply to
Wayne Tiffany

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!

Reply to
That70sTick

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

Reply to
Wayne Tiffany

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.