Jump to content

Can you please test the following code


Guest
 Share

Recommended Posts

Hello,

I made this code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#include <WinAPIEx.au3>
#include <IE.au3>
#Include <Array.au3>

#AutoIt3Wrapper_Run_AU3Check=n

Test("http://www.autoitscript.com/site/")


Func Test($Url)
    Local $Form1 , $Close_Button , $IECreatePseudo , $oIE , $aMain , $nMsg , $IELoaded
    Local $ActiveURL = $Url , $Open_Button , $o_Shell , $o_ShellWindows , $Founnd_Url , $OpenButtonSate

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("", 915, 664)
    $Close_Button = GUICtrlCreateButton("Close", 488, 632, 89, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Open_Button = GUICtrlCreateButton("Open in browser", 328, 632, 105, 25)
    GUICtrlSetState (-1,$GUI_DISABLE)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
;~     WinSetOnTop($Form1, "", 1)
    Local $IEWidth = 897 , $IEHeight = 617
    $IECreatePseudo = IECreatePseudoEmbedded($Url, $Form1, 8, 8, 897, 617,8000)
    If IsArray($IECreatePseudo) Then
        $oIE = $IECreatePseudo[0]
        $aMain = $IECreatePseudo[1]
        If IsObj($oIE) Then
            GUICtrlSetState($Open_Button,$GUI_ENABLE)
            $OpenButtonSate = 1
            $IELoaded = 1
;~          _IEAction($oIE, "focus" )
;           http://msdn.microsoft.com/en-us/library/ms970456.aspx

            $oIE.StatusBar = True
            $oIE.Focus()
        EndIf
    EndIf
    #endregion ### END Koda GUI section ###
;~     WinSetOnTop($Form1, "", 1)
    While 1
        If $IELoaded = 1 Then
            If $oIE.LocationURL <> $ActiveURL Then
                If StringLeft($oIE.LocationURL,4) = "http" Then
                    $ActiveURL = $oIE.LocationURL
                    If $OpenButtonSate = 0 Then
                        GUICtrlSetState($Open_Button,$GUI_ENABLE)
                        $OpenButtonSate = 1
                    EndIf
                Else
                    $o_Shell = ObjCreate("Shell.Application")
                    $o_ShellWindows = $o_Shell.Windows()
                    $Founnd_Url = 0
                    For $o_window In $o_ShellWindows
                        If $o_window.FullScreen = True And $o_window.Width = $IEWidth And $o_window.Height = $IEHeight Then
                            $oIE = $o_window
                            If StringLeft($oIE.LocationURL,4) = "http" Then
                                $ActiveURL = $oIE.LocationURL
                                If $OpenButtonSate = 0 Then
                                    GUICtrlSetState($Open_Button,$GUI_ENABLE)
                                    $OpenButtonSate = 1
                                EndIf
                                $Founnd_Url = 1
                                ConsoleWrite("Fixed:"&@CRLF) ; < --------------- Debug line
                            EndIf
                            ExitLoop
                        EndIf
                    Next
                    If $Founnd_Url = 0 And $OpenButtonSate = 1 Then
                        GUICtrlSetState($Open_Button,$GUI_DISABLE)
                        $OpenButtonSate = 0
                    EndIf
                EndIf
                $oIE.StatusBar = True
                ConsoleWrite($ActiveURL&@CRLF) ; < --------------- Debug line
            EndIf
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE , $Close_Button
                ;ContinueLoop
                If $IELoaded = 1 And IsArray($aMain) Then
                    WinClose($aMain[1])
                    _IEQuit($oIE)
                    If ProcessWaitClose($aMain[0],2) = 0 Then ProcessClose($aMain[0])
                EndIf
                ;IECreatePseudoEmbedded_CloseAllIEs($IEWidth,$IEHeight) ; If another iexplore.exe process that created with IECreatePseudoEmbedded() is still
                ;                                                       running for some for some reson reason, then that process should be closed now.
                ;                                                   ******** This function is not working. Please write working function  and share it with me ********
                ExitLoop
            Case $Open_Button
;~                 WinSetOnTop($Form1, "", 0)
                ShellExecute($ActiveURL)
        EndSwitch
    WEnd
    GUIDelete($Form1)
EndFunc





; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded
; Description ...: Create IE frame in GUI with the laset IE verison that installed on the computer
; Syntax ........: IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height[, $wait = 5000])
; Parameters ....: $sURL                - The URL to load.
;                  $h_Parent            - The handle of the GUI to create the IE frame in..
;                  $i_Left              - X pos.
;                  $i_Top               - Y Pos
;                  $i_Width             - The width of the frame.
;                  $i_Height            - The height of the frame.
;                  $wait                - [optional] max time to wait for the page to load. Default is 5000 ms.
; Return values .: If error:
;                   -1 = can't open internet explorer
;                   -2 = loading time limit reached
;                   -3 = object error occurred
;               .: Id not error:
;                   Array Variable:
;                       [0] = $o_object - Object variable of an InternetExplorer.Application, Window or Frame object
;                           the Object is for IE functions in IE.au3
;                       [1] = Another array:
;                               [0] = the pid of the IE frame
;                               [1] = the handle of the IE frame
; Author ........: gil900
; Modified ......: Yes and No ;)
; Inspired from .: http://www.autoitscript.com/forum/topic/152173-pseudo-embed-google-chrome/
;                  http://www.autoitscript.com/forum/topic/138980-iecreatepseudoembedded/
;                  http://www.autoitscript.com/forum/topic/99234-iecreate2/#entry712594
;                  AutoIt3\Include\IE.au3

; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: yes
;
; ===============================================================================================================================
Func IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height, $wait = 5000)
    Local $Output[2] = [-1,-1] , $acMain[2] , $o_IE , $timer , $GIECPE_Edit1 , $pid , $o_Shell , $o_ShellWindows , $o_window
    $GIECPE_Edit1 = GUICtrlCreateEdit("loading...", $i_Left, $i_Top, $i_Width, $i_Height,$ES_READONLY+$ES_CENTER)
    GUICtrlSetFont(-1, 35, 400, 2, "Tahoma")
    GUICtrlSetColor(-1, 0x646464)
    $pid = ShellExecute(@HomeDrive&"\Program Files\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)
    If $pid = 0 Then
        GUICtrlSetData($GIECPE_Edit1, "Error in opening Internet Explorer")
        Return -1
    EndIf
    $timer = TimerInit()
    While 1
        If TimerDiff($timer) >= $wait Then
            GUICtrlSetData($GIECPE_Edit1, "Error: loading time limit reached")
            ProcessClose($pid)
;~          IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
            Return -2
        EndIf
        $o_Shell = ObjCreate("Shell.Application")
        $o_ShellWindows = $o_Shell.Windows()
        For $o_window In $o_ShellWindows
            If $o_window.LocationURL = $sURL Then
                $o_IE = $o_window
                $Output[0] = $o_IE
                ExitLoop 2
            EndIf
        Next
    WEnd
    If Not IsObj($o_IE) Then
        GUICtrlSetData($GIECPE_Edit1, "Error: object error occurred")
;~      IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
        Return -3
    EndIf
    $acMain[1] = _IEPropertyGet($o_IE, "hwnd")
    $acMain[0] = WinGetProcess($acMain[1])
    $Output[1] = $acMain
    GUISetState(@SW_HIDE, $h_Parent)
    GUICtrlDelete($GIECPE_Edit1)
    _WinAPI_SetParent($acMain[1], $h_Parent)
    _WinAPI_SetWindowLong($acMain[1], $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
    GUISetState(@SW_SHOW, $h_Parent)
    ControlMove($acMain[1], "", "", $i_Left + 1, $i_Top + 1, $i_Width , $i_Height)
    WinActivate($acMain[1])
    Return $Output
EndFunc



; ********************* This function is not working.... I hope someone else will write working function  *******************
; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded_CloseAllIEs
; Description ...: This function will close any iexplore.exe process that started with IECreatePseudoEmbedded()
;                   The function know what iexplore.exe process to close According to the Width , Height of the embedded frame.
;                   In order that the function will performs the action correctly, you need to call to the function with the same $i_Width , $i_Height
;                   values that used in IECreatePseudoEmbedded().

; Syntax ........: IECreatePseudoEmbedded_CloseAllIEs($i_Width, $i_Height)
; Parameters ....: $i_Width             - An integer value.
;                  $i_Height            - An integer value.
; Return values .: None
; Author ........: gil900
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
;~ Func IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height)

;~  ConsoleWrite($i_Width&@CRLF)
;~  Return
;~  Local $o_Shell , $o_ShellWindows , $i_Width2 = $i_Width-44 , $i_Height2 = $i_Height-17 , $IsIe , $pid
;~  ConsoleWrite($i_Width&" , "&$i_Height2&@CRLF)
;~  Return

;~  $o_Shell = ObjCreate("Shell.Application")
;~  $o_ShellWindows = $o_Shell.Windows()
;~  For $o_window In $o_ShellWindows
;~      $IsIe = False
;~      ConsoleWrite($o_window.Width&" , "&$o_window.Height&@CRLF)
;~      If  $o_window.Width = $i_Width And $o_window.Height = $i_Height Then
;~          $IsIe = True
;~      ElseIf $o_window.Width = $i_Width2 And $o_window.Height = $i_Height2 Then
;~          $IsIe = True
;~      EndIf
;~      If $IsIe Then
;~          $pid = WinGetProcess(HWnd($o_window.HWnd()))
;~          ConsoleWrite($pid&@CRLF)
;~          _IEQuit($o_window)


;~      EndIf
;~  Next
;~ EndFunc
; ********************* This function is not working.... I hope someone else will write working function  *******************

I need you to test it on your system.

the code  supposed to open GUI window with embbeded IE frame (last IE version)

in the GUI you will see 2 buttons: "Close" and "Open in browser".

the "Close" will close the GUI window and also the iexplore.exe process that used for the frame.

the "Open in browser" will open in new browser the current page that displayed in the GUI.

and that button will be available only if the IE frame is successfully created.

there is a case that this button will be change to disable. that case never supposed to happen!

if the button was change back to disable then please report to me about it.

In case of error from IECreatePseudoEmbedded() , any hidden iexplore.exe process that opened before(if opened)  should be closed.

 

Please check the code and report to me the results.

If the code is functioning properly, I will post it in Example Scripts

please include in your report the following:
* Your operating system, 64bit / 32 bit
I wish you would fix problems by yourself (if you find any) and give me the patch here.

Thank you

Gil

 

EDIT

I updated the code to new version. the the previous code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#include <WinAPIEx.au3>
#include <IE.au3>
#Include <Array.au3>

#AutoIt3Wrapper_Run_AU3Check=n

Test("http://www.autoitscript.com/site/")


Func Test($Url)
    Local $Form1 , $Button1 , $IE_Pid , $Close_Button , $IECreatePseudo , $oIE , $aMain , $nMsg
    Local $ActiveURL = $Url , $GetActiveURL = 0 , $Open_Button , $o_Shell , $o_ShellWindows , $Founnd_oIE

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("", 915, 664)
    $Close_Button = GUICtrlCreateButton("Close", 488, 632, 89, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Open_Button = GUICtrlCreateButton("Open in browser", 328, 632, 105, 25)
    GUICtrlSetState (-1,$GUI_DISABLE)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    WinSetOnTop($Form1, "", 1)
    Local $IEWidth = 897 , $IEHeight = 617
    $IECreatePseudo = IECreatePseudoEmbedded($Url, $Form1, 8, 8, 897, 617)
    If IsArray($IECreatePseudo) Then
        $oIE = $IECreatePseudo[0]
        $aMain = $IECreatePseudo[1]
        If IsObj($oIE) Then
            GUICtrlSetState($Open_Button,$GUI_ENABLE)
            $GetActiveURL = 1
;~          _IEAction($oIE, "focus" )
;           http://msdn.microsoft.com/en-us/library/ms970456.aspx

            $oIE.StatusBar = True
            $oIE.Focus()
        EndIf
    EndIf
    #endregion ### END Koda GUI section ###
    WinSetOnTop($Form1, "", 1)
    While 1
        If $GetActiveURL = 1 Then ; And IsObj($oIE)
            If $oIE.LocationURL <> $ActiveURL Then
                If $oIE.LocationURL <> "about:blank" Then
                    $ActiveURL = $oIE.LocationURL
                Else
                    $o_Shell = ObjCreate("Shell.Application")
                    $o_ShellWindows = $o_Shell.Windows()
                    $Founnd_oIE = False
                    For $o_window In $o_ShellWindows

                        If $o_window.FullScreen = True And $o_window.Width = $IEWidth And $o_window.Height = $IEHeight Then
                            $oIE = $o_window
                            $ActiveURL = $oIE.LocationURL
                            $Founnd_oIE = True
                            ConsoleWrite("Fixed:"&@CRLF) ; < --------------- Debug line
                            ExitLoop
                        EndIf
                    Next
                    If Not $Founnd_oIE Then
                        GUICtrlSetState ($Open_Button,$GUI_DISABLE)
                        $GetActiveURL = 0
                    EndIf
                EndIf
                $oIE.StatusBar = True
                ConsoleWrite($ActiveURL&@CRLF) ; < --------------- Debug line
            EndIf
        EndIf

        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE , $Close_Button
                ;ContinueLoop
                If IsObj($oIE) Then
                    If IsArray Then WinClose($aMain[1])
                    _IEQuit($oIE)
                    If ProcessWaitClose($aMain[0],2) = 0 Then ProcessClose($aMain[0])
                EndIf
                ;IECreatePseudoEmbedded_CloseAllIEs($IEWidth,$IEHeight) ; If another iexplore.exe process that created with IECreatePseudoEmbedded() is still
                ;                                                       running for some for some reson reason, then that process should be closed now.
                ;                                                   ******** This function is not working. Please write working function  and share it with me ********
                ExitLoop
            Case $Open_Button
                WinSetOnTop($Form1, "", 0)
                ShellExecute($ActiveURL)
        EndSwitch
    WEnd
    GUIDelete($Form1)
EndFunc





; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded
; Description ...: Create IE frame in GUI with the laset IE verison that installed on the computer
; Syntax ........: IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height[, $wait = 5000])
; Parameters ....: $sURL                - The URL to load.
;                  $h_Parent            - The handle of the GUI to create the IE frame in..
;                  $i_Left              - X pos.
;                  $i_Top               - Y Pos
;                  $i_Width             - The width of the frame.
;                  $i_Height            - The height of the frame.
;                  $wait                - [optional] max time to wait for the page to load. Default is 5000 ms.
; Return values .: If error:
;                   -1 = can't open internet explorer
;                   -2 = loading time limit reached
;                   -3 = object error occurred
;               .: Id not error:
;                   Array Variable:
;                       [0] = $o_object - Object variable of an InternetExplorer.Application, Window or Frame object
;                           the Object is for IE functions in IE.au3
;                       [1] = Another array:
;                               [0] = the pid of the IE frame
;                               [1] = the handle of the IE frame
; Author ........: gil900
; Modified ......: Yes and No ;)
; Inspired from .: http://www.autoitscript.com/forum/topic/152173-pseudo-embed-google-chrome/
;                  http://www.autoitscript.com/forum/topic/138980-iecreatepseudoembedded/
;                  http://www.autoitscript.com/forum/topic/99234-iecreate2/#entry712594
;                  AutoIt3\Include\IE.au3

; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: yes
;
; ===============================================================================================================================
Func IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height, $wait = 5000)
    Local $Output[2] = [-1,-1] , $acMain[2] , $o_IE , $timer , $GIECPE_Edit1 , $pid , $o_Shell , $o_ShellWindows , $o_window
    $GIECPE_Edit1 = GUICtrlCreateEdit("loading...", $i_Left, $i_Top, $i_Width, $i_Height,$ES_READONLY+$ES_CENTER)
    GUICtrlSetFont(-1, 35, 400, 2, "Tahoma")
    GUICtrlSetColor(-1, 0x646464)
    $pid = ShellExecute(@HomeDrive&"\Program Files\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)
    If $pid = 0 Then
        GUICtrlSetData($GIECPE_Edit1, "Error in opening Internet Explorer")
        Return -1
    EndIf
    $timer = TimerInit()
    While 1
        If TimerDiff($timer) >= $wait Then
            GUICtrlSetData($GIECPE_Edit1, "Error: loading time limit reached")
            ProcessClose($pid)
;~          IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
            Return -2
        EndIf
        $o_Shell = ObjCreate("Shell.Application")
        $o_ShellWindows = $o_Shell.Windows()
        For $o_window In $o_ShellWindows
            If $o_window.LocationURL = $sURL Then
                $o_IE = $o_window
                $Output[0] = $o_IE
                ExitLoop 2
            EndIf
        Next
    WEnd
    If Not IsObj($o_IE) Then
        GUICtrlSetData($GIECPE_Edit1, "Error: object error occurred")
;~      IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
        Return -3
    EndIf
    $acMain[1] = _IEPropertyGet($o_IE, "hwnd")
    $acMain[0] = WinGetProcess($acMain[1])
    $Output[1] = $acMain
    GUISetState(@SW_HIDE, $h_Parent)
    GUICtrlDelete($GIECPE_Edit1)
    _WinAPI_SetParent($acMain[1], $h_Parent)
    _WinAPI_SetWindowLong($acMain[1], $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
    GUISetState(@SW_SHOW, $h_Parent)
    ControlMove($acMain[1], "", "", $i_Left + 1, $i_Top + 1, $i_Width , $i_Height)
    WinActivate($acMain[1])
    Return $Output
EndFunc



; ********************* This function is not working.... I hope someone else will write working function  *******************
; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded_CloseAllIEs
; Description ...: This function will close any iexplore.exe process that started with IECreatePseudoEmbedded()
;                   The function know what iexplore.exe process to close According to the Width , Height of the embedded frame.
;                   In order that the function will performs the action correctly, you need to call to the function with the same $i_Width , $i_Height
;                   values that used in IECreatePseudoEmbedded().

; Syntax ........: IECreatePseudoEmbedded_CloseAllIEs($i_Width, $i_Height)
; Parameters ....: $i_Width             - An integer value.
;                  $i_Height            - An integer value.
; Return values .: None
; Author ........: gil900
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
;~ Func IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height)

;~  ConsoleWrite($i_Width&@CRLF)
;~  Return
;~  Local $o_Shell , $o_ShellWindows , $i_Width2 = $i_Width-44 , $i_Height2 = $i_Height-17 , $IsIe , $pid
;~  ConsoleWrite($i_Width&" , "&$i_Height2&@CRLF)
;~  Return

;~  $o_Shell = ObjCreate("Shell.Application")
;~  $o_ShellWindows = $o_Shell.Windows()
;~  For $o_window In $o_ShellWindows
;~      $IsIe = False
;~      ConsoleWrite($o_window.Width&" , "&$o_window.Height&@CRLF)
;~      If  $o_window.Width = $i_Width And $o_window.Height = $i_Height Then
;~          $IsIe = True
;~      ElseIf $o_window.Width = $i_Width2 And $o_window.Height = $i_Height2 Then
;~          $IsIe = True
;~      EndIf
;~      If $IsIe Then
;~          $pid = WinGetProcess(HWnd($o_window.HWnd()))
;~          ConsoleWrite($pid&@CRLF)
;~          _IEQuit($o_window)


;~      EndIf
;~  Next
;~ EndFunc
; ********************* This function is not working.... I hope someone else will write working function  *******************

EDIT 2

code updated again - removed

WinSetOnTop($Form1, "", 1)

EDIT 3:

I updated the code to new version. the the previous code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#include <WinAPIEx.au3>
#include <IE.au3>
#Include <Array.au3>

#AutoIt3Wrapper_Run_AU3Check=n

Test("http://www.autoitscript.com/site/")


Func Test($Url)
    Local $Form1 , $Button1 , $IE_Pid , $Close_Button , $IECreatePseudo , $oIE , $aMain , $nMsg
    Local $ActiveURL = $Url , $GetActiveURL = 0 , $Open_Button , $o_Shell , $o_ShellWindows , $Founnd_oIE

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("", 915, 664)
    $Close_Button = GUICtrlCreateButton("Close", 488, 632, 89, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Open_Button = GUICtrlCreateButton("Open in browser", 328, 632, 105, 25)
    GUICtrlSetState (-1,$GUI_DISABLE)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
;~     WinSetOnTop($Form1, "", 1)
    Local $IEWidth = 897 , $IEHeight = 617
    $IECreatePseudo = IECreatePseudoEmbedded($Url, $Form1, 8, 8, 897, 617)
    If IsArray($IECreatePseudo) Then
        $oIE = $IECreatePseudo[0]
        $aMain = $IECreatePseudo[1]
        If IsObj($oIE) Then
            GUICtrlSetState($Open_Button,$GUI_ENABLE)
            $GetActiveURL = 1
;~          _IEAction($oIE, "focus" )
;           http://msdn.microsoft.com/en-us/library/ms970456.aspx

            $oIE.StatusBar = True
            $oIE.Focus()
        EndIf
    EndIf
    #endregion ### END Koda GUI section ###
;~     WinSetOnTop($Form1, "", 1)
    While 1
        If $oIE.LocationURL <> $ActiveURL Then
            If $oIE.LocationURL <> "about:blank" Then
                $ActiveURL = $oIE.LocationURL
                $GetActiveURL = 1
            Else
                $o_Shell = ObjCreate("Shell.Application")
                $o_ShellWindows = $o_Shell.Windows()
                $Founnd_oIE = False
                For $o_window In $o_ShellWindows

                    If $o_window.FullScreen = True And $o_window.Width = $IEWidth And $o_window.Height = $IEHeight Then
                        $oIE = $o_window
                        $ActiveURL = $oIE.LocationURL
                        $GetActiveURL = 1
                        $Founnd_oIE = True
                        ConsoleWrite("Fixed:"&@CRLF) ; < --------------- Debug line
                        ExitLoop
                    EndIf
                Next
                If Not $Founnd_oIE Or $ActiveURL = "about:blank" Then
                    GUICtrlSetState($Open_Button,$GUI_DISABLE)
                    $GetActiveURL = 0
                EndIf
            EndIf
            $oIE.StatusBar = True
            If $GetActiveURL = 1 Then GUICtrlSetState($Open_Button,$GUI_ENABLE)
            ConsoleWrite($ActiveURL&@CRLF) ; < --------------- Debug line
        EndIf

        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE , $Close_Button
                ;ContinueLoop
                If IsObj($oIE) And IsArray($aMain) Then
                    WinClose($aMain[1])
                    _IEQuit($oIE)
                    If ProcessWaitClose($aMain[0],2) = 0 Then ProcessClose($aMain[0])
                EndIf
                ;IECreatePseudoEmbedded_CloseAllIEs($IEWidth,$IEHeight) ; If another iexplore.exe process that created with IECreatePseudoEmbedded() is still
                ;                                                       running for some for some reson reason, then that process should be closed now.
                ;                                                   ******** This function is not working. Please write working function  and share it with me ********
                ExitLoop
            Case $Open_Button
;~                 WinSetOnTop($Form1, "", 0)
                ShellExecute($ActiveURL)
        EndSwitch
    WEnd
    GUIDelete($Form1)
EndFunc





; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded
; Description ...: Create IE frame in GUI with the laset IE verison that installed on the computer
; Syntax ........: IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height[, $wait = 5000])
; Parameters ....: $sURL                - The URL to load.
;                  $h_Parent            - The handle of the GUI to create the IE frame in..
;                  $i_Left              - X pos.
;                  $i_Top               - Y Pos
;                  $i_Width             - The width of the frame.
;                  $i_Height            - The height of the frame.
;                  $wait                - [optional] max time to wait for the page to load. Default is 5000 ms.
; Return values .: If error:
;                   -1 = can't open internet explorer
;                   -2 = loading time limit reached
;                   -3 = object error occurred
;               .: Id not error:
;                   Array Variable:
;                       [0] = $o_object - Object variable of an InternetExplorer.Application, Window or Frame object
;                           the Object is for IE functions in IE.au3
;                       [1] = Another array:
;                               [0] = the pid of the IE frame
;                               [1] = the handle of the IE frame
; Author ........: gil900
; Modified ......: Yes and No ;)
; Inspired from .: http://www.autoitscript.com/forum/topic/152173-pseudo-embed-google-chrome/
;                  http://www.autoitscript.com/forum/topic/138980-iecreatepseudoembedded/
;                  http://www.autoitscript.com/forum/topic/99234-iecreate2/#entry712594
;                  AutoIt3\Include\IE.au3

; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: yes
;
; ===============================================================================================================================
Func IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height, $wait = 5000)
    Local $Output[2] = [-1,-1] , $acMain[2] , $o_IE , $timer , $GIECPE_Edit1 , $pid , $o_Shell , $o_ShellWindows , $o_window
    $GIECPE_Edit1 = GUICtrlCreateEdit("loading...", $i_Left, $i_Top, $i_Width, $i_Height,$ES_READONLY+$ES_CENTER)
    GUICtrlSetFont(-1, 35, 400, 2, "Tahoma")
    GUICtrlSetColor(-1, 0x646464)
    $pid = ShellExecute(@HomeDrive&"\Program Files\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)
    If $pid = 0 Then
        GUICtrlSetData($GIECPE_Edit1, "Error in opening Internet Explorer")
        Return -1
    EndIf
    $timer = TimerInit()
    While 1
        If TimerDiff($timer) >= $wait Then
            GUICtrlSetData($GIECPE_Edit1, "Error: loading time limit reached")
            ProcessClose($pid)
;~          IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
            Return -2
        EndIf
        $o_Shell = ObjCreate("Shell.Application")
        $o_ShellWindows = $o_Shell.Windows()
        For $o_window In $o_ShellWindows
            If $o_window.LocationURL = $sURL Then
                $o_IE = $o_window
                $Output[0] = $o_IE
                ExitLoop 2
            EndIf
        Next
    WEnd
    If Not IsObj($o_IE) Then
        GUICtrlSetData($GIECPE_Edit1, "Error: object error occurred")
;~      IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
        Return -3
    EndIf
    $acMain[1] = _IEPropertyGet($o_IE, "hwnd")
    $acMain[0] = WinGetProcess($acMain[1])
    $Output[1] = $acMain
    GUISetState(@SW_HIDE, $h_Parent)
    GUICtrlDelete($GIECPE_Edit1)
    _WinAPI_SetParent($acMain[1], $h_Parent)
    _WinAPI_SetWindowLong($acMain[1], $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
    GUISetState(@SW_SHOW, $h_Parent)
    ControlMove($acMain[1], "", "", $i_Left + 1, $i_Top + 1, $i_Width , $i_Height)
    WinActivate($acMain[1])
    Return $Output
EndFunc



; ********************* This function is not working.... I hope someone else will write working function  *******************
; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded_CloseAllIEs
; Description ...: This function will close any iexplore.exe process that started with IECreatePseudoEmbedded()
;                   The function know what iexplore.exe process to close According to the Width , Height of the embedded frame.
;                   In order that the function will performs the action correctly, you need to call to the function with the same $i_Width , $i_Height
;                   values that used in IECreatePseudoEmbedded().

; Syntax ........: IECreatePseudoEmbedded_CloseAllIEs($i_Width, $i_Height)
; Parameters ....: $i_Width             - An integer value.
;                  $i_Height            - An integer value.
; Return values .: None
; Author ........: gil900
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
;~ Func IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height)

;~  ConsoleWrite($i_Width&@CRLF)
;~  Return
;~  Local $o_Shell , $o_ShellWindows , $i_Width2 = $i_Width-44 , $i_Height2 = $i_Height-17 , $IsIe , $pid
;~  ConsoleWrite($i_Width&" , "&$i_Height2&@CRLF)
;~  Return

;~  $o_Shell = ObjCreate("Shell.Application")
;~  $o_ShellWindows = $o_Shell.Windows()
;~  For $o_window In $o_ShellWindows
;~      $IsIe = False
;~      ConsoleWrite($o_window.Width&" , "&$o_window.Height&@CRLF)
;~      If  $o_window.Width = $i_Width And $o_window.Height = $i_Height Then
;~          $IsIe = True
;~      ElseIf $o_window.Width = $i_Width2 And $o_window.Height = $i_Height2 Then
;~          $IsIe = True
;~      EndIf
;~      If $IsIe Then
;~          $pid = WinGetProcess(HWnd($o_window.HWnd()))
;~          ConsoleWrite($pid&@CRLF)
;~          _IEQuit($o_window)


;~      EndIf
;~  Next
;~ EndFunc
; ********************* This function is not working.... I hope someone else will write working function  *******************

EDIT 4:

I updated the code to new version. the the previous code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#include <WinAPIEx.au3>
#include <IE.au3>
#Include <Array.au3>

#AutoIt3Wrapper_Run_AU3Check=n

Test("http://www.autoitscript.com/site/")


Func Test($Url)
    Local $Form1 , $Button1 , $IE_Pid , $Close_Button , $IECreatePseudo , $oIE , $aMain , $nMsg
    Local $ActiveURL = $Url , $GetActiveURL = 0 , $Open_Button , $o_Shell , $o_ShellWindows , $Founnd_oIE

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("", 915, 664)
    $Close_Button = GUICtrlCreateButton("Close", 488, 632, 89, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Open_Button = GUICtrlCreateButton("Open in browser", 328, 632, 105, 25)
    GUICtrlSetState (-1,$GUI_DISABLE)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    WinSetOnTop($Form1, "", 1)
    Local $IEWidth = 897 , $IEHeight = 617
    $IECreatePseudo = IECreatePseudoEmbedded($Url, $Form1, 8, 8, 897, 617)
    If IsArray($IECreatePseudo) Then
        $oIE = $IECreatePseudo[0]
        $aMain = $IECreatePseudo[1]
        If IsObj($oIE) Then
            GUICtrlSetState($Open_Button,$GUI_ENABLE)
            $GetActiveURL = 1
;~          _IEAction($oIE, "focus" )
;           http://msdn.microsoft.com/en-us/library/ms970456.aspx

            $oIE.StatusBar = True
            $oIE.Focus()
        EndIf
    EndIf
    #endregion ### END Koda GUI section ###
    WinSetOnTop($Form1, "", 1)
    While 1
        If $GetActiveURL = 1 Then ; And IsObj($oIE)
            If $oIE.LocationURL <> $ActiveURL Then
                If $oIE.LocationURL <> "about:blank" Then
                    $ActiveURL = $oIE.LocationURL
                Else
                    $o_Shell = ObjCreate("Shell.Application")
                    $o_ShellWindows = $o_Shell.Windows()
                    $Founnd_oIE = False
                    For $o_window In $o_ShellWindows

                        If $o_window.FullScreen = True And $o_window.Width = $IEWidth And $o_window.Height = $IEHeight Then
                            $oIE = $o_window
                            $ActiveURL = $oIE.LocationURL
                            $Founnd_oIE = True
                            ConsoleWrite("Fixed:"&@CRLF) ; < --------------- Debug line
                            ExitLoop
                        EndIf
                    Next
                    If Not $Founnd_oIE Then
                        GUICtrlSetState ($Open_Button,$GUI_DISABLE)
                        $GetActiveURL = 0
                    EndIf
                EndIf
                $oIE.StatusBar = True
                ConsoleWrite($ActiveURL&@CRLF) ; < --------------- Debug line
            EndIf
        EndIf

        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE , $Close_Button
                ;ContinueLoop
                If IsObj($oIE) Then
                    If IsArray Then WinClose($aMain[1])
                    _IEQuit($oIE)
                    If ProcessWaitClose($aMain[0],2) = 0 Then ProcessClose($aMain[0])
                EndIf
                ;IECreatePseudoEmbedded_CloseAllIEs($IEWidth,$IEHeight) ; If another iexplore.exe process that created with IECreatePseudoEmbedded() is still
                ;                                                       running for some for some reson reason, then that process should be closed now.
                ;                                                   ******** This function is not working. Please write working function  and share it with me ********
                ExitLoop
            Case $Open_Button
                WinSetOnTop($Form1, "", 0)
                ShellExecute($ActiveURL)
        EndSwitch
    WEnd
    GUIDelete($Form1)
EndFunc





; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded
; Description ...: Create IE frame in GUI with the laset IE verison that installed on the computer
; Syntax ........: IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height[, $wait = 5000])
; Parameters ....: $sURL                - The URL to load.
;                  $h_Parent            - The handle of the GUI to create the IE frame in..
;                  $i_Left              - X pos.
;                  $i_Top               - Y Pos
;                  $i_Width             - The width of the frame.
;                  $i_Height            - The height of the frame.
;                  $wait                - [optional] max time to wait for the page to load. Default is 5000 ms.
; Return values .: If error:
;                   -1 = can't open internet explorer
;                   -2 = loading time limit reached
;                   -3 = object error occurred
;               .: Id not error:
;                   Array Variable:
;                       [0] = $o_object - Object variable of an InternetExplorer.Application, Window or Frame object
;                           the Object is for IE functions in IE.au3
;                       [1] = Another array:
;                               [0] = the pid of the IE frame
;                               [1] = the handle of the IE frame
; Author ........: gil900
; Modified ......: Yes and No ;)
; Inspired from .: http://www.autoitscript.com/forum/topic/152173-pseudo-embed-google-chrome/
;                  http://www.autoitscript.com/forum/topic/138980-iecreatepseudoembedded/
;                  http://www.autoitscript.com/forum/topic/99234-iecreate2/#entry712594
;                  AutoIt3\Include\IE.au3

; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: yes
;
; ===============================================================================================================================
Func IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height, $wait = 5000)
    Local $Output[2] = [-1,-1] , $acMain[2] , $o_IE , $timer , $GIECPE_Edit1 , $pid , $o_Shell , $o_ShellWindows , $o_window
    $GIECPE_Edit1 = GUICtrlCreateEdit("loading...", $i_Left, $i_Top, $i_Width, $i_Height,$ES_READONLY+$ES_CENTER)
    GUICtrlSetFont(-1, 35, 400, 2, "Tahoma")
    GUICtrlSetColor(-1, 0x646464)
    $pid = ShellExecute(@HomeDrive&"\Program Files\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)
    If $pid = 0 Then
        GUICtrlSetData($GIECPE_Edit1, "Error in opening Internet Explorer")
        Return -1
    EndIf
    $timer = TimerInit()
    While 1
        If TimerDiff($timer) >= $wait Then
            GUICtrlSetData($GIECPE_Edit1, "Error: loading time limit reached")
            ProcessClose($pid)
;~          IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
            Return -2
        EndIf
        $o_Shell = ObjCreate("Shell.Application")
        $o_ShellWindows = $o_Shell.Windows()
        For $o_window In $o_ShellWindows
            If $o_window.LocationURL = $sURL Then
                $o_IE = $o_window
                $Output[0] = $o_IE
                ExitLoop 2
            EndIf
        Next
    WEnd
    If Not IsObj($o_IE) Then
        GUICtrlSetData($GIECPE_Edit1, "Error: object error occurred")
;~      IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
        Return -3
    EndIf
    $acMain[1] = _IEPropertyGet($o_IE, "hwnd")
    $acMain[0] = WinGetProcess($acMain[1])
    $Output[1] = $acMain
    GUISetState(@SW_HIDE, $h_Parent)
    GUICtrlDelete($GIECPE_Edit1)
    _WinAPI_SetParent($acMain[1], $h_Parent)
    _WinAPI_SetWindowLong($acMain[1], $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
    GUISetState(@SW_SHOW, $h_Parent)
    ControlMove($acMain[1], "", "", $i_Left + 1, $i_Top + 1, $i_Width , $i_Height)
    WinActivate($acMain[1])
    Return $Output
EndFunc



; ********************* This function is not working.... I hope someone else will write working function  *******************
; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded_CloseAllIEs
; Description ...: This function will close any iexplore.exe process that started with IECreatePseudoEmbedded()
;                   The function know what iexplore.exe process to close According to the Width , Height of the embedded frame.
;                   In order that the function will performs the action correctly, you need to call to the function with the same $i_Width , $i_Height
;                   values that used in IECreatePseudoEmbedded().

; Syntax ........: IECreatePseudoEmbedded_CloseAllIEs($i_Width, $i_Height)
; Parameters ....: $i_Width             - An integer value.
;                  $i_Height            - An integer value.
; Return values .: None
; Author ........: gil900
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
;~ Func IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height)

;~  ConsoleWrite($i_Width&@CRLF)
;~  Return
;~  Local $o_Shell , $o_ShellWindows , $i_Width2 = $i_Width-44 , $i_Height2 = $i_Height-17 , $IsIe , $pid
;~  ConsoleWrite($i_Width&" , "&$i_Height2&@CRLF)
;~  Return

;~  $o_Shell = ObjCreate("Shell.Application")
;~  $o_ShellWindows = $o_Shell.Windows()
;~  For $o_window In $o_ShellWindows
;~      $IsIe = False
;~      ConsoleWrite($o_window.Width&" , "&$o_window.Height&@CRLF)
;~      If  $o_window.Width = $i_Width And $o_window.Height = $i_Height Then
;~          $IsIe = True
;~      ElseIf $o_window.Width = $i_Width2 And $o_window.Height = $i_Height2 Then
;~          $IsIe = True
;~      EndIf
;~      If $IsIe Then
;~          $pid = WinGetProcess(HWnd($o_window.HWnd()))
;~          ConsoleWrite($pid&@CRLF)
;~          _IEQuit($o_window)


;~      EndIf
;~  Next
;~ EndFunc
; ********************* This function is not working.... I hope someone else will write working function  *******************

Improvements in the new version (the new version is not under EDIT 4):

* Bug Fix (Logic problem)

* removed unused variables

* Small Optimzation 1 - Instead of constantly check in the loop if a variable is an object, it checks only once. Maybe it reduces CPU use

* Bug fix 2 (Logic problem) but not real bug (the END user will see nothing different)

Edited by Guest
Link to comment
Share on other sites

@gil900

not that i rant or something, but i have VM's of many Windows systems. some 64-bit (and even some Linux for WINE) dedicated to testing my scripts, so i'm fairly sure they work before i release stuff to production (or to the forum). testing in self makes it a lot faster then relying on community members, and if your scripts relate to deep hardware manipulation - which makes VM irrelevant - then multiboot will come in handy.

if you have a lot of testing to do, set up your own test environment. it's fun!

anyway, Vista "you asked for it ;)" Ultimate SP2 32-bit IE9 in crash recovery mode:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "Z:userDownloadsgil900.au3" /UserParams    
+>21:13:40 Starting AutoIt3Wrapper v.2.1.4.5 SciTE v.3.3.7.0   Keyboard:00000409  OS:WIN_VISTA/Service Pack 2  CPU:X64 OS:X86    Environment(Language:0409)
>Running:(3.3.10.2):C:Program FilesAutoIt3autoit3.exe "Z:userDownloadsgil900.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
"Z:userDownloadsgil900.au3" (46) : ==> Variable must be of type "Object".:
If $oIE.LocationURL <> $ActiveURL Then
If $oIE^ ERROR
->21:13:47 AutoIt3.exe ended.rc:1
+>21:13:47 AutoIt3Wrapper Finished..
>Exit code: 1    Time: 6.870

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

and same error on Win2008 SP2 32-bit IE9.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Thanks for the reports!

 

 

@gil900

not that i rant or something, but i have VM's of many Windows systems. some 64-bit (and even some Linux for WINE) dedicated to testing my scripts, so i'm fairly sure they work before i release stuff to production (or to the forum). testing in self makes it a lot faster then relying on community members, and if your scripts relate to deep hardware manipulation - which makes VM irrelevant - then multiboot will come in handy.

if you have a lot of testing to do, set up your own test environment. it's fun!

anyway, Vista "you asked for it ;)" Ultimate SP2 32-bit IE9 in crash recovery mode:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "Z:userDownloadsgil900.au3" /UserParams    
+>21:13:40 Starting AutoIt3Wrapper v.2.1.4.5 SciTE v.3.3.7.0   Keyboard:00000409  OS:WIN_VISTA/Service Pack 2  CPU:X64 OS:X86    Environment(Language:0409)
>Running:(3.3.10.2):C:Program FilesAutoIt3autoit3.exe "Z:userDownloadsgil900.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
"Z:userDownloadsgil900.au3" (46) : ==> Variable must be of type "Object".:
If $oIE.LocationURL <> $ActiveURL Then
If $oIE^ ERROR
->21:13:47 AutoIt3.exe ended.rc:1
+>21:13:47 AutoIt3Wrapper Finished..
>Exit code: 1    Time: 6.870

 

 

Oops .. I meant to put the lines 46-73 in

If IsObj($oIE) Then

EndIf

I guess that the IE frame didn't load right?

Is the following path is exist on your computer:
 

C:Program FilesInternet Exploreriexplore.exe

?

Can you check what value the function IECreatePseudoEmbedded() returned?

 

About what you say, I also do tests alone.
But I find it useful to use the community.
In such a situation the community gets something (a function that can be useful to someone) and I get tests and reports if the code works properly.

Everyone gets something ..

 

EDIT:

Please test this code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#include <WinAPIEx.au3>
#include <IE.au3>
#Include <Array.au3>

#AutoIt3Wrapper_Run_AU3Check=n

Test("http://www.autoitscript.com/site/")


Func Test($Url)
    Local $Form1 , $Button1 , $IE_Pid , $Close_Button , $IECreatePseudo , $oIE , $aMain , $nMsg
    Local $ActiveURL = $Url , $GetActiveURL = 0 , $Open_Button , $o_Shell , $o_ShellWindows , $Founnd_oIE

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("", 915, 664)
    $Close_Button = GUICtrlCreateButton("Close", 488, 632, 89, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Open_Button = GUICtrlCreateButton("Open in browser", 328, 632, 105, 25)
    GUICtrlSetState (-1,$GUI_DISABLE)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
;~     WinSetOnTop($Form1, "", 1)
    Local $IEWidth = 897 , $IEHeight = 617
    $IECreatePseudo = IECreatePseudoEmbedded($Url, $Form1, 8, 8, 897, 617)
    If IsArray($IECreatePseudo) Then
        $oIE = $IECreatePseudo[0]
        $aMain = $IECreatePseudo[1]
        If IsObj($oIE) Then
            GUICtrlSetState($Open_Button,$GUI_ENABLE)
            $GetActiveURL = 1
;~          _IEAction($oIE, "focus" )
;           http://msdn.microsoft.com/en-us/library/ms970456.aspx

            $oIE.StatusBar = True
            $oIE.Focus()
        EndIf
    EndIf
    #endregion ### END Koda GUI section ###
;~     WinSetOnTop($Form1, "", 1)
    While 1
        If IsObj($oIE) Then
            If $oIE.LocationURL <> $ActiveURL Then
                If $oIE.LocationURL <> "about:blank" Then
                    $ActiveURL = $oIE.LocationURL
                    $GetActiveURL = 1
                Else
                    $o_Shell = ObjCreate("Shell.Application")
                    $o_ShellWindows = $o_Shell.Windows()
                    $Founnd_oIE = False
                    For $o_window In $o_ShellWindows

                        If $o_window.FullScreen = True And $o_window.Width = $IEWidth And $o_window.Height = $IEHeight Then
                            $oIE = $o_window
                            $ActiveURL = $oIE.LocationURL
                            $GetActiveURL = 1
                            $Founnd_oIE = True
                            ConsoleWrite("Fixed:"&@CRLF) ; < --------------- Debug line
                            ExitLoop
                        EndIf
                    Next
                    If Not $Founnd_oIE Or $ActiveURL = "about:blank" Then
                        GUICtrlSetState($Open_Button,$GUI_DISABLE)
                        $GetActiveURL = 0
                    EndIf
                EndIf
                $oIE.StatusBar = True
                If $GetActiveURL = 1 Then GUICtrlSetState($Open_Button,$GUI_ENABLE)
                ConsoleWrite($ActiveURL&@CRLF) ; < --------------- Debug line
            EndIf
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE , $Close_Button
                ;ContinueLoop
                If IsObj($oIE) And IsArray($aMain) Then
                    WinClose($aMain[1])
                    _IEQuit($oIE)
                    If ProcessWaitClose($aMain[0],2) = 0 Then ProcessClose($aMain[0])
                EndIf
                ;IECreatePseudoEmbedded_CloseAllIEs($IEWidth,$IEHeight) ; If another iexplore.exe process that created with IECreatePseudoEmbedded() is still
                ;                                                       running for some for some reson reason, then that process should be closed now.
                ;                                                   ******** This function is not working. Please write working function  and share it with me ********
                ExitLoop
            Case $Open_Button
;~                 WinSetOnTop($Form1, "", 0)
                ShellExecute($ActiveURL)
        EndSwitch
    WEnd
    GUIDelete($Form1)
EndFunc





; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded
; Description ...: Create IE frame in GUI with the laset IE verison that installed on the computer
; Syntax ........: IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height[, $wait = 5000])
; Parameters ....: $sURL                - The URL to load.
;                  $h_Parent            - The handle of the GUI to create the IE frame in..
;                  $i_Left              - X pos.
;                  $i_Top               - Y Pos
;                  $i_Width             - The width of the frame.
;                  $i_Height            - The height of the frame.
;                  $wait                - [optional] max time to wait for the page to load. Default is 5000 ms.
; Return values .: If error:
;                   -1 = can't open internet explorer
;                   -2 = loading time limit reached
;                   -3 = object error occurred
;               .: Id not error:
;                   Array Variable:
;                       [0] = $o_object - Object variable of an InternetExplorer.Application, Window or Frame object
;                           the Object is for IE functions in IE.au3
;                       [1] = Another array:
;                               [0] = the pid of the IE frame
;                               [1] = the handle of the IE frame
; Author ........: gil900
; Modified ......: Yes and No ;)
; Inspired from .: http://www.autoitscript.com/forum/topic/152173-pseudo-embed-google-chrome/
;                  http://www.autoitscript.com/forum/topic/138980-iecreatepseudoembedded/
;                  http://www.autoitscript.com/forum/topic/99234-iecreate2/#entry712594
;                  AutoIt3\Include\IE.au3

; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: yes
;
; ===============================================================================================================================
Func IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height, $wait = 5000)
    Local $Output[2] = [-1,-1] , $acMain[2] , $o_IE , $timer , $GIECPE_Edit1 , $pid , $o_Shell , $o_ShellWindows , $o_window
    $GIECPE_Edit1 = GUICtrlCreateEdit("loading...", $i_Left, $i_Top, $i_Width, $i_Height,$ES_READONLY+$ES_CENTER)
    GUICtrlSetFont(-1, 35, 400, 2, "Tahoma")
    GUICtrlSetColor(-1, 0x646464)
    $pid = ShellExecute(@HomeDrive&"\Program Files\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)
    If $pid = 0 Then
        GUICtrlSetData($GIECPE_Edit1, "Error in opening Internet Explorer")
        Return -1
    EndIf
    $timer = TimerInit()
    While 1
        If TimerDiff($timer) >= $wait Then
            GUICtrlSetData($GIECPE_Edit1, "Error: loading time limit reached")
            ProcessClose($pid)
;~          IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
            Return -2
        EndIf
        $o_Shell = ObjCreate("Shell.Application")
        $o_ShellWindows = $o_Shell.Windows()
        For $o_window In $o_ShellWindows
            If $o_window.LocationURL = $sURL Then
                $o_IE = $o_window
                $Output[0] = $o_IE
                ExitLoop 2
            EndIf
        Next
    WEnd
    If Not IsObj($o_IE) Then
        GUICtrlSetData($GIECPE_Edit1, "Error: object error occurred")
;~      IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
        Return -3
    EndIf
    $acMain[1] = _IEPropertyGet($o_IE, "hwnd")
    $acMain[0] = WinGetProcess($acMain[1])
    $Output[1] = $acMain
    GUISetState(@SW_HIDE, $h_Parent)
    GUICtrlDelete($GIECPE_Edit1)
    _WinAPI_SetParent($acMain[1], $h_Parent)
    _WinAPI_SetWindowLong($acMain[1], $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
    GUISetState(@SW_SHOW, $h_Parent)
    ControlMove($acMain[1], "", "", $i_Left + 1, $i_Top + 1, $i_Width , $i_Height)
    WinActivate($acMain[1])
    Return $Output
EndFunc



; ********************* This function is not working.... I hope someone else will write working function  *******************
; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded_CloseAllIEs
; Description ...: This function will close any iexplore.exe process that started with IECreatePseudoEmbedded()
;                   The function know what iexplore.exe process to close According to the Width , Height of the embedded frame.
;                   In order that the function will performs the action correctly, you need to call to the function with the same $i_Width , $i_Height
;                   values that used in IECreatePseudoEmbedded().

; Syntax ........: IECreatePseudoEmbedded_CloseAllIEs($i_Width, $i_Height)
; Parameters ....: $i_Width             - An integer value.
;                  $i_Height            - An integer value.
; Return values .: None
; Author ........: gil900
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
;~ Func IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height)

;~  ConsoleWrite($i_Width&@CRLF)
;~  Return
;~  Local $o_Shell , $o_ShellWindows , $i_Width2 = $i_Width-44 , $i_Height2 = $i_Height-17 , $IsIe , $pid
;~  ConsoleWrite($i_Width&" , "&$i_Height2&@CRLF)
;~  Return

;~  $o_Shell = ObjCreate("Shell.Application")
;~  $o_ShellWindows = $o_Shell.Windows()
;~  For $o_window In $o_ShellWindows
;~      $IsIe = False
;~      ConsoleWrite($o_window.Width&" , "&$o_window.Height&@CRLF)
;~      If  $o_window.Width = $i_Width And $o_window.Height = $i_Height Then
;~          $IsIe = True
;~      ElseIf $o_window.Width = $i_Width2 And $o_window.Height = $i_Height2 Then
;~          $IsIe = True
;~      EndIf
;~      If $IsIe Then
;~          $pid = WinGetProcess(HWnd($o_window.HWnd()))
;~          ConsoleWrite($pid&@CRLF)
;~          _IEQuit($o_window)


;~      EndIf
;~  Next
;~ EndFunc
; ********************* This function is not working.... I hope someone else will write working function  *******************

 

Edited by Guest
Link to comment
Share on other sites

Thanks for the reports!

I updated the code to new version. this is the new code(the new code is also in #1)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

#include <WinAPIEx.au3>
#include <IE.au3>
#Include <Array.au3>

#AutoIt3Wrapper_Run_AU3Check=n

Test("http://www.autoitscript.com/site/")


Func Test($Url)
    Local $Form1 , $Close_Button , $IECreatePseudo , $oIE , $aMain , $nMsg , $IELoaded
    Local $ActiveURL = $Url , $Open_Button , $o_Shell , $o_ShellWindows , $Founnd_Url , $OpenButtonSate

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("", 915, 664)
    $Close_Button = GUICtrlCreateButton("Close", 488, 632, 89, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Open_Button = GUICtrlCreateButton("Open in browser", 328, 632, 105, 25)
    GUICtrlSetState (-1,$GUI_DISABLE)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
;~     WinSetOnTop($Form1, "", 1)
    Local $IEWidth = 897 , $IEHeight = 617
    $IECreatePseudo = IECreatePseudoEmbedded($Url, $Form1, 8, 8, 897, 617,8000)
    If IsArray($IECreatePseudo) Then
        $oIE = $IECreatePseudo[0]
        $aMain = $IECreatePseudo[1]
        If IsObj($oIE) Then
            GUICtrlSetState($Open_Button,$GUI_ENABLE)
            $OpenButtonSate = 1
            $IELoaded = 1
;~          _IEAction($oIE, "focus" )
;           http://msdn.microsoft.com/en-us/library/ms970456.aspx

            $oIE.StatusBar = True
            $oIE.Focus()
        EndIf
    EndIf
    #endregion ### END Koda GUI section ###
;~     WinSetOnTop($Form1, "", 1)
    While 1
        If $IELoaded = 1 Then
            If $oIE.LocationURL <> $ActiveURL Then
                If StringLeft($oIE.LocationURL,4) = "http" Then
                    $ActiveURL = $oIE.LocationURL
                    If $OpenButtonSate = 0 Then
                        GUICtrlSetState($Open_Button,$GUI_ENABLE)
                        $OpenButtonSate = 1
                    EndIf
                Else
                    $o_Shell = ObjCreate("Shell.Application")
                    $o_ShellWindows = $o_Shell.Windows()
                    $Founnd_Url = 0
                    For $o_window In $o_ShellWindows
                        If $o_window.FullScreen = True And $o_window.Width = $IEWidth And $o_window.Height = $IEHeight Then
                            $oIE = $o_window
                            If StringLeft($oIE.LocationURL,4) = "http" Then
                                $ActiveURL = $oIE.LocationURL
                                If $OpenButtonSate = 0 Then
                                    GUICtrlSetState($Open_Button,$GUI_ENABLE)
                                    $OpenButtonSate = 1
                                EndIf
                                $Founnd_Url = 1
                                ConsoleWrite("Fixed:"&@CRLF) ; < --------------- Debug line
                            EndIf
                            ExitLoop
                        EndIf
                    Next
                    If $Founnd_Url = 0 And $OpenButtonSate = 1 Then
                        GUICtrlSetState($Open_Button,$GUI_DISABLE)
                        $OpenButtonSate = 0
                    EndIf
                EndIf
                $oIE.StatusBar = True
                ConsoleWrite($ActiveURL&@CRLF) ; < --------------- Debug line
            EndIf
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE , $Close_Button
                ;ContinueLoop
                If $IELoaded = 1 And IsArray($aMain) Then
                    WinClose($aMain[1])
                    _IEQuit($oIE)
                    If ProcessWaitClose($aMain[0],2) = 0 Then ProcessClose($aMain[0])
                EndIf
                ;IECreatePseudoEmbedded_CloseAllIEs($IEWidth,$IEHeight) ; If another iexplore.exe process that created with IECreatePseudoEmbedded() is still
                ;                                                       running for some for some reson reason, then that process should be closed now.
                ;                                                   ******** This function is not working. Please write working function  and share it with me ********
                ExitLoop
            Case $Open_Button
;~                 WinSetOnTop($Form1, "", 0)
                ShellExecute($ActiveURL)
        EndSwitch
    WEnd
    GUIDelete($Form1)
EndFunc





; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded
; Description ...: Create IE frame in GUI with the laset IE verison that installed on the computer
; Syntax ........: IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height[, $wait = 5000])
; Parameters ....: $sURL                - The URL to load.
;                  $h_Parent            - The handle of the GUI to create the IE frame in..
;                  $i_Left              - X pos.
;                  $i_Top               - Y Pos
;                  $i_Width             - The width of the frame.
;                  $i_Height            - The height of the frame.
;                  $wait                - [optional] max time to wait for the page to load. Default is 5000 ms.
; Return values .: If error:
;                   -1 = can't open internet explorer
;                   -2 = loading time limit reached
;                   -3 = object error occurred
;               .: Id not error:
;                   Array Variable:
;                       [0] = $o_object - Object variable of an InternetExplorer.Application, Window or Frame object
;                           the Object is for IE functions in IE.au3
;                       [1] = Another array:
;                               [0] = the pid of the IE frame
;                               [1] = the handle of the IE frame
; Author ........: gil900
; Modified ......: Yes and No ;)
; Inspired from .: http://www.autoitscript.com/forum/topic/152173-pseudo-embed-google-chrome/
;                  http://www.autoitscript.com/forum/topic/138980-iecreatepseudoembedded/
;                  http://www.autoitscript.com/forum/topic/99234-iecreate2/#entry712594
;                  AutoIt3\Include\IE.au3

; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: yes
;
; ===============================================================================================================================
Func IECreatePseudoEmbedded($sURL, $h_Parent, $i_Left, $i_Top, $i_Width, $i_Height, $wait = 5000)
    Local $Output[2] = [-1,-1] , $acMain[2] , $o_IE , $timer , $GIECPE_Edit1 , $pid , $o_Shell , $o_ShellWindows , $o_window
    $GIECPE_Edit1 = GUICtrlCreateEdit("loading...", $i_Left, $i_Top, $i_Width, $i_Height,$ES_READONLY+$ES_CENTER)
    GUICtrlSetFont(-1, 35, 400, 2, "Tahoma")
    GUICtrlSetColor(-1, 0x646464)
    $pid = ShellExecute(@HomeDrive&"\Program Files\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)
    If $pid = 0 Then
        GUICtrlSetData($GIECPE_Edit1, "Error in opening Internet Explorer")
        Return -1
    EndIf
    $timer = TimerInit()
    While 1
        If TimerDiff($timer) >= $wait Then
            GUICtrlSetData($GIECPE_Edit1, "Error: loading time limit reached")
            ProcessClose($pid)
;~          IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
            Return -2
        EndIf
        $o_Shell = ObjCreate("Shell.Application")
        $o_ShellWindows = $o_Shell.Windows()
        For $o_window In $o_ShellWindows
            If $o_window.LocationURL = $sURL Then
                $o_IE = $o_window
                $Output[0] = $o_IE
                ExitLoop 2
            EndIf
        Next
    WEnd
    If Not IsObj($o_IE) Then
        GUICtrlSetData($GIECPE_Edit1, "Error: object error occurred")
;~      IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height) ; ***** IECreatePseudoEmbedded_CloseAllIEs is not working. Please write working function  and share it with me ********
        Return -3
    EndIf
    $acMain[1] = _IEPropertyGet($o_IE, "hwnd")
    $acMain[0] = WinGetProcess($acMain[1])
    $Output[1] = $acMain
    GUISetState(@SW_HIDE, $h_Parent)
    GUICtrlDelete($GIECPE_Edit1)
    _WinAPI_SetParent($acMain[1], $h_Parent)
    _WinAPI_SetWindowLong($acMain[1], $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
    GUISetState(@SW_SHOW, $h_Parent)
    ControlMove($acMain[1], "", "", $i_Left + 1, $i_Top + 1, $i_Width , $i_Height)
    WinActivate($acMain[1])
    Return $Output
EndFunc



; ********************* This function is not working.... I hope someone else will write working function  *******************
; #FUNCTION# ====================================================================================================================
; Name ..........: IECreatePseudoEmbedded_CloseAllIEs
; Description ...: This function will close any iexplore.exe process that started with IECreatePseudoEmbedded()
;                   The function know what iexplore.exe process to close According to the Width , Height of the embedded frame.
;                   In order that the function will performs the action correctly, you need to call to the function with the same $i_Width , $i_Height
;                   values that used in IECreatePseudoEmbedded().

; Syntax ........: IECreatePseudoEmbedded_CloseAllIEs($i_Width, $i_Height)
; Parameters ....: $i_Width             - An integer value.
;                  $i_Height            - An integer value.
; Return values .: None
; Author ........: gil900
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
;~ Func IECreatePseudoEmbedded_CloseAllIEs($i_Width,$i_Height)

;~  ConsoleWrite($i_Width&@CRLF)
;~  Return
;~  Local $o_Shell , $o_ShellWindows , $i_Width2 = $i_Width-44 , $i_Height2 = $i_Height-17 , $IsIe , $pid
;~  ConsoleWrite($i_Width&" , "&$i_Height2&@CRLF)
;~  Return

;~  $o_Shell = ObjCreate("Shell.Application")
;~  $o_ShellWindows = $o_Shell.Windows()
;~  For $o_window In $o_ShellWindows
;~      $IsIe = False
;~      ConsoleWrite($o_window.Width&" , "&$o_window.Height&@CRLF)
;~      If  $o_window.Width = $i_Width And $o_window.Height = $i_Height Then
;~          $IsIe = True
;~      ElseIf $o_window.Width = $i_Width2 And $o_window.Height = $i_Height2 Then
;~          $IsIe = True
;~      EndIf
;~      If $IsIe Then
;~          $pid = WinGetProcess(HWnd($o_window.HWnd()))
;~          ConsoleWrite($pid&@CRLF)
;~          _IEQuit($o_window)


;~      EndIf
;~  Next
;~ EndFunc
; ********************* This function is not working.... I hope someone else will write working function  *******************
Link to comment
Share on other sites

code from post #7 OK on:

Windows Vista Ultimate 32-bit SP2 IE9

Windows 2008 Server 32-bit SP2 IE9

Windows 8 Pro 64-bit IE10

(all compiled to exe in AutoIt 3.3.10.2 + SciTe 3.4.1)

also, for obvious reasons, i think you should replace this:

$pid = ShellExecute(@HomeDrive&"\Program Files\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)

with this:

$pid = ShellExecute(@ProgramFilesDir&"\Internet Explorer\iexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Thanks for the reports

 

Single error when Close button is clicked.

--> IE.au3 T3.0-1 Error from function _IEQuit, $_IEStatus_InvalidObjectType

It is not expected .. but usually it does not happen right?
In any case, IE should be closed
even if get this error because  WinClose($aMain[1]) and If ProcessWaitClose($aMain[0],2) = 0 Then ProcessClose($aMain[0])

I'll fix something in the next version to be less likely to receive this error

 


 

 

code from post #7 OK on:

Windows Vista Ultimate 32-bit SP2 IE9

Windows 2008 Server 32-bit SP2 IE9

Windows 8 Pro 64-bit IE10

(all compiled to exe in AutoIt 3.3.10.2 + SciTe 3.4.1)

also, for obvious reasons, i think you should replace this:

$pid = ShellExecute(@HomeDrive&"Program FilesInternet Exploreriexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)

with this:

$pid = ShellExecute(@ProgramFilesDir&"Internet Exploreriexplore.exe","-k "&$sURL,"","",@SW_MINIMIZE)

 

In windows 64bit, @ProgramFilesDir is "Program Files (x86)" and not "Program Files"

and in 64bit, the code not working as it should with the x86 version of internet explorer.

I tested it out. There is a reason why I wrote it that way

Edited by Guest
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...