Hi @guxianbang,
Take a look at this sample macro. Looks like it is exactly what you are looking for.
For more information, see the wiki Searching the Forum for Answers section.