Jump to content
Macro Express Forums

How to copy email and subject from a craigslist ad?

Recommended Posts

Hi everyone.


I am currently looking for a new apartment on craigslist. I'm finding myself repeating the same keystrokes over, and over and over....macro time!

Allow me to provide a little bit of backround:


I have a pre-written "background info" letter that I wrote about me to send to prospective landlords.


Here is what I want my macro to be able to do

(I use FF 3.5.3)


When I am on a craigslist posting for an apartment I like, I want to be able to hit my activation keystroke, which will:

Automatically open compose a new email in a separate tab.

I want my macro to automatically arrange the following in my email


To: the email address listed on the craigslist page should appear in the To field in my new email

Subject: The subject should match the subject of the apartment ad i saw

Body: I want my pre-written form letter to appear first, followed by a copy and pasted version of the craigslist ad. So what I'm saying is, I want to permanently immortalize the ad by including it as a footer in the email I am sending as a response. This way when someone gets back to me I know exactly who they are and what place the email corresponds to.


Assuming the macro is for the most part flawless...i'd like it to finish off my sending the email it created. If there might be issues occasionally i'll have to correct, I suppose I can skip this step for now and manually click send.

Link to comment
Share on other sites

There are a lot of ways to script this with Macro Express. The technique or techniques that work for you will depend on how you have configured Firefox, the uniformity (or lack of uniformity) of the Craigslist pages you are accessing, and more.


The best way I know to built a complex macro like this is to script one step at a time. Script and test... add the next step... test... repair... add another step... change the approach you used in an earlier stage based on what you have learned subsequently... script and test some more... etc.


It's time consuming, but if you have a "macro personality," you may find it very satisfying!


Because the task involves a series of complex steps, I can guarantee that you will face timing issues. So you need a good way to infer when each task is complete. Inserting timed delays will not be reliable, unless you choose overly long wait times, say 5 or 10 or 20 seconds between steps. This is inefficient, as a step may only take a fraction of a second 90% of the time. But you need to plan for network bottlenecks and other factors when scripting tasks that take place in a browser.


There are no built in MX commands to detect when Firefox has completed tasks, so you will have to make them from scratch. One strategy is to monitor a pixel. When the pixel at (x, y) turns a certain colour, a task is done. Another strategy is to monitor the shape of the mouse pointer at coordinates (x, y). When it changes from Shape "A" to Shape "B," assume the process is complete.


If my description in the previous paragraph is hard to understand, ignore it. It is perfectly OK to use timed delays. If your script works reliably with delays, more power to you! I try to avoid them, but sometimes they are necessary.


It's easy to find and select text in Firefox via keyboard and via mouse. In general, navigating by keyboard is more reliable than navigating by mouse for scripting purposes. There are setting changes (Tools > Options) that improve keyboard access. For example, you can do something like this to copy the line of text that appears after the word "Hello!": [This is MX pseudo code]


Type Text <CONTROL> f ' Search mode

Type Text Hello!: ' Search for "Hello!"

Type Text <ENTER> ' Initiate search

Type Text <ESCAPE> ' Cancel search

Type Text <RIGHT> ' Move cursor off selection.

Type Text <SHIFT><END> ' Select to end of line

Type Text <CONTROL>c ' Copy


Some Add-ins also may make it easier to find and select text via keyboard. Personally, I almost never need to reach for the mouse with Firefox, and this fact contributes to the reliability of some of my Firefox macros.


It sounds like an interesting project!

Link to comment
Share on other sites

I was actually hired once to rewrite an old macro based product for CL and then I found out that CL sues absolutely anyone who tried to make any automation stuff for their site, users their name or anything like it so just be sure this remains a personal use thing or it can cost you a lot more than you imagine.


What you want to do is doable and Alan gives good advice. I often read posts like this and chuckle. It's like a kid showing up at a boatyard with no experience asking how to build a boat. Well what kind of boat? How much time and money do you have? Are you really good with tools or just competent? Are you concerns with rouge great whites... Wait, that was movie and they did need a bigger boat. :) So I encourage you to tinker and learn but like Alan said you should probably pick one piece first and then when confronted with specific technical issue post question here. Of if you have some disposable income you can hire someone like me to help you. Just send me a PM if interested. Just don't expect someone to write it all for you.


If you're a newb then using mouse moves and copy commands is a good tack. If you're more technically minded you might want to look into the RSS side of CL. Everything you see in CL is also on a RSS. Nice thing about RSS is that it uses XML which is a beautifully structured data format and you can save the raw XML to disk, read in to a variable and parse really easily. It sounds complicated and it probably will twist your noodle a little but there are no issues with web page loads, timing, mouse positions, clipboard events, or difficult timing issues. As an aside you can use many RSS apps to watch for and filter out listings and get automatic updates. I use it for torrents all the time and it works great.

Link to comment
Share on other sites

hi thanks for your response. i was not looking for someone to write this for me. rather i was looking for advice.

well, ive already written the thing myself, and it appears to work quite well...save for an occasional issue due to gmails weird & random ability to keep the "X" icon in the toolbar red even after the page has loaded (this therefore affects my wait for firefox macro)


if anyone is interested below is the code

Please note that I have configured my FF browser to automatically use Gmail when clicking on a link.

When I am sitting on a craigslist add that I like, I hover the mouse over the email address in the ad and push my activation key.

The macro therefore opens a new email in gmail with the to: and subject: field already filled out, thanks to craigslists mailto: link.

The macro inserts my letter, copies the add, then ends once it has highlighted the send key. i make sure everything is as is should be, add some personalized info if needed, and click send. i then simply click my browsers back button once and i am back at the end. once more and im back to CL. Its great.

Feel free to use this for personal use only.


<TEXT TYPE Action="0" Text="<CONTROL>a"/>

<TEXT TYPE Action="0" Text="<CONTROL>c"/>


<DELAY Flags="\x01" Time="2"/>

<MACRO RUN Use_ID="FALSE" Name="wait-for-FF" ID="-1" Wait="TRUE"/>

<DELAY Flags="\x01" Time="2"/>

<TEXT TYPE Action="0" Control="Roomate Form" Text="Dear Someone, this is where my pre-written letter goes. From, me."/>

<TEXT TYPE Action="0" Text="<CONTROL>v"/>

<DELAY Flags="\x11" Time=".5"/>

<TEXT TYPE Action="0" Control="Roomate Form" Text="<SHIFT><TAB>"/>

<TEXT TYPE Action="0" Control="Roomate Form" Text="<SHIFT><TAB>"/>

<TEXT TYPE Action="0" Control="Roomate Form" Text="<SHIFT><TAB>"/>

<TEXT TYPE Action="0" Control="Roomate Form" Text="<SHIFT><TAB>"/>

<TEXT TYPE Action="0" Control="Roomate Form" Text="<SHIFT><TAB>"/>

<DELAY Flags="\x01" Time="1" _ENABLED="FALSE"/>

<TEXT TYPE Action="0" Text="<TAB>" _ENABLED="FALSE"/>

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.

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.

  • Create New...