A simple and sensitive method for the determination of amphetamine, methamphetamine and their methylenedioxy derivatives in urine and hair samples was developed by coupling automated in-tube solid phase microextraction (SPME) to high performance liquid chromatography-electrospray ionization mass spectrometry (HPLC-ES-MS). To achieve optimum performance, the conditions for both the in-tube SPME and the ES-MS detection were investigated. ES-MS detection conditions were studied by flow injection analysis (FIA) with direct liquid injection. In-tube SPME conditions were optimized by selecting the appropriate extraction parameters, including capillary stationary phases and sample pH. For the compounds studied, a custom-made polypyrrole (PPY) coated capillary showed superior extraction efficiency as compared to commercial capillaries. Therefore, the PPY coated capillary was selected for in-tube SPME in this study. The calibration curves of stimulants were linear in the range from 0.1 to 100 ng ml(-1) with detection limits (S/N=3) of 8-56 ng l(-1). This method was successfully applied to the analysis of the stimulants in spiked human urine and hair samples.