Jump to content

Help needed _IE resizing and displaying


sunburn
 Share

Recommended Posts

Hey sorry for needing help with this, but I've tried it 10 different ways and just don't have the knowledge base to make it happen everytime. Basically this is what I want. Use _IE to open a navigation window, do a bunch of stuff throughout the day, but when a something specific happens (ie a certain phrase is found in the html code), I want the window to be resized and displayed (whether its minimized, or in a different z-order/behind other windows, whatever) then scroll to where that information is at (typically at the bottom of the page). Below is my best stab at it.

In my research I've come up with several questions.

1) I would really appreciate someone correcting how to get my _IE windows handle (the title is always changing so it is unknown at the time of occurance, I am also working in other windows during that period which might have the text I'm triggering on, that being said, I'm just trying to dictate the original internet explorer window). Different ways to approach the problem are welcome.

2) Also I figured out how to scroll to the end, but how would I scroll only to where the html phrase I was triggering on is at (for example if it is only half way down the page). What would be the command to scroll right?

CODE

#include <IE.au3>

#include <WinAPI.au3>

;set an exit option

HotKeySet("^!x", "MyExit")

Func MyExit()

MsgBox(0, 'Premature ending message', "Auto it has exited script per your hotkey input-control alt x")

Exit

EndFunc ;==>MyExit

;Set Loadwait to 30seconds

_IELoadWaitTimeout(30000)

$oIE = _IECreate("http://www.airlinepilotforums.com/cargo/", 1)

msgbox (0,'','resize for test and close')

$winhdl = WinGetHandle($oIE)

_winAPI_setwindowpos($winhdl, "hwnd_top",0,0,400,774, "SWP_SHOWWINDOW")

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

$iDocHeight = $oIE.document.body.scrollHeight

$oIE.document.parentwindow.scrollTo(0,$iDocHeight)

msgbox (0,'','program ended')

Exit

Thanks again, sorry for the trouble

Edited by sunburn
Link to comment
Share on other sites

if u want to resize the actual IE window, use WinGetHandle("pilot.fedex.com") then you can use WinMove($winHandle, "", $x, $y)

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

In my research I've come up with several questions.

1) I would really appreciate someone correcting how to get my _IE windows handle (the title is always changing so it is unknown at the time of occurance, I am also working in other windows during that period which might have the text I'm triggering on, that being said, I'm just trying to dictate the original internet explorer window). Different ways to approach the problem are welcome.

#include <IE.au3>
#include <WinAPI.au3>

;set an exit option
HotKeySet("^!x", "MyExit")
Func MyExit()
    MsgBox(0, 'Premature ending message', "Auto it has exited script per your hotkey input-control alt x")
    Exit
EndFunc   ;==>MyExit

;Set Loadwait to 30seconds
_IELoadWaitTimeout(30000)

;check to see if fedex.com is open, if not open it
If WinExists("", "pilot.fedex.com") Then
    WinActivate('', "pilot.fedex.com")
EndIf

Global $winHandle = WinGetHandle("pilot.fedex.com") ; this will hold a handle to the windows regardless of the title text. I assume the text is correct at that time.

$oIE = _IECreate("http://www.airlinepilotforums.com/cargo/", 1)

MsgBox(0, '', 'resize for test and close')
$winhdl = WinGetHandle($oIE)
_WinAPI_SetWindowPos($winhdl, "hwnd_top", 0, 0, 400, 774, "SWP_SHOWWINDOW")
_IENavigate($oIE, "http://www.airlinepilotforums.com/cargo/")
$iDocHeight = $oIE.document.body.scrollHeight
$oIE.document.parentwindow.scrollTo(0, $iDocHeight)
MsgBox(0, '', 'program ended')
Exit

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

To get the handle, check out _IEPropertyGet($oIE, "hwnd")

If you can get an object reference to the element you want on the screen, you can use the .scrollIntoView() method... for example:

$oElement = _IEGetObjById($oIE, "myId")

$oElement.scrollIntoView()

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

Dale, Bo8ster and Authentisity

My internet has been off for a couple days, thanks to all, this a good start for me to run down now. Using a global to lock the handle is a great idea (thanks). Stand by for results.

Edited by sunburn
Link to comment
Share on other sites

CODE

; this will hold a handle to the windows regardless of the title text. I'm assuming the text is correct at that time.

Global $winHandle = WinGetHandle("","http://www.airlinepilotforums.com/cargo/")

; this will restore the window incase it was minimized

winsetstate ($winhandle, '', @SW_RESTORE)

;this will move the window to the top (so its definately visible)

WinSetOnTop ($winhandle,'',1); makes the window "hard on top" until you are done with it

;this will resize it so that it doesn't dominate the desktop

_WinAPI_SetWindowPos($winhandle, "hwnd_top", 0, 0, 400, 400, "SWP_SHOWWINDOW")

;this will alow the window to be minimized afterward

WinSetOnTop ($winhandle,'',0)

Ok, I've got everything working(as far as resizing and showing), but I opened up a new can of worms though trying this method of scrolling.

$oElement = _IEGetObjById($oIE, "myId")

$oElement.scrollIntoView()

I like how the .scrollintoview method goes straight to an object, but since I'm keying on a specific text, the closest object is not right where I want the window to be opened to......

So here is the question.....

How do I scroll left (or right) a specific amount?

Ive tried about 10 different variations, but it isnt working yet

CODE

;I grabbed an object that was close by the text I want to display and scrolled to it

$codebox = _IEGetObjByName($oIE, "nCTL")

$codebox.scrollIntoView()

;up to this point it all works, but what I need to do is now BACK UP (scroll left and up) just alittle. Maybe 50 coordinate places.......

; I tried this

With $oIE

.scroll (-40,-10)

EndWith

; and I tried this

$oIE.scroll (-40,-10); but no luck

;also

$oIE.SmallScroll Up:=5, ToLeft:=5

Basically I'm doing my research, but I think I need a lesson in using the msdn commands.

Link to comment
Share on other sites

The syntax is like this:

#include <IE.au3>

$oIE = _IECreate("www.autoitscript.com")

$oIE.document.parentwindow.scroll(x, y)

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

The syntax is like this:

#include <IE.au3>

$oIE = _IECreate("www.autoitscript.com")

$oIE.document.parentwindow.scroll(x, y)

Dale

Thanks Dale!

Ok now, now at least I'm getting a little response in my windows. This syntax allows me to scroll to a numeric value, but what i liked about the scrollintoview method, is that it went right to where an object was......

using this method ($oIE.document.parentwindow.scroll(x, y)), I have to specify exacty where i want it to scroll to. So now the question is how do i get that value from an object?

For example:

CODE

$codebox = _IEGetObjByName($oIE, "nCTL")

$nCTL.scrollintoview(); I now use this to scroll to an object close to the text i'm looking for (it is always present, like an enter box)

but what I really want to do is back up from this object by 50 in the x axis.

Is there a way to get a return on where that object lies? Then it would be simple, just subtract from that number and use the "$oIE.document.parentwindow.scroll(x [-50], y) as you suggest.

You see the problem is that the x, and y on the web page I'm going to are always changing, I just know that the text i'm looking for is close to the bottom of the page. some times on the right, sometimes on the left (which is why the scrollintoviw method was nice).

Sunburn

Inputs?

Link to comment
Share on other sites

.scrollBy(x, y)

Also, _IEPropertyGet() allows you to get coordinates of an object.

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

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...