Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to automate the selection of a value from a drop-down box in Mozilla using an applescript. What I want it to do is to tab to the drop-down box and enter down twice to select the third item in the drop-down.

Here is what I have so far:

tell application "Firefox"
    tell application "System Events" to keystroke tab
    tell application "System Events" to keystroke down
    tell application "System Events" to keystroke down
end tell

But, as far as I can tell, when I run the script nothing happens.

What do I need to do to make this script work?

EDIT: I have also tried entering the key code 125 for down in case the keystroke command was wrong.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Try this

tell application "Firefox"
    activate
    tell application "System Events"
        keystroke tab
        keystroke (key code 125)
        keystroke (key code 125)
        keystroke (key code 125)        
    end tell
end tell

You might not need to activate Firefox if it's the current active app. Them you just need :

tell application "System Events"
    keystroke tab
    keystroke (key code 125)
    keystroke (key code 125)
    keystroke (key code 125)        
end tell
share|improve this answer
    
I think you might have misunderstood. I want to navigate within the page. There are a number of drop-down menus on the page. I want to set up something that will let me tab to one of these menus and select the third value on the list. I will then repeat the script for the number of drop-down menus. The issue is a large number of drop-down menus that I need to select the third value from each of. I don't want to get to the address bar. –  Dennis Jan 31 '13 at 6:34
    
I modified your suggestion, though, and found something that works. I just replaced the keystroke "l" line with my original tab line. –  Dennis Jan 31 '13 at 6:39
    
ok I edited my answer to match what you were looking for. –  Matthieu Riegler Jan 31 '13 at 10:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.