Phoenixx177

Embedding 3rd Party app and 2 browsers in GUI - I'm THIS close.

5 posts in this topic

#1 ·  Posted

I have a script that is calling 2 browser windows in my GUI and loading up the appropriate URLs.  Tested alone it works fine.  I also have another script that launches a 3rd party application in the GUI.  When I try to modify my 2nd script so that it includes the two browser windows along with the GUI, the GUI loads but not the browser windows.  Can someone get a second set of eyes on the script below and tell me where my brain jumped track please?  Many Thanks.

#include <GUIConstants.au3>
#include <Constants.au3>
#include <windowsconstants.au3>
#include <IE.au3>

Global $oIE_google = _IECreateEmbedded()
Global $oIE_autoit = _IECreateEmbedded()

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

$mainWindow = GUICreate("Embed Cmd", 1280, 780, 10, 10)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState (@SW_SHOW)
GUIRegisterMsg(0xF, "WM_PAINT")

; create a borderless window that is a child to the main window
$embedWindow = GUICREATE("", 700, 400, 15, 15, $WS_POPUP, -1, $mainWindow)
Global $google = GUICtrlCreateObj($oIE_google, 10, 10, 1000, 300)
Global $autoit = GUICtrlCreateObj($oIE_autoit, 800, 10, 500, 300)
_IENavigate($oIE_google, "http://www.google.com")
_IENavigate($oIE_autoit, "http://www.bing.com")

DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $embedWindow, "hwnd", $mainWindow)




; launch the command prompt (black on white, without the operating system message)
$pid = run("C:\Program Files (x86)\Cisco\Router Manager\Router Administration.exe")
ProcessWait ($pid)
; get the handle of the cmd window as i cannot be certain that there will be only one instance of the cmd running with the same window title or class
$cmdHandle = _ProcessGetHWnd($pid, 2)
$hWndChild = $cmdHandle[1][1]
; make the command prompt window a child to the earlier created borderless child window
DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWndChild, "hwnd", $embedWindow)
; resize the command prompt window so that its bolder and title bar are outside the borderless child window
;  giving the appearance of a borderless command prompt
WinMove($hWndChild, '', 10, 500, 485, 206)
;WinMove($hWndChild, '', 10, 500)
WinSetState($hWndChild, '', @SW_SHOW)
WinSetState($embedWindow, '', @SW_SHOW)
WinSetState($oIE_google, '', @SW_SHOW)
WinSetState($oIE_autoit, '', @SW_SHOW)

; inifinite event loop
While 1

; sleep for 100 milliseconds (to not hog the cpu)
    sleep(100)

; end of event loop
WEnd


Func CLOSEClicked()
; take care of things to do when exiting
    Winkill($hWndChild)
    Exit
EndFunc


Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    Sleep(100)
    DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "ptr", 0, "int", 0)
EndFunc  ;==>WM_PAINT



;===============================================================================
;
; Function Name:    _ProcessGetHWnd
; Description:      Returns the HWND(s) owned by the specified process (PID only !).
;
; Parameter(s):     $iPid        - the owner-PID.
;                    $iOption    - Optional : return/search methods :
;                        0 - returns the HWND for the first non-titleless window.
;                        1 - returns the HWND for the first found window (default).
;                        2 - returns all HWNDs for all matches.
;
;                   $sTitle        - Optional : the title to match (see notes).
;                    $iTimeout    - Optional : timeout in msec (see notes)
;
; Return Value(s):  On Success - returns the HWND (see below for method 2).
;                        $array[0][0] - number of HWNDs
;                        $array[x][0] - title
;                        $array[x][1] - HWND
;
;                   On Failure    - returns 0 and sets @error to 1.
;
; Note(s):            When a title is specified it will then only return the HWND to the titles
;                    matching that specific string. If no title is specified it will return as
;                    described by the option used.
;
;                    When using a timeout it's possible to use WinWaitDelay (Opt) to specify how
;                    often it should wait before attempting another time to get the HWND.
;
;
; Author(s):        Helge
;
;===============================================================================
Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000)
    Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit()

    While 1

    ; Get list of windows
        $aWin = WinList($sTitle)

    ; Searches thru all windows
        For $i = 1 To $aWin[0][0]

        ; Found a window owned by the given PID
            If $iPid = WinGetProcess($aWin[$i][1]) Then

            ; Option 0 or 1 used
                If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then
                    Return $aWin[$i][1]

            ; Option 2 is used
                ElseIf $iOption = 2 Then
                    ReDim $aReturn[UBound($aReturn) + 1][2]
                    $aReturn[0][0] += 1
                    $aReturn[$aReturn[0][0]][0] = $aWin[$i][0]
                    $aReturn[$aReturn[0][0]][1] = $aWin[$i][1]
                EndIf
            EndIf
        Next

    ; If option 2 is used and there was matches then the list is returned
        If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn

    ; If timed out then give up
        If TimerDiff($hTimer) > $iTimeout Then ExitLoop

    ; Waits before new attempt
        Sleep(Opt("WinWaitDelay"))
    WEnd


