automator /apple script to click speech input (microphone ) on google.

-can anyone help me in writing some automator /apple script to click speech input (microphone ) on google.com
i d like to this using javascript and get element by id.
tell application “Google Chrome”
tell window 1
tell tab 1
execute javascript “?? get element by id??”
end tell
end tell
end tell

I wrote an Alfred Workflow for that. You can check it out here:

http://www.alfredforum.com/topic/2452-voice-search/?hl=%2Bvoice+%2Bsearch

Here is the code:


property google : "https://www.google.com/"
property myDelay : 0.5
property secondsForSpeech : 15

activate application "Google Chrome"
tell application "Google Chrome"
	if not (exists window 1) then reopen
	tell window 1
		if URL of active tab starts with google then
			set URL of active tab to google
		else
			make new tab with properties {URL:google}
		end if
		my chromePageLoad()
		tell active tab to execute javascript "document.getElementsByClassName('gsst_a')[0].click()"
	end tell
end tell
waitForSearch()

on chromePageLoad()
	tell application "Google Chrome"
		repeat until not loading of active tab of front window
			delay myDelay
		end repeat
	end tell
end chromePageLoad


on waitForSearch()
	set startTime to current date
	try
		tell application "Google Chrome" to tell active tab of window 1
			repeat
				set searchTerm to execute javascript "document.getElementById('gbqfq').value;"
				if (searchTerm = missing value) or (current date) - startTime ≥ secondsForSpeech then
					error
				else if searchTerm ≠ "" and URL ≠ google then
					exit repeat
				end if
				delay myDelay
			end repeat
			return searchTerm
		end tell
	end try
end waitForSearch

tahnk you very much very fast !!!
best regards!
i don t use alfred i assigned it to better touch tool!