Sign in to follow this  
Followers 0
Crazyace

_IECreate hidden IE Window in IE9 fails

18 posts in this topic

When I try simple code like

#include <IE.au3>
$oIE = _IECreate("http://sourceforge.net", 0, 0)

It fails to hide. Any ideas?


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Bug submitted #2194

Edited by Crazyace

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

Looks fine to me on IE9, Win7, Au3 3.3.8.1 x64/x86.

You have to provide more details so other people can reproduce it.

AdmiralAlkex,

Thats the problem, you can see it :-) With the options that I'm using it should be hidden :-)


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

AdmiralAlkex,

When I try to run it from SciTE4AutoIt3 I get this error in the Console

C:Program FilesAutoIt3IncludeIE.au3 (560) : ==> The requested action with this object has failed.:
WEnd
WEnd^ ERROR

My test file

#cs ----------------------------------------------------------------------------


AutoIt Version: 3.3.8.1
Author:      myName

Script Function:
Template AutoIt script.


#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here


#include <IE.au3>

$oIE = _IECreate("http://sourceforge.net", 0, 0)
Edited by Crazyace

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

That's a different problem than the original problem.

I ran your code on my system, Win 7 x64 and IE 8 (no access to IE9 here) and it works without a problem, the IE window is hidden.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

That's a different problem than the original problem.

I ran your code on my system, Win 7 x64 and IE 8 (no access to IE9 here) and it works without a problem, the IE window is hidden.

Thanks for your reply BrewManNH. The system I'm using is Windows 7 x86 and I'm going to try uninstalling IE9 and try IE8. I tried the same code on my other desktop that has IE9 and WIndows 7 x64 and it did the same thing.

Any ideas about the error in the console?


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

I tested with IE8 now and I still have the same issue ;)


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

#10 ·  Posted

Which issue? It isn't hidden or the Wend error message?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#11 ·  Posted

The Wend seems to be the issue causing it not to hide for me. The IE.au3 file has not been touched by me.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

#13 ·  Posted

I haven't tried Beta, but I did reinstall AutoIT on my desktop system and it works fine with IE9. I'm going to see if reinstalling on my laptop will resolve the issue for me.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

#14 ·  Posted

I just reinstalled AutoIT and installed the full version of SciTE. I tried to run the file again and it still fails.

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Usersjeff_tincherDesktopAU3 AutoSweettest.au3" /UserParams   
+>13:43:39 Starting AutoIt3Wrapper v.2.1.0.8    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86)
>Running AU3Check (1.54.22.0)  from:C:Program FilesAutoIt3
+>13:43:39 AU3Check ended.rc:0
>Running:(3.3.8.1):C:Program FilesAutoIt3autoit3.exe "C:Usersjeff_tincherDesktopAU3 AutoSweettest.au3"   
C:\Program Files\AutoIt3\Include\IE.au3 (560) : ==> The requested action with this object has failed.:
WEnd
WEnd^ ERROR
->13:43:39 AutoIT3.exe ended.rc:1
>Exit code: 1    Time: 1.576

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

#15 ·  Posted

I think it's related to a Trak issue that's been reported previously, not sure if there's a work-around yet.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#16 ·  Posted

I just tried AutoIT beta and 1/2 of it works. When I launch the code it starts 3 iexplore.exe processes and shows the webpage.

I changed the code to:

#include <IE.au3>

$oIE = _IECreate("www.google.com", 0, 0)
Sleep(5000)
_IEQuit($oIE)

I noticed that the _IEQuit never kills the process. If I close the process via task manager when I open IE I get - "Your last browsing session closed unexpectedly"


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

#17 ·  Posted

Posting info from my desktop that the code works fine on.

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:UsersJeffDesktopNew AutoIt v3 Script.au3" /UserParams   
+>14:03:15 Starting AutoIt3Wrapper v.2.1.0.8    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:C:Program Files (x86)AutoIt3
+>14:03:15 AU3Check ended.rc:0
>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:UsersJeffDesktopNew AutoIt v3 Script.au3"   
+>14:03:21 AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 6.999

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites

#18 ·  Posted

