JohnOne Posted July 11, 2013 Share Posted July 11, 2013 (edited) I'm having an issue trying to set an IE window's parent similar as in >this post, I thought it would be pretty simple to be honest but the IE window does not appear to be set as child to my GUI. I get no errors either, can anyone spot my mistake? //Create an Internet Explorer kiosk window //hWnd is my gui HINSTANCE IEKIOSK = ShellExecuteA(hWnd, "open", "C:\\progra~1\\intern~1\\iexplore.exe", "-k http://www.google.com", "", SW_SHOW); HWND IEWIN = NULL; do{IEWIN = FindWindowA("IEFrame", "http://www.google.com/ - Google - Windows Internet Explorer"); Sleep(100); }while(! IEWIN); Beep(700,100); if(! SetParent(IEWIN,hWnd)){ MessageBoxA(NULL, "Funtion failure", "Error", MB_OK); }; MoveWindow(IEWIN,0,0,400,300,true); Edited July 12, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted July 14, 2013 Share Posted July 14, 2013 (edited) Hi,Do you want it in autoit? if so, try this :#include <GUIConstantsEx.au3> #include <Constants.au3> #include <WinAPI.au3> Opt("WinTitleMatchMode", 2) ;Create an Internet Explorer kiosk window ShellExecute("C:\\progra~1\\intern~1\\iexplore.exe", "-k http://www.google.com") Local $hIEWIN = 0 Do $hIEWIN = WinGetHandle("[CLASS:IEFrame;TITLE: - Google - Windows Internet Explorer]") Sleep(100) Until $hIEWIN > 0 Beep(700, 100) Local $hGUI = GUICreate("MyGUI") GUISetState(@SW_SHOW, $hGUI) If _WinAPI_SetParent($hIEWIN, $hGUI) = 0 Then MsgBox($MB_OK, "Funtion failure", "Error") EndIf ;~ WinMove($hIEWIN, 0, 0, 400, 300) While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEndEdit: Added indents.Br, FireFox. Edited July 14, 2013 by FireFox Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 (edited) Thanks FireFox, but my problem is that, when I convert that code to C++ it does not work. Or perhaps more specifically, the IE window does not pseudo embed into the window I create in c++ (hWnd). The _WinAPI_SetParent() is basically just a DllCall to C++ Setparent and my expectations were that it would do exactly the same as what it does in AutoIt. It seems very odd that it does not. EDIT: I have used a few different ways of starting IE, including CoCreateInstance, CreateProcess, ShellExecuteEx and simply retrieving the handle of an already running IE window. All without success. Edited July 14, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted July 14, 2013 Share Posted July 14, 2013 Can you send me your project in a packed file? Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 Certainly, but it's part of a larger project so I'll just make a new one with the necessary code. Give me a few minutes. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 (edited) Here is project http://www.filedropper.com/ieembed EDIT: not quite a few minutes, but had a pop in from a pal in the middle, so I had to stop cause he was mocking me for being a big daft science cowboy. EDIT2: I could not be bothered to put a button in so I just shamefully recycled the exit from file menu to run the function Edited July 14, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted July 14, 2013 Share Posted July 14, 2013 The ShellExecute fails and it avoids the MessageBox to be displayed, I can see that with breakpoints.You can't get a partial title with the FindWindow function, you will need to use the EnumWindows function and check the titles (which I can't get to work).I have tested directly with the handle of the IE kiosk window and the rest of the script is OK.I don't code in C++, I will be glad if someone points out what's wrong :expandcollapse popupBOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam); void myFunc1(HWND); void Embed(){ /* HINSTANCE IEKIOSK = ShellExecute( hWnd, L"open", L"C:\\Progra~1\Intern~1\\iexplore.exe", L"-k http://www.google.com/", L"", SW_SHOW); //??does not work if (!IEKIOSK) { MessageBox(NULL, L"Function ShellExecute Failed", L"Boooooo!", MB_OK); exit(0); } */ EnumWindows(EnumWindowsProc, NULL); } BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { LPTSTR title = (LPTSTR)""; LPTSTR class_name = (LPTSTR)""; GetClassName(hwnd, class_name, sizeof(class_name)); GetWindowText(hwnd, title, sizeof(title)); printf("%d", lstrcmpi(class_name, (LPTSTR)"IEFrame")); //??access violation //if(lstrcmpi(class_name, (LPTSTR)"IEFrame") && lstrcmpi(title, (LPTSTR)"Google - Windows Internet Explorer")) { if((int)hwnd==0x002003D8) { //handle of the IE kiosk wnd myFunc1(hwnd); return FALSE; } return TRUE; } void myFunc1(HWND wnd) { Beep(700,150); if (!SetParent(wnd, hWnd)){ MessageBox(NULL, L"Function Setparent Failed", L"Boooooo!", MB_OK); } MoveWindow(wnd, 0, 0, 400, 400, TRUE); }Br, FireFox. Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 Sorry, I already had a normal IE window open just for testing and Findwindow was working fine to get window handle. The Shellexecute was not working because I left out an escaping backslash in the path somehow. Are you saying that the IE window embeds into the created window for you? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted July 14, 2013 Share Posted July 14, 2013 Are you saying that the IE window embeds into the created window for you?Yes. Try without the MoveWindow function. Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 Weird, Does not embed for me, I've tried rebooting on a number of occasions, and on two different computers AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted July 14, 2013 Share Posted July 14, 2013 Well, I edited a few lines in the IEEMBED file. I don't know if it affects the rest of the program.Try it: http://www.mediafire.com/download/rlcnzm4dv7apqwk/IEEMBED.zip JohnOne 1 Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 Is that different from what you posted above, because I tried that? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 FireFox. Thank you kindly. Your code works, but I can not immediately see what you have changed other than where you call the function. Can you give an explanation if you have the time? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted July 14, 2013 Share Posted July 14, 2013 (edited) I removed the local declaration of hWnd in the InitInstance function, otherwise it overrides? the global one which is then not set. Edited July 14, 2013 by FireFox Link to comment Share on other sites More sharing options...
JohnOne Posted July 14, 2013 Author Share Posted July 14, 2013 Well spotted and thanks again, been cracking me up for a couple of days now. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted July 14, 2013 Share Posted July 14, 2013 You're welcome Link to comment Share on other sites More sharing options...
ionamartin123 Posted August 6, 2013 Share Posted August 6, 2013 FireFox. Thank you kindly. Your code works, but I can not immediately see what you have changed other than where you call the function. Can you give an explanation if you have the time? Last week I'm also having the same problem. In this answer useful for me.I will try to use the same method the error is to be clear. Link to comment Share on other sites More sharing options...
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