发送点击进入谷歌的chrome输入html标签

Ton*_*Nam 5 html5 automation google-chrome

Google Chrome在其浏览器中具有非常好的语音识别控制功能.例如,如果我放置此html标记:

<input  id="speech" type="text" speech="speech" x-webkit-speech="x-webkit-speech" onspeechchange="processspeech();" onwebkitspeechchange="processspeech();" />  
Run Code Online (Sandbox Code Playgroud)

用它的相应的javascript:

<script type="text/javascript">

        function processspeech() {
            var speechtext = $("#speech").val();
            alert(speechtext);
        }

</script>
Run Code Online (Sandbox Code Playgroud)

那么我将能够使用谷歌的语音识别.我想知道是否可以发送一个点击该输入控件,以便用JavaScript激活它.换句话说,我想通过点击小麦克风以外的按钮开始录制消息.我计划在本地使用该网站,所以也许我可以通过其他方式发送一个点击.

Ton*_*Nam 1

我设法用一个名为 autoit 的程序来做到这一点。步骤如下:

1)下载AutoIt并安装。

2)创建html:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function processspeech() {
            var speechtext = document.getElementById("speech").value;                   
            alert(speechtext);          
        }

    </script>
</head>
<body>


    <div id="speechinput"> 
        <input  id="speech" type="text" speech="speech" x-webkit-speech="x-webkit-speech" onspeechchange="processspeech();" onwebkitspeechchange="processspeech();" />          
    </div> 

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

3)用google chrome打开上一步刚刚创建的html文件

在此输入图像描述

4)当您安装 autoit 时,会有一个名为“autoit window info启动它”的程序,然后单击“摘要”选项卡

在此输入图像描述

5)将finder工具拖到google的chrome窗口(特别是麦克风)。

在此输入图像描述

6)创建一个新的autoit脚本:

在此输入图像描述

我忘记强调ControlClick Coords你将需要......

7) 在 autoit 中输入以下函数以及从步骤 5 获得的结果:

在此输入图像描述

8) 按 {f5} 运行脚本,然后即使窗口是隐藏的,也应该将单击发送到该控件!然后你可以使用ajax将结果发送到你的网络服务器等......