user52 Posted May 1, 2007 Posted May 1, 2007 (edited) continued from http://www.autoitscript.com/forum/index.php?showtopic=36890 here's a snippet of the code i'm using: expandcollapse popup#include <guiconstants.au3> ;~ #include <ie.au3> #include <IET2.0.6.au3> ;~ ProcessClose("iexplore.exe") HotKeySet("{ESC}", "_Exit") $gui = GUICreate("", 700, 700, -1, -1, 0) $Label_1 = GuiCtrlCreateLabel("", 10, 10, 670, 650) _IEErrorHandlerRegister() ;setup ie win $oIE1 = _IECreate("about:blank",0,0,1,0) $oIE1.AddressBar = 0 $oIE1.MenuBar = 0 $oIE1.StatusBar = 0 $oIE1.ToolBar = 0 $uID1 = Random(1000, 100000000) $oIE1.document.title = $uID1 WinWait($uID1, "", 7) $hoIE1 = WinGetHuID1) $pid1 = WinGetProcess($hoIE1) ;embed DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE1, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE1, "hwnd", $gui) ;move $pos = ControlGetPos($gui, "", $Label_1) If IsArray($pos) Then WinMove($hoIE1, "", $pos[0], $pos[1], $pos[2], $pos[3]) EndIf ;show GuiSetState() $oIE1.visible=1 While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd _Exit() Func _Exit() While ProcessExists($pid1) ProcessClose($pid1) WEnd Exit EndFunc Windows 2000/XP: When you change the parent of a window, you should synchronize the UISTATE of both windows. For more information, see WM_CHANGEUISTATE and WM_UPDATEUISTATE. i was looking at the SetParent() function and was wondering how to synchronize the UISTATE of both windows. thanks Edited May 1, 2007 by user52
lod3n Posted May 1, 2007 Posted May 1, 2007 I'm not sure what the value of $hwnd should be, but this is similar to the code you should probably be using to do this:#include <misc.au3> $WM_CHANGEUISTATE = 0x127 $WM_UPDATEUISTATE = 0x128 _SendMessage($hWnd, $WM_CHANGEUISTATE) _SendMessage($hWnd, $WM_UPDATEUISTATE)$hwnd should probably be replaced with the Gui handle, but I'm thinking it could be the IE control instead, or the containing shell object, or the containing document embedding object. It would be cool if you get this working nicely. I've had some trouble embedding two+ IE objects. The problem is the last IE object to be added to the GUI steals all of the accelerator key events from the other IE objects, and the cursor focus. So you can't click on the first IE object and tab around, it just jumps to the second IE object and tabs there. Very frustrating, but I thought it was due to an internal AutoIt limitation. Some of my research into workarounds pointed to some kind of window message to indicate the currently active IE object, but I could never find it. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
user52 Posted May 1, 2007 Author Posted May 1, 2007 (edited) thank you lod3ni finally got the ie windows not to take away the focus of the gui. it was just a matter of setting $WS_CHILD right after setting it's parent using "SetParent".beforeafterworking code:expandcollapse popup#region #include <guiconstants.au3> ;~ #include <ie.au3> #include <IET2.0.6.au3> #include <misc.au3> HotKeySet("{ESC}", "_Exit") $gui = GUICreate("", 1230, 500) $Label_1 = GuiCtrlCreateLabel("", 10, 10, 600, 420) $Label_2 = GuiCtrlCreateLabel("", 620, 10, 600, 420) _IEErrorHandlerRegister() ;setup ie win (2x) $oIE1 = _IECreate("about:blank",0,0,1,0) $oIE1.AddressBar = 0 $oIE1.MenuBar = 0 $oIE1.StatusBar = 0 $oIE1.ToolBar = 0 $uID1 = Random(1000, 100000000) $oIE1.document.title = $uID1 WinWait($uID1, "", 7) $hoIE1 = WinGetHandle($uID1) $pid1 = WinGetProcess($hoIE1) $oIE2 = _IECreate("about:blank",0,0,1,0) $oIE2.AddressBar = 0 $oIE2.MenuBar = 0 $oIE2.StatusBar = 0 $oIE2.ToolBar = 0 $uID2 = Random(1000, 100000000) $oIE2.document.title = $uID2 WinWait($uID2, "", 7) $hoIE2 = WinGetHandle($uID2) $pid2 = WinGetProcess($hoIE2) ;embed DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE1, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE1, "hwnd", $gui) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE1, "int", -16, "long", $WS_CHILD) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE2, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE2, "hwnd", $gui) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE2, "int", -16, "long", $WS_CHILD) ;move $pos = ControlGetPos($gui, "", $Label_1) WinMove($hoIE1, "", $pos[0], $pos[1], $pos[2], $pos[3]) $pos = ControlGetPos($gui, "", $Label_2) WinMove($hoIE2, "", $pos[0], $pos[1], $pos[2], $pos[3]) ;nav _IENavigate($oIE1, "http://www.google.com/", 0) _IENavigate($oIE2, "http://images.google.com/", 0) ;show GuiSetState() $oIE1.visible=1 $oIE2.visible=1 #endregion WinActivate($gui) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd _Exit() Func _Exit() While ProcessExists($pid1) ProcessClose($pid1) WEnd Exit EndFunc Func dbg($msg) ConsoleWrite($msg & @CRLF) DllCall("kernel32.dll", "none", "OutputDebugString", "str", $msg) EndFunc Edited May 1, 2007 by user52
user52 Posted May 1, 2007 Author Posted May 1, 2007 An application can use the SetParent function to set the parent window of apop-up, overlapped, or child window. The new parent window and the childwindow must belong to the same application.If the window identified by the hWndChild parameter is visible, the systemperforms the appropriate redrawing and repainting.For compatibility reasons, SetParent does not modify the WS_CHILD orWS_POPUP window styles of the window whose parent is being changed.Therefore, if hWndNewParent is NULL, you should also clear the WS_CHILD bitand set the WS_POPUP style after calling SetParent. Conversely, ifhWndNewParent is not NULL and the window was previously a child of thedesktop, you should clear the WS_POPUP style and set the WS_CHILD stylebefore calling SetParent.Windows 2000 or later: When you change the parent of a window, you shouldsynchronize the UISTATE of both windows. For more information, seeWM_CHANGEUISTATE and WM_UPDATEUISTATE.
lod3n Posted May 2, 2007 Posted May 2, 2007 Looks like I wrote something similar to this already:http://www.autoitscript.com/forum/index.php?showtopic=32804Nice to see I'm not the only one having the problem. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
magnifier512 Posted April 22, 2008 Posted April 22, 2008 Nice solution, however I only understand half of your code for getting this Tab-problem working and my problem is slightly different. I want to attach one IE window on each of two tabs. Here is the code im currently using. Is it possible to realize that? #include <guiconstants.au3> #include <IE.au3> $oIE1 = _IECreateEmbedded() $oIE2 = _IECreateEmbedded() $main_window = GUICreate("Testwindow", @DesktopWidth/2, @DesktopHeight/2, 0, 0, $WS_CAPTION + $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetState(@SW_MAXIMIZE, $main_window) $mainpos_array = WinGetPos($main_window) $main_tab = GUICtrlCreateTab(10, 10, 90, 50) $main_tab1 = GUICtrlCreateTabItem("Tab1") $GUIoIE1 = GUICtrlCreateObj($oIE1, 10, 30, $mainpos_array[2] - 30, $mainpos_array[3] - 125) GUICtrlCreateTabItem("") $main_tab2 = GUICtrlCreateTabItem("Tab2") $GUI_oIE2 = GUICtrlCreateObj($oIE2, 10, 30, $mainpos_array[2] - 30, $mainpos_array[3] - 125) GUICtrlCreateTabItem("") GUICtrlSetState($main_tab1, $GUI_SHOW) GuiSetState() _IENavigate($oIE1, "http://www.google.com/", 0) _IENavigate($oIE2, "http://images.google.com/", 0) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now