Override Firefox by having the system type characters.

I realize that Firefox isn’t scriptable, but maybe there is a way around this limitation in my instance?

In my instance, Firefox will be the active application and the active page will contain a two field entry box, which sometimes has pre-populated text - but the cursor is always active in the top field.

Is there a way for the system to just type text as if it doesn’t care what application it is targeting?

The system would then need to the following:

  1. perform a key code that mimics “cmd” + a. For example: key code “0” using {command down}
  2. insert or type the text “g r a p h i c s” in the first field.
  3. perform a “tab” key code to advance to the next field.
    3, insert or type the text “c o d e”.
  4. perform an “enter” key code

Thanks,
Jeff

Try this.


activate application "Firefox"
tell application "System Events"
	tell process "Firefox"
		keystroke "graphics"
		keystroke tab
		keystroke "code"
		keystroke return
	end tell
end tell

Craig,
This works very well. Thanks for getting back to me on this.

-Jeff

Hi.

  1. The name of the Firefox process is “firefox-bin”.

  2. process “Firefox” doesn’t error here because it’s being ignored. Although System Events’s keystroke and key code commands are most commonly used in conjunction with GUI Scripting, they’re actually independent of it. They work even when GUI Scripting’s disabled. They’re not executed by the processes receiving the keystrokes but by System Events itself, which applies the keystrokes to whatever process is frontmost at the time, as it would if you were typing at the keyboard.

activate application "Firefox"
tell application "System Events"
	keystroke "graphics"
	keystroke tab
	keystroke "code"
	keystroke return
end tell

I hasten to add that this is the situation in Tiger and I presume it’s the same in Leopard. :slight_smile: