JohnOne Posted June 29, 2013 Share Posted June 29, 2013 I ripped off a bit of code from >here to sort of pseudo embedd an instance of google chrome in gui. Thing is, it winds up all out of whack and not centered, wondering if anyone might know why? expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <Array.au3> #include <Constants.au3> #include <IE.au3> Dim $hGUI, $oIE, $sURL, $iLeft, $iTop, $iHeight, $iWidth $iLeft = 0 $iTop = 0 $iWidth = 1024 $iHeight = 768 Global $i_PID $hGUI = GUICreate("Test", $iWidth, $iHeight) ChromeCreatePseudoEmbedded($iLeft, $iTop, $iWidth, $iHeight, $hGUI) GUISetState(@SW_SHOW, $hGUI) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ;_IEQuit($oIE) ProcessClose($i_PID) Exit EndIf WEnd Func ChromeCreatePseudoEmbedded($i_Left, $i_Top, $i_Width, $i_Height, $h_Parent, $f_ShowWin = False, $i_Timeout = 30000) Local $i_PID, $o_IE, $h_HWND, $h_Timer = TimerInit() $i_PID = Run(@ProgramFilesDir & "\Google\Chrome\Application\chrome.exe --chrome-frame -kiosk http://www.google.com") If @error Then MsgBox(0, 0, @error) Exit EndIf $ah_HWND = _WinAPI_EnumProcessWindows($i_PID) While Not IsArray($ah_HWND) $ah_HWND = _WinAPI_EnumProcessWindows($i_PID) WEnd $h_HWND = HWnd($ah_HWND[1][0]) _WinAPI_SetParent($h_HWND, $h_Parent) _WinAPI_MoveWindow($h_HWND, $i_Left, $i_Top, $i_Width, $i_Height, True) _WinAPI_SetWindowLong($h_HWND, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) If $f_ShowWin Then WinSetState($h_HWND, "", @SW_SHOW) EndIf EndFunc ;==>ChromeCreatePseudoEmbedded 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 June 29, 2013 Author Share Posted June 29, 2013 Well the reason seems to be that The kiosk window does not respond to _WinAPI_MoveWindow, or SetWindowPos dllcall 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 June 29, 2013 Author Share Posted June 29, 2013 Don't ask me how or why, but adding a ControlMove, gets me a little bit closer. It works fine sometimes but others, you need to click in the gui to get it right. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> ;#include <Array.au3> #include <Constants.au3> ;#include <IE.au3> Dim $hGUI, $oIE, $sURL, $iLeft, $iTop, $iHeight, $iWidth $iLeft = 0 $iTop = 0 $iWidth = 1024 $iHeight = 768 Global $i_PID $hGUI = GUICreate("Test", $iWidth, $iHeight) ChromeCreatePseudoEmbedded($iLeft, $iTop, $iWidth, $iHeight, $hGUI) GUISetState(@SW_SHOW, $hGUI) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ;_IEQuit($oIE) ProcessClose($i_PID) Exit EndIf WEnd Func ChromeCreatePseudoEmbedded($i_Left, $i_Top, $i_Width, $i_Height, $h_Parent, $f_ShowWin = True, $i_Timeout = 30000) Local $i_PID, $o_IE, $h_HWND, $h_Timer = TimerInit() $i_PID = Run(@ProgramFilesDir & "\Google\Chrome\Application\chrome.exe --chrome-frame -kiosk http://www.google.com") If @error Then MsgBox(0, 0, @error) Exit EndIf $ah_HWND = _WinAPI_EnumProcessWindows($i_PID) While Not IsArray($ah_HWND) $ah_HWND = _WinAPI_EnumProcessWindows($i_PID) WEnd $h_HWND = HWnd($ah_HWND[1][0]) _WinAPI_SetParent($h_HWND, $h_Parent) _WinAPI_MoveWindow($h_HWND, $i_Left, $i_Top, $i_Width, $i_Height, False) _WinAPI_SetWindowLong($h_HWND, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) $ret = DllCall("User32.dll", "bool", "SetWindowPos", "hwnd", $h_HWND, "hwnd", -2, "int", $i_Left, "int", $i_Top, "int", $i_Width, "int", $i_Height, "uint", 0x4000 + 0x0100) ControlMove($h_HWND, "","", $i_Left,$i_Top,$i_Width,$i_Height) ; << this clinches the deal but still a bit weird ;_WinAPI_RedrawWindow($h_Parent) EndFunc ;==>ChromeCreatePseudoEmbedded 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 June 29, 2013 Author Share Posted June 29, 2013 Still cannot figure out how to edit a post underneath a code bos, you cannot get a cursor under it. Anyway this seems to work. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> ;#include <Array.au3> #include <Constants.au3> ;#include <IE.au3> Dim $hGUI, $oIE, $sURL, $iLeft, $iTop, $iHeight, $iWidth $iLeft = 0 $iTop = 0 $iWidth = 1024 $iHeight = 768 Global $i_PID $hGUI = GUICreate("Test", $iWidth, $iHeight) ControlClick("Test", "", "") ChromeCreatePseudoEmbedded($iLeft, $iTop, $iWidth, $iHeight, $hGUI) GUISetState(@SW_SHOW, $hGUI) ControlClick($hGUI, "", "") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ;_IEQuit($oIE) ProcessClose($i_PID) Exit EndIf WEnd Func ChromeCreatePseudoEmbedded($i_Left, $i_Top, $i_Width, $i_Height, $h_Parent, $f_ShowWin = True, $i_Timeout = 30000) Local $i_PID, $o_IE, $h_HWND, $h_Timer = TimerInit() $i_PID = Run(@ProgramFilesDir & "\Google\Chrome\Application\chrome.exe --chrome-frame -kiosk http://www.google.com") If @error Then MsgBox(0, 0, @error) Exit EndIf $ah_HWND = _WinAPI_EnumProcessWindows($i_PID) While Not IsArray($ah_HWND) $ah_HWND = _WinAPI_EnumProcessWindows($i_PID) WEnd $h_HWND = HWnd($ah_HWND[1][0]) _WinAPI_SetParent($h_HWND, $h_Parent) _WinAPI_MoveWindow($h_HWND, $i_Left + 1, $i_Top + 1 , $i_Width - 2 , $i_Height - 2, True) ControlMove($h_HWND, "","", $i_Left + 1, $i_Top + 1 , $i_Width - 2 , $i_Height - 2) ; << this clinches the deal but still a bit weird _WinAPI_SetWindowLong($h_HWND, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) EndFunc ;==>ChromeCreatePseudoEmbedded Writing under code so I can get to it if need be 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...
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