Jump to content

Display Part of a webpage in Gui


Recommended Posts

Using GuiCtrlCreateObj I can display a web page in my gui. The Gui's dimensions are only so big and I want a portion of the page that isn't in the upper left hand corner to center in it. I wasn't sure if the way to do that was with an IE function or with a Gui one so I'm starting in this forum instead of the gui one.

Bad: Starts in the upper left hand corner of the page.

Posted Image

Good: Introduction header is in the upper left hand corner

Posted Image

Ideally, I'd like to force it to show the area without scroll bars but at this point I'd be happy to just be able to default it it to a certain location. What functions should I be looking at to help me accomplish this?

Edited by muncherw
Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

Post the code you've used to get close and I'll help you tweak it.

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

Post the code you've used to get close and I'll help you tweak it.

Dale

Thanks for the response, Dale. I didn't post anything because so far all I have is the code from the help file. Since you answered I'll start sifting through your UDF and see if there is something in there that looks right to me. I'll update if I get a chance to create some new code. Edited by muncherw
Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

  • 2 weeks later...

CODE
$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output

$hGUI = GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))

$GUIActiveX = GUICtrlCreateObj ($oIE, 10, 40, 490, 500)

GUISetState() ;Show GUI

$oIE.navigate("http://www.autoitscript.com")

_GUIScrollBars_Init($hGUI)

_GUIScrollBars_SetScrollInfoPos($hGUI, 50, 0)

I am *guessing* that maybe these scroll bar functions are what I want however I can't get it to display anything different.

Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

CODE
$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output

$hGUI = GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))

$GUIActiveX = GUICtrlCreateObj ($oIE, 10, 40, 490, 500)

GUISetState() ;Show GUI

$oIE.navigate("http://www.autoitscript.com")

_GUIScrollBars_Init($hGUI)

_GUIScrollBars_SetScrollInfoPos($hGUI, 50, 0)

I am *guessing* that maybe these scroll bar functions are what I want however I can't get it to display anything different.

That's not an example script, that needs fixing just to work... So we can help you fix the real problem. Maybe you are just being lazy.... then I will too!

... I'm not doing it!

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

That's not an example script, that needs fixing just to work... So we can help you fix the real problem. Maybe you are just being lazy.... then I will too!

... I'm not doing it!

8)

Not sure what you are saying, Valuater, about this not needing fixing. I took the bits of the scroll bar stuff and combined it with the gui embedded stuff. This is just the snippit I think is relavant but obviously it doesn't work. I can't actually see it does anything.  I just want to figure it out on an example so I don't have to sift through extraneous code. You tell me what you think I should be showing you and I'll be happy to provide it. Not being lazy, just being confused. Thanks for the help.
Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

Here's one I did, and I know Dale can show you how to remove the Scroll Bars/

; This is a demonstration for Object Create, similar to Level I.
; We are using AU3Info to get the Pixel search color.

#include <GuiConstants.au3> 

Dim $My_Color = 0xA8FF93 ; from AU3Info.
Dim $Game, $MID
HotKeySet("{F8}","Get_coord")
HotKeySet("{F9}","Game_Bot")



Opt("MouseCoordMode", 0)        ;see Level I or Search Help for "options".
Opt("PixelCoordMode", 0)       

GUICreate("Object - Game Bot", 614, 370) 
GUISetFont(9, 400, -1, "MS Sans Serif") 
$B_oIE3 = ObjCreate("Shell.Explorer.2") 
$Breaktime = GUICtrlCreateObj($B_oIE3, -45, -320, 540, 680 )
$html2 = "about:<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><Text>..........  Game Bots... Yes, You can Create Game Bots in AutoIt. <br><br>........... Check this easy one out!...   Please Press *Enter Game* </Text>"
$B_oIE3.navigate ($html2) 
GUICtrlCreateLabel ("*Game Bots*", 503, 80,150)
GUICtrlSetFont( -1, 12, 700)
GUICtrlCreateLabel ("PixelSearch", 505, 120,150)
GUICtrlSetFont( -1, 12, 700)
$BrkStart = GUICtrlCreateButton("&Enter Game", 505, 300, 80, 25)
$BrkEnd = GUICtrlCreateButton("&Exit", 505, 330, 80, 25)
GUISetState() 

While 1 
    
    $msg = GUIGetMsg() 
    
    If $msg = $GUI_EVENT_CLOSE Or $msg = $BrkEnd Then 
        Exit
    EndIf
    
    If $msg = $BrkStart Then 
        ;http://av.vet.ksu.edu/flash/curveball/curveball.swf
        $B_oIE3.navigate ("http://www.albinoblacksheep.com/flash/curveball.php")
        Sleep(1500) ; wait to load
        $B_oIE3.navigate ("http://www.albinoblacksheep.com/flash/curveball.php")
        Sleep(1500) ; bypass the advertisement
        MsgBox(262208, "How to Play", "Move the Racket to Hit the Ball   " & @CRLF & "Or, Press [F9] to Use the Game Bot    ")
        ToolTip('Press (F9) to Use the Game Bot',0,0)
    EndIf
    
WEnd 

Func Game_Bot() ; if $Game then $Game = True, If Not $Game then $Game = False, maybe think of $Game as "1".
    $Game = NOT $Game 
    If $Game Then ToolTip('Press (F9) to Exit Game Bot',0,0)
    While $Game ; search left, top, right bottom for my color, color varience of 50 shades, check every 10 pixels.
         $ball = PixelSearch( 49, 75, 430, 330, $My_Color, 50, 10) 
        If Not @error Then MouseClick("left", $ball[0], $ball[1], 1, 0)
    WEnd
    ToolTip("")
EndFunc

Func Get_coord() ; press F8 to get mouse coordinates
    $MID = NOT $MID
    While $MID
        $pos = MouseGetPos()
        ToolTip('Mouse coordinates     ' & @CRLF & " X = " & $pos[0] & @CRLF & " Y = " & $pos[1],0,0)
        Sleep(20)
    WEnd
    ToolTip("")
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Since Dale has done most all the functions you'll need for IE, I'd suggest using IE.au3 for browser functions.

Here's an example of scrolling.

#include <GuiConstantsEx.au3>
#include <windowsconstants.au3>
#include <IE.au3>

Global $oIE = _IECreateEmbedded()
; Create a simple GUI for our output

Global $hGUI = GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))

Global $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 490, 500)

_IENavigate($oIE, "http://www.autoitscript.com")

Global $o_doc = _IEDocGetObj($oIE)
$o_doc.DocumentElement.ScrollTop = 140
$o_doc.DocumentElement.ScrollLeft = 170

GUISetState()
While GUIGetMsg() <> -3
WEnd
Probably not up to Dales standards, but you should get the drift ^_^ ...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

And here's the missing piece:

; Get rid of scrollbars
If IsObj($oIE.document.documentElement) Then
    ; HTML4 transitional or strict
    $oIE.document.documentElement.style.overflow = "hidden"
Else
    ; IE in quirks mode
    $oIE.documentElement.scroll = "no"
EndIf

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

These examples are great. I think SmOke_N showed me what I needed with $o_doc.DocumentElement.ScrollTop and $o_doc.DocumentElement.ScrollLeft where as I  had given up on it being part of IE and thought it was the gui that was making the scroll bars so was trying to use _GUIScrollBars_SetScrollInfoPos. I'll come back with what I have if I get time to work on this today.

Thanks Valuater, SmOke_N and Dale!

Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
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...