找回密码
 加入
搜索
查看: 4663|回复: 3

[IE类操作] 【已解决】从IE里面怎么更好的调用到autoit中的方法?

[复制链接]
发表于 2012-12-2 21:50:05 | 显示全部楼层 |阅读模式
本帖最后由 gently 于 2012-12-2 22:14 编辑

网上一堆的帮助都是autoit怎么调用ie里的js,就是没有找到IE里的js怎么调用autoit里的方法,函数,等等,所以我有些郁闷阿

我想要在IE里面用JS调用到autoit中的方法,比如获得网卡信息,比如弹出一个对话框,我想到的办法是使用window.status作代理,这总显得蹩脚,大牛们有更好的方法吗?
#include "IE.au3"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("test",@DesktopWidth-30)
;_IECreate(@ScriptDir & "\1.html", 1, 1, )
_IEErrorHandlerRegister("myerrhand")

Local $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 10, 40, 600, 360)

GUISetState(@SW_SHOW)
_IENavigate($oIE, @ScriptDir & "\1.html?"&Random(1,10000))
While 1
   $msg = GUIGetMsg()
   Select
   case  $msg = $GUI_EVENT_CLOSE
          GUIDelete()
          Exit
   EndSelect
   $cmd_str = $oIE.document.parentWindow.status
   if StringCompare("login::", $cmd_str) = 0 then
          MsgBox(64, "main window","登录 (你成功的从JS调用了我 )")
   elseif StringCompare("get_mac::",$cmd_str) = 0 then
          $oIE.document.parentWindow.execScript('get_mac("我怎么知道你网卡地址是啥")')
          ConsoleWrite("getMAC")
   EndIf
   $oIE.document.parentWindow.status=""
   Sleep(10)
WEnd

func myerrhand()
   ;nothing to do
EndFunc
HTML代码如下:
<!DOCTYPE HTML>
<html>

<head>
        <title>Page Title</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script type="text/javascript">
                function ttt(){
                        var rand = Math.random()*10000;
                        document.getElementById("show").innerHTML="外部登录" + rand;
                        window.status="login::";
                }
                function get_mac(mac){
                        mac = mac || null;
                        if(!mac){
                                window.status = "get_mac::";
                                document.getElementById("show").innerHTML="正在获取网卡信息....";
                                return false;
                        }
                        document.getElementById("show").innerHTML=mac;
                        return true;
                }
        </script>
</head>

<body>
        <h1 id="show">title random</h1>
        <input type="button" value="登录" onclick="ttt()"/>
        <input type="button" value="网卡地址" onclick="get_mac()"/>
</body>
</html>
期待高见
 楼主| 发表于 2012-12-2 22:13:20 | 显示全部楼层
搜到一篇2年前的帖子,似乎我的问题解决了,我关闭话题吧
http://www.autoitx.com/forum.php?mod=viewthread&tid=17524,第7楼
发表于 2017-7-17 16:32:33 | 显示全部楼层
期待高见期待高见
发表于 2017-7-17 16:32:40 | 显示全部楼层
期待高见期待高见
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-25 16:12 , Processed in 0.081382 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表