AutoHotKeyでIE操作 google検索サンプル

ネタ元


上記記事のころとはGoogleのコードが変わったのでそのままでは動かなかった。

現在(2012/6/24)で動くのはコチラ

ActiveX.ahk

;ActiveX.ahkを同じディレクトリに置いてます
#include %A_ScriptDir%\ActiveX.ahk

;初期化
ActiveX()

;オブジェクト作成
ie:=CreateObject("InternetExplorer.Application")

pp(ie,"Visible","true")
inv(ie,"Navigate","http://www.google.co.jp/")

;表示待ち
Gosub IEbusy

OutputDebug,"表示OK"

doc:=gp(ie,"document")
forms:=gp(doc,"forms")
forms:=gp(doc,"gbqf")
input:=gp(forms,"q")
pp(input,"value","test")
btn:=gp(forms,"btnG")
inv(btn,"click")


IEbusy:
    Loop {
        busy:=gp(ie,"busy")
        state:=gp(ie,"readyState")
        if ( busy = 0 and state = 4)
            break
        sleep 250
    }
return