I found out that it's that damn UAC that's causing an issue here.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • tarretarretarre
      _IEEmbedded2! UDF
      By tarretarretarre
      Yet another IE UDF, but this time I "covered all angels" to make it as close to "embedded" as possible, the biggest inspiration came from Dale
      Anyway, one of the issues with the other "snipplets\UDF's" is that $WS_POPUP style will cause other Windows to overlap, even though you clicked on the GUI's "Embedded window". see picture:

      This issue is solved, but there is an option to disable it, if the user want
      One more small issue with others IE Embedded UDF's is that implementation should not be so much different than the original implementation was. I am not ranting, I am just speaking for my mind.
      So here we go:
      This is how the classic _IeCreateEmbedded() implementation goes down
      #include <IE.au3> Local $hGUI = GUICreate("_IECreateEmbedded", 800, 600) Local $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 0, 0, 800, 600) GUISetState() _IENavigate($oIE, "https://www.google.se") While GUIGetMsg() <> - 3 wend and this is how _IeCreateEmbedded2() is implemented
      #include <IE.au3> #include <_IECreateEmbedded2.au3> Local $hGUI = GUICreate("_IECreateEmbedded", 800, 600) Local $oIE = _IEEmbedded2_Create($hGUI, 0, 0, 800, 600) GUISetState() _IENavigate($oIE, "https://www.google.se") While GUIGetMsg() <> - 3 wend The only downside with this implementation is that _IECreateEmbedded2() is not an GUI control, it only has our Com Object, so I added basic manipulation.
      I will change \ add more options based on user requests or if I feel like it.
      _IEEmbedded2_Move($iLeft, $iTop, $iWidth = Default, $iHeight = Default) ;Similar to AutoIT's WinMove _IEEmbedded2_Hide() _IEEmbedded2_Show()
      Here is a GUI example with different options, so you can test some of the functionality
       Example.au3
      #include <_IEEmbedded2.au3> Local $hGUI = GUICreate("_IEEmbedded2 Example Gui", 1575, 600) Local $iDMove = GUICtrlCreateButton("Move", 0, 0, 225, 50) Local $iDHide = GUICtrlCreateButton("Hide", 225, 0, 225, 50) Local $iDShow = GUICtrlCreateButton("Show", 450, 0, 225, 50) Local $iDnav = GUICtrlCreateButton("Navigate", 675, 0, 225, 50) Local $iDestroy = GUICtrlCreateButton("Destroy", 900, 0, 225, 50) Local $iDCreate = GUICtrlCreateButton('Create with ($iCmdLine = "-extoff -private")', 1125, 0, 225, 50) Local $iDCreateNoWsChildOnBlur = GUICtrlCreateButton("Create with ($iWsChildOnBlurMS = 0)", 1350, 0, 225, 50) Local $oIE = _IEEmbedded2_Create($hGUI, 0, 50, 1575, 550, "http://www.google.se/", Default, Default, Default) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _IEQuit($oIE) Exit Case $iDMove _IEEmbedded2_Move(Random(0, 10, 1), Random(50, 60, 1)) If @error Then MsgBox(0, "Error", "Failed to move window") Case $iDHide _IEEmbedded2_Hide() If @error Then MsgBox(0, "Error", "Failed to hide window") Case $iDShow _IEEmbedded2_Show() If @error Then MsgBox(0, "Error", "Failed to show window") Case $iDnav If IsObj($oIE) Then _IENavigate($oIE, "https://www.autoitscript.com/site/") Else MsgBox(0, "Error", "Failed to navigate") EndIf Case $iDestroy If IsObj($oIE) Then _IEQuit($oIE) ___IEEmbedded2_Data(0, 0, 0, 0); only required if $iWsChildOnBlurMS = 0 Else MsgBox(0, "Error", "Failed to destroy object.") EndIf Case $iDCreate Local $tmpOie = _IEEmbedded2_Create($hGUI, 0, 50, 1575, 550, "https://www.google.com/", "-extoff -private", Default, Default) If Not @error Then $oIE = $tmpOie Else MsgBox(0, "Error", "Failed to _IEEmbedded2_Create, error code: "&@error) EndIf Case $iDCreateNoWsChildOnBlur Local $tmpOie = _IEEmbedded2_Create($hGUI, 0, 50, 1575, 550, Default, Default, Default, 0) If Not @error Then $oIE = $tmpOie Else MsgBox(0, "Error", "Failed to _IEEmbedded2_Create, error code: "&@error) EndIf EndSwitch WEnd
       _IEEmbedded2.au3
      #include-once #include <IE.au3> #include <WinAPI.au3> #include <GuiConstants.au3> Opt("WinWaitDelay", 1) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IEEmbedded2_Create ; Description ...: Creates an "embedded Internet Explorer window" for a parent window (E.ex GuiCreate), and returns a webbrowser object refrence which can be used with _IE* Functions ; Syntax ........: _IEEmbedded2_Create($hWndParent, $iLeft, $iTop, $iWidth, $iHeight, $iCmdLine = Default, $iTimeoutMS = Default, $iWsChildOnBlurMS = Default) ; Parameters ....: $hWndParent - The handle of the window you would like to embed internet explorer in ; $iLeft - X1 ; $iTop - Y1 ; $iWidth - X2 ; $iHeight - Y2 ; $iDefaultPage - [optional] Default page on launch, _IeNavigate will be used as soon as the object exists and the script does not wait for the page to load (Default = about:blank) ; $iCmdLine - [optional] Parameters passed when starting Iexplore, see remarks. (Default = "") ; $iTimeoutMS - [optional] Max wait time in milliseconds before SetError, se @error 5 and 6. (Default = 30000 ms) ; $iWsChildOnBlurMS - [optional] How often in milliseconds we want to make sure $hParrent does not get overlapped by other Windows gui's, set 0 to disable (Default = 100 ms) ; Return values .: Success - a Webbrowser object reference. ; Failure - 0 and sets @error to non zero. ; Author ........: TarreTarreTarre ; Modified.......: ; Remarks .......: Max 1 instance is allowed. ; ; Set $iWsChildOnBlurMS to 0 if you do not wish to have $hWndChild altered when the $hWndParent is not active, this will however cause other windows to overlap your Gui and more. ; Also, if $iAdlibCalltime is 0, you have to manually reset _IEEmbedded2_Createdata's data if you want to invoke _IEEmbedded2_Create again. ; Use ___IEEmbedded2_Data(0, 0, 0, 0) to reset data ; ; For $iCmdLine, these commands are avilable -extoff, -framemerging, -noframemerging, -nohangrecovery, -private, -nosessionmerging And -sessionmerging ; Read more about Command-Line Options at https://msdn.microsoft.com/en-us/library/hh826025(v=vs.85).aspx ; Link ..........: ; Example .......: ; @error ........: 1 - $hWndParent is not a valid window handle. ; 2 - Iexplore.exe not found. ; 3 - Another instance of _IEEmbedded2_ is already running. ; 4 - $iCmdLine is provided with invalid parameters ; 5 - Load Wait Timeout, was not able to retrive Iexplore.exe window handle. ; 6 - (IE >= 10 only) Load Wait Timeout, failed to force $hWndChild into a minimized state. ; 7 - Windows API error, check @extended for more information Func _IEEmbedded2_Create($hWndParent, $iLeft, $iTop, $iWidth, $iHeight, $iDefaultPage = Default, $iCmdLine = Default, $iTimeoutMS = Default, $iWsChildOnBlurMS = Default) $iDefaultPage = ($iDefaultPage == Default ? "about:blank" : $iDefaultPage) $iCmdLine = ($iCmdLine == Default ? "" : StringRegExpReplace($iCmdLine, "([a-zA-Z]*)\s*[-]{1}", "$1 -")) $iTimeoutMS = ($iTimeoutMS == Default ? 30000 : $iTimeoutMS) $iWsChildOnBlurMS = ($iWsChildOnBlurMS == Default ? 100 : $iWsChildOnBlurMS) Local $sIexplorePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE", "") Local $sUrl = StringFormat("about:blank#%s", Chr(Random(65, 90, 1)) & Random(1, 100, 1)) If Not IsHWnd($hWndParent) Then Return SetError(1, 0, 0) If Not FileExists($sIexplorePath) Then Return SetError(2, 0, 0) If ___IEEmbedded2_IsInited() Then Return SetError(3, 0, 0) If Not StringRegExp($iCmdLine, _ "^((|-extoff|-framemerging|-noframemerging|-nohangrecovery|-private|-nosessionmerging|-sessionmerging)\s*){1,}+$") Then Return SetError(4, 0, 0) Local $Pid = Run(StringFormat("%s -k %s %s", $sIexplorePath, $iCmdLine, $sUrl), "", @SW_HIDE) Local $Timeout = TimerInit() Local $_IEErrorNotify = _IEErrorNotify(False) Do Local $oIE = _IEAttach($sUrl, "url") If TimerDiff($Timeout) > $iTimeoutMS Then _IEErrorNotify($_IEErrorNotify) ProcessClose($Pid) Return SetError(5, 0, 0) EndIf Sleep(0) Until IsObj($oIE) _IEErrorNotify($_IEErrorNotify) Local $hWndChild = _IEPropertyGet($oIE, "hwnd") _WinAPI_MoveWindow($hWndChild, -1000, -1000, -1000, -1000, True) _IENavigate($oIE, $iDefaultPage, 0) ;IEVer >= 10 needs to be minimized or it will not disappear from the taskbar @ windows 7 32\64 bit & mby other win vers. If Int(FileGetVersion($sIexplorePath)) >= 10 Then Do WinActivate($hWndChild, "") WinSetState($hWndChild, "", @SW_MINIMIZE) If TimerDiff($Timeout) > $iTimeoutMS Then ProcessClose($Pid) Return SetError(6, 0, 0) EndIf Until WinGetState($hWndChild) == 23 ; $WIN_STATE_EXISTS + $WIN_STATE_VISIBLE + $WIN_STATE_MINIMIZED EndIf _WinAPI_SetParent($hWndChild, $hWndParent) _WinAPI_MoveWindow($hWndChild, $iLeft, $iTop, $iWidth, $iHeight, True) _WinAPI_SetWindowLong($hWndChild, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) If @error Then SetExtended(1, _WinAPI_GetLastError()) ProcessClose($Pid) Return SetError(7, 1, 0) EndIf Local $aDimensions = [$iLeft, $iTop, $iWidth, $iHeight] ___IEEmbedded2_Data($hWndParent, $hWndChild, $aDimensions, $iWsChildOnBlurMS) If $iWsChildOnBlurMS Then AdlibRegister("___IEEmbedded2_WsChildOnBlur", $iWsChildOnBlurMS) EndIf Return $oIE EndFunc ;==>_IEEmbedded2_Create ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IEEmbedded2_Move ; Description ...: Moves a previously created _IEEmbedded2_Create window ; Syntax ........: _IEEmbedded2_Move($iLeft, $iTop, $iWidth = Default, $iHeight = Default) ; Parameters ....: $iLeft - X1 ; $iTop - Y1 ; $iWidth - X2 [optional] (Default = Original value) ; $iHeight - Y2 [optional] (Default = Original value) ; Return values .: Success - True ; Failure - 0 and sets @error to non zero. ; Author ........: TarreTarreTarre ; Modified.......: ; Remarks .......: Similar to AutoIt's WinMove ; Do not use this to "hide" objects, use _IEEmbedded2_Hide() instead ; Link ..........: ; Example .......: ; @error ........: 1 - _IEEmbedded2_Create is not invoked Func _IEEmbedded2_Move($iLeft, $iTop, $iWidth = Default, $iHeight = Default) Local $e = ___IEEmbedded2_Data() Local $hc = $e[1] Local $d = $e[2] Local $alr = $e[3] If Not IsHWnd($hc) Then Return SetError(1, 0, 0) $iWidth = ($iWidth == Default ? $d[2] : $iWidth) $iHeight = ($iHeight == Default ? $d[3] : $iHeight) _WinAPI_MoveWindow($hc, $iLeft, $iTop, $iWidth, $iHeight, True) Local $nd = [$iLeft, $iTop, $iWidth, $iHeight] ___IEEmbedded2_Data(Null, Null, $nd) If $alr Then AdlibRegister("___IEEmbedded2_WsChildOnBlur", $alr) Return True EndFunc ;==>_IEEmbedded2_Move ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IEEmbedded2_Hide ; Description ...: Hides a previously created _IEEmbedded2_Create window ; Syntax ........: _IEEmbedded2_Hide() ; Parameters ....: ; Return values .: Success - True ; Failure - 0 and sets @error to non zero. ; Author ........: TarreTarreTarre ; Modified.......: ; Remarks .......: ; Link ..........: ; Example .......: ; @error ........: 1 - _IEEmbedded2_Create is not invoked Func _IEEmbedded2_Hide() Local $e = ___IEEmbedded2_Data() Local $hc = $e[1] If Not IsHWnd($hc) Then Return SetError(1, 0, 0) _WinAPI_MoveWindow($hc, 0, 0, 0, 0, True) AdlibUnRegister("___IEEmbedded2_WsChildOnBlur") Return True EndFunc ;==>_IEEmbedded2_Hide ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IEEmbedded2_Show ; Description ...: Restore the window to its original size, a counter to _IEEmbedded2_Move() \ _IEEmbedded2_Hide() ; Syntax ........: _IEEmbedded2_Show() ; Parameters ....: ; Return values .: Success - True ; Failure - 0 and sets @error to non zero. ; Author ........: TarreTarreTarre ; Modified.......: ; Remarks .......: ; Link ..........: ; Example .......: ; @error ........: 1 - _IEEmbedded2_Create is not invoked Func _IEEmbedded2_Show() Local $e = ___IEEmbedded2_Data() Local $hc = $e[1] If Not IsHWnd($hc) Then Return SetError(1, 0, 0) Local $d = $e[2] Local $alr = $e[3] _WinAPI_MoveWindow($hc, $d[0], $d[1], $d[2], $d[3], True) If $alr Then AdlibRegister("___IEEmbedded2_WsChildOnBlur", $alr) Return True EndFunc ;==>_IEEmbedded2_Show #Region IECreateEmbedded2 Internals functions Func ___IEEmbedded2_Data($_hWndParent = Null, $_hWndChild = Null, $_aDimensions = Null, $_iWsChildOnBlurMS = Null) Local Static $hWndParent = 0 Local Static $hWndChild = 0 Local Static $aDimensions = 0 Local Static $iWsChildOnBlurMS = 0 If $_hWndParent <> Null Then $hWndParent = $_hWndParent If $_hWndChild <> Null Then $hWndChild = $_hWndChild If IsArray($_aDimensions) Then $aDimensions = $_aDimensions If $_iWsChildOnBlurMS <> Null Then $iWsChildOnBlurMS = $_iWsChildOnBlurMS Local $aRet = [$hWndParent, $hWndChild, $aDimensions, $iWsChildOnBlurMS] Return $aRet EndFunc ;==>___IEEmbedded2_Data Func ___IEEmbedded2_IsInited() Local $e = ___IEEmbedded2_Data() Return IsHWnd($e[1]) EndFunc ;==>___IEEmbedded2_IsInited Func ___IEEmbedded2_WsChildOnBlur() Local Static $p Local $c = 0 Local $e = ___IEEmbedded2_Data() Local $hp = $e[0] Local $hc = $e[1] If Not IsHWnd($hc) Then ___IEEmbedded2_Data(0, 0, 0, 0) Return AdlibUnRegister("___IEEmbedded2_WsChildOnBlur") EndIf If WinActive($hp) Or WinActive($hc) Then $c = 1 If $c And $p <> $c Then Local $gmp = _WinAPI_GetMousePos() Local $wfp = _WinAPI_WindowFromPoint($gmp) Local $gp = _WinAPI_GetParent($wfp) _WinAPI_SetWindowLong($hc, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) _WinAPI_UpdateWindow($hp) If $wfp <> $hp And $gp <> $hp Then WinActivate($hc) EndIf $p = $c ElseIf Not $c And $p <> $c Then _WinAPI_SetWindowLong($hc, $GWL_STYLE, $WS_CHILD + $WS_VISIBLE) _WinAPI_UpdateWindow($hp) $p = $c EndIf EndFunc ;==>___IEEmbedded2_WsChildOnBlur #EndRegion IECreateEmbedded2 Internals functions This is currently tested with (AutoIt v3.3.14.0):
      Windows 7 x86: Ie 8-9-10-11
      Windows 7 x64: Ie 8-9-10-11

      Error-report on this thread: IE version, @error code, Operationg system ex: (Windowx 10 64 bit)
       
      Trevlig Helg /Tarre
    • orichec
      IECreate not working using Excelsheet values
      By orichec
      Hello,
      I'm trying to save source of a particular webpage using its URL. When i tried to save source code using following command it works fine
      $IE = _IECreate( 'www.example.com', 0, 0 )
      But my problem is different I've saved different URL in my excel sheet, that's why, I tried to use "$IE" command in this way;
      $URL = _Excel_RangeCopyPaste($oWorkbook1.Activesheet, "C1")
      $IE = _IECreate($URL, 0, 0 )
      But It's unable to fetch source codes using URL placed in excel sheet 1 at cell No. "C1".
      Please guide me what's wrong with my codes and how can I make it possible to use URL placed in excel sheet instead of copying URL every time in "_IECreate" command.
      Thanks
      #RequireAdmin #include <Excel.au3> #include <IE.au3> #include <String.au3> #include <Array.au3> Local $oExcel = _Excel_Open() Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Software.csv", True) $file = fileopen(@scriptdir & "\source01.txt", 10) ;------------Below Command is not working--------------------- $URL = _Excel_RangeCopyPaste($oWorkbook1.Activesheet, "C1" ;------------String $IE unable to fetch data from URL available in excel sheet at cell No. "C1"--------------------- $IE = _IECreate($URL, 0, 0 ) $source = _IEDocReadHTML($IE) FileWrite($file, $source)  
    • Dgameman1
      Browser Object Creation Failed
      By Dgameman1
      My program is super simple with only 2 lines of code.
      #include <IE.au3> $Site = _IECreate("www.google.com", 0, 1, 1) I'm just trying to open up a browser that goes to google.com
      The issue with this is that whenever I try and run the program, I get this error
      Not sure how to go about fixing this issue?
    • computergroove
      Create a browser window and maximize it
      By computergroove
      #include <IE.au3> _IECreate("www.google.com") Sleep(5000) WinSetState("Google - Internet Explorer","",@SW_MAXIMIZE) The browser window opens and it goes to google.com but it will not maximize. I have also tried:
      #include <IE.au3> Local $Browser = _IECreate("www.google.com") Sleep(5000) WinSetState($Browser,"",@SW_MAXIMIZE) Also doesn't work. I'm running windows 8.1 x64 and internet explorer 11.0.9600.16384. Help!
    • Ascend4nt
      IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI)
      By Ascend4nt
      IE Embedded Control Versioning
      Use IE 9+ and HTML5 features inside a GUI

      This UDF allows the use of embedded IE controls which support IE versions greater than IE 7.  By default, all embedded IE controls default to IE 7 compatibility mode (unless for some reason somebody has IE 6 installed!), so its not possible to use most of the HTML5 features available today. Fortunately, IE 9 and greater allow the use of HTML5, and the embedded IE control actually supports it.  The problem is convincing Windows to let your program actually use those features!
      There are Registry branches that modify how an IE control works in specific programs.  Those branches are:
      HKCU\Software\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION In at least one of these branches, the executable name needs to appear as a value name ("autoit.exe" for example), and the value data needs to indicate what IE version to 'emulate'. The value data is actually dependent on the version and whether quirks-mode is enabled.
      See Web Browser Control - Specifying the IE Version for more information.
      Note that a 64-bit O/S needs adjustments to the HKLM paths.  Also, prefer the HKCU branch unless the program needs to enable access across all user accounts.

      HTML5 Canvas Element Example
      Anyway, all the complexity of setting the right value with the right name with the right 32/64-bit branch is handled for you in this UDF.  Enabling support for IE9+, and new HTML5 features, is as simple as making one call to _IE_EmbeddedSetBrowserEmulation().

      _IE_EmbeddedSetBrowserEmulation() takes an executable name (@AutoItExe if none is provided), and checks the Registry for an entry for it.  If it doesn't find one, it will create one and enable support for later versions of IE. The full parameters to the function are as follows:
       
      _IE_EmbeddedSetBrowserEmulation($nIEVersion, $bIgnoreDOCTYPE = True, $bHKLMBranch = False, $sExeName = @AutoItExe)  
      The parameter passed in $nIEVersion can be anything from 8 to 11 [or 12+ in the future], or just the current version of IE, which is available also through a call to _IE_EmbeddedGetVersion().  $bIgnoreDOCTYPE controls when IE will go into quirks mode based on any "<!DOCTYPE>" declarations on webpages. This mode can cause major problems, so by default it is set to ignore it (set this to False to enable it). $bHKLMBranch controls where in the registry the Browser Emulation Mode setting will be stored. If you wish to store the mode for ALL users, set this parameter to True. Note, however, that elevated privileges are required for modifying the HKLM branch!

      If the call to _IE_EmbeddedSetBrowserEmulation() is successful, then you can enable a (more) HTML5 compliant IE browser control in a GUI.

      The complete set of functions in the UDF:
      _IE_EmbeddedGetVersion()            ; Gets version of IE Embeddable Control (from ieframe.dll or Registry) _IE_EmbeddedGetBrowserEmulation()    ; Gets Browser Emulation Version for given Executable (or 0 if not found) _IE_EmbeddedSetBrowserEmulation()    ; Sets Browser Emulation Version. NOTE: HKLM branch REQUIRES ELEVATED PRIVILEGES! _
      IMPORTANT:
      Setting the embedded browser object to a newer version of IE may alter the behavior of some things.  See documenation for the HTMLDocumentEvents2 interface and HTMLAnchorEvents2 interface for example.
      Also, there is at least one difference in behavior noted by mesale0077 in working with IE10 (and possibly other versions of IE) - clicks for elements inside an <a> anchor tag will register as the actual internal element rather than the surrounding anchor. For example, an <img> element wrapped by an <a> anchor will only send the click to the <img> element and not propagate it any further. A workaround for this is to check the parentNode to see if it is an <a> element. See the discussion in the >ObjEvent dont work thread. It could be that there's some other reason for this behavior, but nothing has come to light yet.
      As an aside, also see trancexx's response in >ObjEvent usage for more techniques for capturing IE events.
      History:



      An example of HTML5 use, which has a little interactive Canvas, follows (requires IE9 or higher!):
       
      #include "IE_EmbeddedVersioning.au3" ; =============================================================================================================================== ; <IE_EmbeddedHTML5Example.au3> ; ; Example of using 'IE_EmbeddedVersioning' UDF ; ; This example 1st attempts to set the Browser Emulation information in the registry, then ; creates an embedded IE control with an interactive HTML5 Canvas element. ; ; Author: Ascend4nt ; =============================================================================================================================== #Region IE_CANVAS_EXAMPLE #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> ; ----------- ; GLOBALS ; ----------- Global $bMouseDown = False, $iLastX1 = 0, $iLastY1 = 0 Global $g_oCanvas, $g_oCtx Global $hGUI, $ctGUI_ErrMessageLabel Global $GUI_IE_Obj Global $nRet = _WinMain() ; Optionally remove valuename at Exit (not recommended if compiled to executable) ;~ _IE_EmbeddedRemoveBrowserEmulation() Exit $nRet ; ====================================================================================================== ; Embedded IE Browser-Emulation Fix + HTML5 Example ; ====================================================================================================== Func _WinMain()     ConsoleWrite("@AutoItX64 = " & @AutoItX64 & ", IsAdmin() = " & IsAdmin() & @CRLF)     ;; Get Current IE Embeddable Control Version (from ieframe.dll)     Local $sIEVer = _IE_EmbeddedGetVersion(), $nIEVer = @extended     ConsoleWrite("Embedded Version = " & $sIEVer & ", as Int: " & $nIEVer & ", @error = " & @error & @CRLF)     ; Old IE version w/o HTML5 support? Exit     If $nIEVer < 9 Then Return MsgBox(0, "Old IE Version", "IE version is less than 9, HTML5 example will not work")     ;; Current Browser Emulation Mode for this executable (if exists)     Local $nIEBEVer = _IE_EmbeddedGetBrowserEmulation()     ConsoleWrite("GetEmbeddedVersion: " & $nIEBEVer & ", @error = " & @error & ", @extended = " & @extended & @CRLF)     ;; Set Browser Emulation Mode for this executable (if not already set or set to a different version)     ; HKCU Branch:     _IE_EmbeddedSetBrowserEmulation()     ; HKLM Branch:     ;_IE_EmbeddedSetBrowserEmulation(-1, True, True)     If @error Then         ; -1 error means trying to access HKLM, so script needs elevation to access the Registry         If @error = -1 Then             If MsgBox(32 + 3, "Elevation Required", "Elevate script to enable setting Browser Emulation Mode?") = 6 Then Return _ReRunIfNotElevated()             Return 1         EndIf         Return MsgBox(0, "Error", "Couldn't set Browser Emulation mode")     EndIf     ;Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")     ;; Create Embedded Browser Control and GUI     Local $oIE = _IECreateEmbedded()     ; GUI (vars are Global)     $hGUI = GUICreate("Embedded Web control Test", 460, 360, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)     $GUI_IE_Obj = GUICtrlCreateObj($oIE, 10, 10, 440, 340)     $ctGUI_ErrMessageLabel = GUICtrlCreateLabel("", 100, 500, 500, 30)     GUICtrlSetColor(-1, 0xff0000)     GUISetState(@SW_SHOW) ;Show GUI     ; Doesn't work (at least for keyboard focus):     ;~ ControlFocus($hGUI, '', $GUI_IE_Obj)     ;; Initialize Embedded Control and write some HTML5 data to it     _IENavigate($oIE, 'about:blank' )     ; Basic Near-Empty HTML (with minimal CSS styling for Canvas element)     Local $sHTML = '<!DOCTYPE html>' & @CR & '<html>' & @CR & '<head>' & @CR & _         '<meta content="text/html; charset=UTF-8" http-equiv="content-type">' & @CR & _         '<title>Experiments</title>' & @CR & _         '<style>canvas { display:block; background-color:white; outline:#00FF00 dotted thin;}</style>' & @CR & _         '</head>' & @CR & '<body>' & @CR & '</body>' & @CR & '</html>'     _IEDocWriteHTML($oIE, $sHTML)     _IEAction($oIE, "refresh")     ;; Setup Event Object Functions     Local $oEventsDoc = ObjEvent($oIE.document, "Event_", "HTMLDocumentEvents2")     #forceref $oEventsDoc ;~     ConsoleWrite("Obj Name = " & ObjName($oIE) & @CRLF) ;~     ConsoleWrite("Location = " & $oIE.document.location.pathname & @CRLF)     ; --------------------------------------------------------------------------------------     ; Create Canvas Element through the DOM (optionally just add it in the HTML5 above)     ; -------------------------------------------------     ; Note: Support in browsers, see "Can I use..."     ;     @ http://caniuse.com/#feat=canvas     ; and @ http://caniuse.com/#search=canvas     ; -------------------------------------------------     ; IE minimum is version 9+, 10+ has more features, but WebGL support requires version 11+     ; --------------------------------------------------------------------------------------     $g_oCanvas = $oIE.document.createElement("canvas")     $g_oCanvas.id = "myCanvas" ;~     ConsoleWrite("Canvas ID = " & $g_oCanvas.id & @CRLF)     $oIE.document.body.appendChild($g_oCanvas)     ; Optionally, if added already through the HTML5 text:     ;Local $g_oCanvas = _IEGetObjById($oIE, "myCanvas")     If @error Then Return MsgBox(0, "Error", "Error creating/accessing Canvas")     ;; Tweak Canvas Size, Move into View ;~     ConsoleWrite("window innerwidth = " & $oIE.document.parentWindow.innerWidth & @CRLF)     ;$oIE.document.parentWindow.scrollTo(0, 10)     $g_oCanvas.width = 420     $g_oCanvas.height = 320     ;ConsoleWrite("Canvas item offsetTop = " & $g_oCanvas.offsetTop & @CRLF)     $g_oCanvas.scrollIntoView()     ;; Grab the Canvas 2D Context     $g_oCtx = $g_oCanvas.getContext("2d")     ;; Example Drawing: Gradiant     Local $oGrad = $g_oCtx.createLinearGradient(0,0,0,60)     If IsObj($oGrad) Then         $oGrad.addColorStop(0, "red")         $oGrad.addColorStop(1, "blue")         $g_oCtx.fillStyle = $oGrad     EndIf     $g_oCtx.fillRect(0,0,419,60)     ;; Example Drawing: Text     $g_oCtx.font = "30px serif"     $g_oCtx.fillStyle = "white"     $g_oCtx.textBaseline = "top"     $g_oCtx.fillText("HTML5 Canvas Drawing!", 50, 10)     ;; Example Drawing: Circle, Line     $g_oCtx.beginPath()     $g_oCtx.arc(200, 100, 20, 0, ACos(-1) * 2)     $g_oCtx.fillStyle = "red"     $g_oCtx.fill()     $g_oCtx.beginPath()     $g_oCtx.lineWidth = "3"     $g_oCtx.strokeStyle = "green"     $g_oCtx.moveTo(185, 85)     $g_oCtx.lineTo(215, 115)     $g_oCtx.stroke()     ; Waiting for user to close the window     While GUIGetMsg() <> $GUI_EVENT_CLOSE         Sleep(10)     WEnd     GUIDelete() EndFunc ; ====================================================================================================== ; IE Event Functions - React to Mouse events with some Canvas graphics ; ====================================================================================================== #Region IE_EVENT_FUNCS ; For right-click, the context menu pops up, UNLESS we change the Event's 'returnValue' property Volatile Func Event_oncontextmenu($oEvtObj)     If IsObj($oEvtObj) Then         ; Convert to string so that 0 doesn't match EVERY string         Local $sId = $oEvtObj.srcElement.id & ""         If ($sId = "myCanvas") Then $oEvtObj.returnValue = False     EndIf EndFunc Volatile Func Event_onmousedown($oEvtObj)     If IsObj($oEvtObj) And IsObj($g_oCtx) Then         ; Map click coordinates to Canvas coordinates         $iLastX1 = $oEvtObj.x - $g_oCanvas.offsetLeft         $iLastY1 = $oEvtObj.y - $g_oCanvas.offsetTop ;~         ConsoleWrite("Downclick recvd at X1: " & $iLastX1 & ", Y1: " & $iLastY1 & ", MouseButton [1 = left, 2 = right, etc] = " & $oEvtObj.button & @CRLF)         ; Check if click was in fact within Canvas element         If $iLastX1 >= 0 And $iLastX1 < $g_oCanvas.width And $iLastY1 >= 0 And $iLastY1 < $g_oCanvas.height Then             ; Signal mouse-down occurred inside Canvas             $bMouseDown = 1             ; Make a small square where initial down-click was detected             $g_oCtx.fillStyle = "blue"             $g_oCtx.fillRect($iLastX1 - 2, $iLastY1 - 2, 3, 3)         EndIf     EndIf EndFunc Volatile Func Event_onmouseup($oEvtObj)     If IsObj($oEvtObj) And IsObj($g_oCtx) Then ;~         ConsoleWrite("MouseUp" & @LF)         If $bMouseDown Then             Local $iX = $oEvtObj.x - $g_oCanvas.offsetLeft, $iY = $oEvtObj.y - $g_oCanvas.offsetTop             ; Random color in "#0f1100" (RGB) string form             Local $sColor = "#" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2)             ;; Draw either a line or circle depending on where the mouse button is released             If $iX = $iLastX1 And $iY = $iLastY1 Then                 ; Circle if mouse start = mouse end                 $g_oCtx.beginPath()                 $g_oCtx.arc($iX, $iY, 8, 0, ACos(-1) * 2)                 $g_oCtx.fillStyle = $sColor                 $g_oCtx.fill()             Else                 ; Line if mouse start <> mouse end                 $g_oCtx.beginPath()                 $g_oCtx.lineWidth = "3"                 $g_oCtx.strokeStyle = $sColor                 $g_oCtx.moveTo($iLastX1, $iLastY1)                 $g_oCtx.lineTo($iX, $iY)                 $g_oCtx.stroke()             EndIf             $bMouseDown = 0         EndIf     EndIf EndFunc Volatile Func Event_onkeydown($oEvtObj)     If IsObj($oEvtObj) Then         ConsoleWrite("Event type: " & $oEvtObj.type & "id (0 is document) = " & $oEvtObj.srcElement.id)         ConsoleWrite(", keycode = " & $oEvtObj.keyCode & ", shiftkey = " & $oEvtObj.shiftKey & @CRLF)     EndIf EndFunc ; ====================================================================================================== #EndRegion IE_EVENT_FUNCS #EndRegion IE_CANVAS_EXAMPLE #Region UTIL_FUNCS ; ====================================================================================================== ; Func _ReRunIfNotElevated() ; ; Does what it says. (rumored to occasionally say what it does) ; ; Author: Ascend4nt ; ====================================================================================================== Func _ReRunIfNotElevated()     If IsAdmin() Then         Return 0     Else         If @Compiled Then             ; If compiled to A3X, we need to execute it as if not compiled.             Local $sCmd = (@AutoItExe = @ScriptFullPath) ? "" : ("/AutoIt3ExecuteScript " & @ScriptFullPath)             Return ShellExecute(@AutoItExe, $sCmd, @ScriptDir, "runas")         Else             Return ShellExecute(@AutoItExe,@ScriptFullPath,@ScriptDir,"runas")         EndIf     EndIf EndFunc #EndRegion UTIL_FUNCS IEEmbeddedVersioning.zip ~prev Downloads: 61
      Also, HTML5+Javascript standalone Canvas demo (should run in any browser): HTML5StandaloneCanvasDemo.zip