Quantitative electroencephalography from freely-moving rats is commonly used as a translational tool for predicting drug-effects in humans. We hypothesized that drug-effects may be expressed differently depending on whether the rat is in active locomotion or sitting still during recording sessions, and proposed automatic state-detection as a viable tool for estimating drug-effects free of hypo-/hyperlocomotion induced effects. We aimed at developing a fully automatic and validated method for detecting two behavioral states: active and inactive, in one-second intervals and to use the method for evaluating ketamine, DOI, d-cycloserine, d-amphetamine, and diazepam effects specifically within each state. The developed state-detector attained high precision with more than 90% of the detected time correctly classified, and multiple differences between the two detected states were discovered. Ketamine-induced delta activity was found specifically related to locomotion. Ketamine and DOI suppressed theta and beta oscillations exclusively during inactivity. Characteristic gamma and high-frequency oscillations (HFO) enhancements of the NMDAR and 5HT2A modulators, speculated associated with locomotion, were profound and often largest during the inactive state. State-specific analyses, theoretically eliminating biases from altered occurrence of locomotion, revealed only few effects of d-amphetamine and diazepam. Overall, drug-effects were most abundant in the inactive state. In conclusion, this new validated and automatic locomotion state-detection method enables fast and reliable state-specific analysis facilitating discovery of state-dependent drug-effects and control for altered occurrence of locomotion. This may ultimately lead to better cross-species translation of electrophysiological effects of pharmacological modulations. This article is protected by copyright. All rights reserved.