Jump to content

_IECreateEmbedded() -from help example but


John117
 Share

Recommended Posts

Pleaes click http://traffic.houstontranstar.org/layers/# -This is a traffic page.

I am hoping to get an untra mobile pc (very small screen) and would like to only see the traffic area on this page (thats all that will fit) . maybe the map controls area too.

I have tried saving the page and editing it, but it doesn't load anymore. (I haven't played with html in a few years and its moved beyond me atleast for now)

Can anyone tell me how this could be done? Starter code below. Thanks,

#include <GUIConstants.au3>
#include <IE.au3>
HotKeySet("{ESC}", "_Toggle")
$Show = True

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 620, 660, Default, Default, $WS_POPUPWINDOW)
;$GUI = GUICreate("Embedded Web control Test", 640, 600, Default, Default, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 5, 5, 620, 620)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 625, 100, 20)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 625, 100, 20)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 625, 100, 20)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 625, 100, 20)

GUISetState(@SW_SHOW, $GUI);Show GUI
_IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")

; ============================================================================
; Main Loop
; ============================================================================
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
    EndSelect
WEnd
; ============================================================================
; Functions
; ============================================================================
Func _Toggle()
    If $Show = True Then
        Global $Show = False
        GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>_Toggle
Link to comment
Share on other sites

Add this after _IENavigate()

$oMAP=_IEGetObjByName($oIE,"topImage")
$Left=_IEPropertyGet($oMAP,"browserx")
$Top=_IEPropertyGet($oMAP,"browsery")
$oIE.document.parentwindow.scrollBy($Left,$Top)

To make it a bit better, you could show the GUI after it scrolled to the map, so the user doesn't see that. Show a spash text.. like 'Please wait, connecting...'

Just an idea.

Link to comment
Share on other sites

Not a bad concept, thanks! :) I was thinking of getting the manual position of the scrollbar and scrolling with that as a fixed position and last result.

This is a better idea ^_^

my next challange will be to maybe scroll left and right by grabbing the image and holding (would help to reduce the gui size further). If you have done something like this before, feel free to help me out. Im off to work at it. :)

Link to comment
Share on other sites

this is what Im up to. still working on it.

#include <GUIConstants.au3>
#include <IE.au3>
HotKeySet("{ESC}", "_Toggle")
$Show = False
Global $Pos, $Pos2
_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 620, 660, Default, Default, $WS_POPUPWINDOW)
;GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 5, 5, 620, 620)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 625, 100, 20)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 625, 100, 20)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 625, 100, 20)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 625, 100, 20)

_IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
$oMAP=_IEGetObjByName($oIE,"topImage")
$Left=_IEPropertyGet($oMAP,"browserx")
$Top=_IEPropertyGet($oMAP,"browsery")
$oIE.document.parentwindow.scrollBy($Left,$Top)
GUISetState(@SW_SHOW, $GUI);Show GUI
msgbox(0, "Left", $Left)
msgbox(0, "Top", $Top)
; ============================================================================
; Main Loop
; ============================================================================
While 1
    $msg = GUIGetMsg()
    $Pos = MouseGetPos()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
        Case $Show = True
            If $Pos <> $Pos2 Then $oIE.document.parentwindow.scrollBy($Pos2[0]-((@DesktopWidth-620)/2),$Pos2[1]-((@DesktopHeight-620)/2))   
            ;msgbox(0, "Left", ($Pos2[0]-((@DesktopWidth-620)/2)))
            ;msgbox(0, "Top", ($Pos2[1]-((@DesktopHeight-620)/2)))
        EndSelect
        $Pos2 = MouseGetPos()
WEnd
; ============================================================================
; Functions
; ============================================================================
Func _Toggle()
    If $Show = True Then
        Global $Show = False
        ;GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        ;GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>_Toggle

*Yes I know something wrong :) -still working on it

hit esc to see it work, hit esc to turn it off

Link to comment
Share on other sites

==> Subscript used with non-Array variable.: 
If $Pos <> $Pos2 Then $oIE.document.parentwindow.scrollBy($Pos2[0]-((@DesktopWidth-620)/2),$Pos2[1]-((@DesktopHeight-620)/2)) 
If $Pos <> $Pos2 Then $oIE.document.parentwindow.scrollBy($Pos2^ ERROR

What do you want to do here?

If $Pos <> $Pos2 Then $oIE.document.parentwindow.scrollBy($Pos2[0]-((@DesktopWidth-620)/2),$Pos2[1]-((@DesktopHeight-620)/2))

why 620?

Link to comment
Share on other sites

the 620 area is where the problem is but you should not be getting the error. (I only press esc after the while has 1+ loop. -by then it is an array.

try moving pos2 under pos and adding sleep(10) between

#include <GUIConstants.au3>
#include <IE.au3>
HotKeySet("{ESC}", "_Toggle")
$Show = False
_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 620, 660, Default, Default, $WS_POPUPWINDOW)
;GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 5, 5, 400, 300)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 625, 100, 20)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 625, 100, 20)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 625, 100, 20)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 625, 100, 20)

_IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
$oMAP=_IEGetObjByName($oIE,"topImage")
$Left=_IEPropertyGet($oMAP,"browserx")
$Top=_IEPropertyGet($oMAP,"browsery")
$oIE.document.parentwindow.scrollBy($Left,$Top)
GUISetState(@SW_SHOW, $GUI);Show GUI
msgbox(0, "Left", $Left)
msgbox(0, "Top", $Top)
; ============================================================================
; Main Loop
; ============================================================================
While 1
    $msg = GUIGetMsg()
    $Pos = MouseGetPos()
    Sleep(10)
    $Pos2 = MouseGetPos()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
        Case $Show = True
            If $Pos <> $Pos2 Then $oIE.document.parentwindow.scrollBy($Pos2[0]-(@DesktopWidth/2)-310,$Pos2[1]-(@DesktopHeight/2)-330)           ;msgbox(0, "Left", ($Pos2[0]-((@DesktopWidth-620)/2)))
            ;msgbox(0, "Top", ($Pos2[1]-((@DesktopHeight-620)/2)))
        EndSelect
        
WEnd
; ============================================================================
; Functions
; ============================================================================
Func _Toggle()
    If $Show = True Then
        Global $Show = False
        ;GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        ;GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>_Toggle

still playing with it.

my goal is to get the mouse position to center the scroll bar above the mouse area.

looking like I may have to settle for middle click on the mouse.

Edited by Hatcheda
Link to comment
Share on other sites

A Wider spectrum...

#include <GUIConstants.au3>
#include <IE.au3>
HotKeySet("{ESC}", "_Toggle")
$Show = False
_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 620, 680, Default, Default, $WS_POPUPWINDOW)
;GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, -176, -127, 810, 776)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 650, 100, 20)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 650, 100, 20)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 650, 100, 20)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 650, 100, 20)

_IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
;$oMAP=_IEGetObjByName($oIE,"topImage")
;$Left=_IEPropertyGet($oMAP,"browserx")
;$Top=_IEPropertyGet($oMAP,"browsery")
;$oIE.document.parentwindow.scrollBy($Left,$Top)
GUISetState(@SW_SHOW, $GUI);Show GUI
;msgbox(0, "Left", $Left)
;msgbox(0, "Top", $Top)
; ============================================================================
; Main Loop
; ============================================================================
While 1
    $msg = GUIGetMsg()
    $Pos = MouseGetPos()
    Sleep(10)
    $Pos2 = MouseGetPos()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
        Case $Show = True
            ;If $Pos <> $Pos2 Then $oIE.document.parentwindow.scrollBy($Pos2[0]-((@DesktopWidth-620)/2),$Pos2[1]-(((@DesktopHeight)/2)))
            ;msgbox(0, "Left", ($Pos2[0]-((@DesktopWidth-620)/2)))
            ;msgbox(0, "Top", ($Pos2[1]-((@DesktopHeight-620)/2)))
        EndSelect
       
WEnd
; ============================================================================
; Functions
; ============================================================================
Func _Toggle()
    If $Show = True Then
        Global $Show = False
        ;GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        ;GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>_Toggle

I know you wanted a smaller screen, this is just a concept idea!

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

ok, I have one final question directly related to the map.

what is the vertical white bar on the right side?

I was thinking I could chop it off by reducing the width. -this actually chops off the arrow as expected. (proves basic concept) - but the white bar stays there.

#include <GUIConstants.au3>
#include <IE.au3>
HotKeySet("{ESC}", "_Toggle")
$Show = False
_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()

;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 840, 600, Default, Default, $WS_POPUPWINDOW)
;$GUI = GUICreate("", 840, 600, Default, Default)

;GUICtrlCreateObj ( $ObjectVar, left, top [, width [, height ]] )
$GUIActiveX = GUICtrlCreateObj($oIE, -176, -130, 800, 800)
$GUI_Button_Back = GUICtrlCreateButton("Back", 600, 0, 60, 20)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 660, 0, 60, 20)
$GUI_Button_Home = GUICtrlCreateButton("Home", 720, 0, 60, 20)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 780, 0, 60, 20)

_IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
GUISetState(@SW_SHOW, $GUI);Show GUI
; ============================================================================
; Main Loop
; ============================================================================
While 1
    $msg = GUIGetMsg()
    $Pos = MouseGetPos()
    Sleep(10)
    $Pos2 = MouseGetPos()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
        EndSelect
WEnd
; ============================================================================
; Functions
; ============================================================================
Func _Toggle()
    If $Show = True Then
        Global $Show = False
        GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>_Toggle

edit: It appears to be a non functioning scroll bar, -trying to kill it now.

Edited by Hatcheda
Link to comment
Share on other sites

@Valuanter - Can you help me get rid of the defunct scroll bar.

Edit: My last resort would be to have the right side be a second gui floating over the first.

@Dale Thanks for reading :0)

Edited by Hatcheda
Link to comment
Share on other sites

No, but it looks like a cool separator...

added drag window

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

Global Const $WM_LBUTTONDOWN = 0x0201
;Global Const $WM_SYSCOMMAND = 0x0112

HotKeySet("{ESC}", "_Toggle")

$Show = False

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()

;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 840, 600, Default, Default, $WS_POPUPWINDOW)
;$GUI = GUICreate("", 840, 600, Default, Default)

;GUICtrlCreateObj ( $ObjectVar, left, top [, width [, height ]] )
$GUIActiveX = GUICtrlCreateObj($oIE, -176, -130, 800, 800)
$GUI_Button_Back = GUICtrlCreateButton("Back", 650, 20, 60, 20)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 650, 50, 60, 20)
$GUI_Button_Home = GUICtrlCreateButton("Home", 650, 80, 60, 20)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 650, 110, 60, 20)

_IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
GUISetState(@SW_SHOW, $GUI);Show GUI

GuiRegisterMsg($WM_LBUTTONDOWN, "_WinMove")

; ============================================================================
; Main Loop
; ============================================================================
While 1
    $msg = GUIGetMsg()
    $Pos = MouseGetPos()
    Sleep(10)
    $Pos2 = MouseGetPos()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
        EndSelect
WEnd
; ============================================================================
; Functions
; ============================================================================
Func _Toggle()
    If $Show = True Then
        Global $Show = False
        GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>_Toggle

Func _WinMove($HWnd, $Command, $wParam, $lParam)
    If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0)
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

No, but it looks like a cool separator...

Hey, thanks! I've never seen that! :)

my last revision set the width heigth at 1024, 600 wich is the resolution of the umpc I hope to get, so I may not be able to use it there, but Im keeping a copy on my desktop and that solves all kinds of issues ^_^

Link to comment
Share on other sites

Doesn't look like it is an IE scrollbar or this would get rid of it:

$oIE.document.body.scroll="no"

and it doesn't

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

thats strange. (if you expand the heigth a little, you can see it as a dead scrollbar. -atleast looks that way)

earlier, I thought it was because there was a vertical scrollbar. So I expanded the vertical aspect to get rid of the functioning vertical scrollbar. (worked)

I cant do this with the other one. It changes from working, to what it is now. maybe I set it to working, then added your code . . .

Edited by Hatcheda
Link to comment
Share on other sites

Hey, I wasnt sure where to put it so I put it in three places.

It doesn't seem to work even when I turn the scroll bar back on by sizing too small.

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

Global Const $WM_LBUTTONDOWN = 0x0201
;Global Const $WM_SYSCOMMAND = 0x0112

HotKeySet("{ESC}", "_Toggle")

$Show = False

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
$oIE.document.body.scroll="no"



;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 1024, 600, Default, Default, $WS_POPUPWINDOW)

;GUICtrlCreateObj ( $ObjectVar, left, top [, width [, height ]] )
$GUIActiveX = GUICtrlCreateObj($oIE, -176, -130, 800, 750)
$oIE.document.body.scroll="no"


$GUI_Button_Back = GUICtrlCreateButton("Back", 650, 20, 60, 20)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 650, 50, 60, 20)
$GUI_Button_Home = GUICtrlCreateButton("Home", 650, 80, 60, 20)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 650, 110, 60, 20)

_IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
$oIE.document.body.scroll="no"


GUISetState(@SW_SHOW, $GUI);Show GUI

GuiRegisterMsg($WM_LBUTTONDOWN, "_WinMove")

; ============================================================================
; Main Loop
; ============================================================================
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://traffic.houstontranstar.org/layers/#")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
        EndSelect
WEnd
; ============================================================================
; Functions
; ============================================================================
Func _Toggle()
    If $Show = True Then
        Global $Show = False
        GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>_Toggle

Func _WinMove($HWnd, $Command, $wParam, $lParam)
    If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0)
EndFunc

edit: off the the long haul home. -check back in 90 :)

Edited by Hatcheda
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...