Jump to content
Macro Express Forums

Use clipboard to run macro


Recommended Posts

I am trying to build some logic into my macro that would select a string of text, copy it to the clipboard, and then run a specific macro based on what is stored in the clipboard (or a variable that was set to the clipboard content).

 

So far, I have created a bunch of code like this:

If Clipboard contains "brown"

Variable Set String %macroname% to "brown"

End If

Macro Run: %macroname%

 

This definitely works, but as I have a few thousand macros that could potentially be run, I am hesitant to continue doing it this way. Any ideas on an alternate approach to accomplish the same thing?

Link to comment
Share on other sites

If there is consistency in the clipboard text, delete everything that is not a macro name. For example, let's say the clipboard text always is something like this...

" 0123456789Colour = Brown "

or this...

" 0987654321Colour = Red "

or this...

" 3.14159265Colour = Turquoise "

Variable Set String %Clip% from the Clipboard

// A series of statements to parse out unwanted text...
// e.g., delete leading/trailing white space, the first 10 characters, and the phrase "Colour = "

Variable Modify String %Clip%: Trim
Variable Modify String %Clip%: Delete a substring starting at 1 and 10 characters long
Variable Modify String: Replace "Colour = " in %Clip% with ""

Macro Run: %Clip%

Link to comment
Share on other sites

20 hours ago, Cory said:

You might want to create a CSV list of your keyword matches in one column and macro name in another and and repeat with it each time using ASCII File Process. 

This method worked perfectly! It took me a while to get the hang of using it and truth be told, I am not even that well versed in using arrays either, but I was amazed at how a few lines of code combined with a tab delimited document made this whole thing really easy. I was also worried about the ASCII file process taking too long to and slowing down the macro, but that wasn't an issue either.

Thanks Cory and others for valuable suggestions. I can see myself using this method for other applications as well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...