; No matches
    SetError(1)
    Return 0
EndFunc  ;==>_ProcessGetHWnd

$StaticTxt = ControlGetText("Embed Cmd","",1007)
 MsgBox(1,"Static Text", $StaticTxt)

GUISetState()
While GUIGetMsg() <> -3
WEnd

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Still not able to put this together.  Anyone have any insight?

Share this post


Link to post
Share on other sites

#3 ·  Posted

Are you experiencing a strange occurrence and that the window instead of being embedded is acting like an overlay? In other words, are you getting a window covering up another and can actually click and drag it out separating the two?

If so, I wonder about the DLL calls  you're making to make the parent/child windows. I could be wrong. But wouldn't something like this be more helpful:

 

$h_HWND = _IEPropertyGet($o_IE, "hwnd")
$hhwnd = WinGetProcess($hWnd)
_WinAPI_SetParent($h_HWND, [your GUI])
_WinAPI_MoveWindow($h_HWND, $0, $0, 1049, 550, False)
_WinAPI_SetWindowLong($h_HWND, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)

The two browser windows would be something like this:

$o_IE = ObjCreate("InternetExplorer.Application")
$o_IE.theatermode = True
$o_IE.fullscreen = True
$o_IE.statusbar = False
_IENavigate($o_IE, 'about:blank')
        
        and

$o_IETwo = ObjCreate("InternetExplorer.Application")
$o_IETwo.theatermode = True
$o_IETwo.fullscreen = True
$o_IETwo.statusbar = False
_IENavigate($o_IETwo, 'about:blank')

I hope this helps. The other folks here can add more insights.

1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Phoenixx77,

You are overlaying your controls/windows and after the 2nd guicreate you do NOT do a GuiSetState() to show the gui...

kylomas

edit: This is not launching the command processor...

; launch the command prompt (black on white, without the operating system message)
$pid = run("C:\Program Files (x86)\Cisco\Router Manager\Router Administration.exe")

Also, not sure if winsetstate is the same as guisetstate...

edit2: Output from the cmd window is not read with windows cmds/funcs, rather with stdoutread.  So I am not sure what you expect from creating a cmd window.

If you outline what you are trying to do there are probably examples available.

Edited by kylomas
additional info

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#5 ·  Posted

@kylomas put simply I'm just trying to embed 2 browser windows and the router application.  We are doing web testing and want to watch the front end in one browser window, the back end in the other browser window, and the router in the 3rd.  This will be distributed to a few of our offices so it needs to be a standard GUI that encompasses both browsers and the router GUI in one AutoIT GUI.

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

  • Similar Content

    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3

    • Neonovaz
      By Neonovaz
      Hello
       
      Is there anyway to store word documents in Autoit GUI? For example I have a instruction sheet that I want to bundle up with the exe.

      So a user simply clicks the icon and the stored document will launch  (Something like how you can add objects like excel sheets in word documents )

      (I Know we can launch word files from script directory)

       
    • leomoon
      By leomoon
      Hello,
      I'm trying to write a hotkey program and I know exactly how to do it but it will be hard coded and the user won't be able to edit it.
      HotKeySet("{ESC}", "HotKeyPressed") HotKeySet("^!d", "HotKeyPressed") HotKeySet("^+x", "HotKeyPressed") While 1 Sleep(500) WEnd Func HotKeyPressed() Switch @HotKeyPressed Case "{ESC}" Exit Case "^!d" ShellExecute("D:\Docs") Case "^+x" ShellExecute("D:\Docs\My Portables\Burner\AnyBurn\AnyBurn.exe") EndSwitch EndFunc I want the program to read a file that has hotkeys on odd lines and paths on even lines but I don't see how the program will load into itself.
      Is it even possible?
      Thanks.
    • hemichallenger
      By hemichallenger
      Not sure if this is possible or if someone has already tackled this. Is it possible to embed PowerShell into a GUI? Autoit is great for quick function but sometime I need to run a command thru PowerShell. It be great to have PowerShell console embedded into the gui.