heavenm 发表于 2014-5-6 21:58:23

如何获取IE句柄?之前好像记得有方法的忘记了

; *******************************************************
; 示例1 - 获取COM错误以便外部历史集的'Back'及'Forward'不使脚本退出
;    (COM错误将送至控制台)
;
; *******************************************************

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister()

Local $oIE = _IECreateEmbedded()
$Form1_1=GUICreate("Embedded Web control Test", 640, 580, _
                (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
                $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 40, 600, 360)
Local $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
Local $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
Local $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
Local $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState() ;显示GUI

_IENavigate($oIE, "http://www.baidu.com")
MsgBox(0, $Form1_1, $oIE.HWnd)
Exit
; 等待用户关闭窗口
While 1
        Local $msg = GUIGetMsg()
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $msg = $GUI_Button_Home
                        _IENavigate($oIE, "http://www.autoitscript.com")
                Case $msg = $GUI_Button_Back
                        _IEAction($oIE, "back")
                Case $msg = $GUI_Button_Forward
                        _IEAction($oIE, "forward")
                Case $msg = $GUI_Button_Stop
                        _IEAction($oIE, "stop")
        EndSelect
WEnd

GUIDelete()

Exit

athland5013 发表于 2014-5-7 12:28:27

WinSetOnTop(HWnd($oIE.HWnd()), "", 0)

heavenm 发表于 2014-5-7 22:44:54

WinSetOnTop(HWnd($oIE.HWnd()), "", 0)
athland5013 发表于 2014-5-7 12:28 http://www.autoitx.com/images/common/back.gif


    一样不会获取到呢!

lin6051 发表于 2014-5-8 07:58:20

貌似可以获取进程id 再或句柄吧

lixiaolong 发表于 2014-5-11 15:44:42

本帖最后由 lixiaolong 于 2014-5-11 15:46 编辑

回复 1# heavenm

试试.; *******************************************************
; 示例1 - 获取COM错误以便外部历史集的'Back'及'Forward'不使脚本退出
;    (COM错误将送至控制台)
;
; *******************************************************

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

;~ _IEErrorHandlerRegister()

Local $oIE = _IECreateEmbedded()
$Form1_1=GUICreate("Embedded Web control Test", 640, 580, _
                (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
                $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 40, 600, 360)
Local $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
Local $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
Local $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
Local $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState() ;显示GUI

_IENavigate($oIE, "http://www.baidu.com")

$hWnd = ControlGetHandle($Form1_1, "", "")

MsgBox(0, $Form1_1, $hWnd)
Exit
; 等待用户关闭窗口
While 1
      Local $msg = GUIGetMsg()
      Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $msg = $GUI_Button_Home
                        _IENavigate($oIE, "http://www.autoitscript.com")
                Case $msg = $GUI_Button_Back
                        _IEAction($oIE, "back")
                Case $msg = $GUI_Button_Forward
                        _IEAction($oIE, "forward")
                Case $msg = $GUI_Button_Stop
                        _IEAction($oIE, "stop")
      EndSelect
WEnd

GUIDelete()

Exit

heavenm 发表于 2014-5-11 17:21:02


句柄不一样!
而且这个方法太间接了,不太好用!
页: [1]
查看完整版本: 如何获取IE句柄?之前好像记得有方法的忘记了