Jump to content

ObjGet/ObjCreate and WinGetHandle


Recommended Posts

I have a program that runs but fails when it completes the one step. Here is the code work:

#RequireAdmin
#include <IE.au3>

While Not Activate()
 $oIE = _IECreate("[url="http://www.yahoo.com"]www.yahoo.com[/url]")
WEnd

$oElements = _IETagNameAllGetCollection($oIE)
For $oElement In $oElements
;
 MsgBox(0, "System", $oElement.tagname)
;
Next

Func Activate()
 $sIE = WinGetHandle("Yahoo!")
; $oIE = ObjGet("", "InternetExplorer.Application")
 If @error Then
  MsgBox(0, "Application", "Returning False")
  Return False
 EndIf
 
 Return True
EndFunc

As you can see it works the first time but not the second time because there is no $oIE. How would you get this to work? I was trying the ObjGet but couldn't get it to work and I have no title to go off of.

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

So what are you trying to do? What doesn't work? What do you mean by "fails when it completes the one step"? How does it fail? What is "one step"?

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

I seem to get past the While if I have a current "Yahoo!" page or any to be specific. But I fail if I don't have it already up because of the $sIE meaning it is only one string when I _IETagNameAllGetCollection the function so I need to _IEattach the $sIE string to but I will get further into _IEAttach as I like to know what is happening and everything is sent.

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

Sorry, that's gibberish to me.

Please try using more words, more punctuation, and some examples/illustrations of what you are talking about. Be specific and don't assume that I start with any clue as to what you are trying to accomplish.

I don't want to have to run your code just to try to get a clue what you are talking about, but I did in this case. I got a huge stream of MsgBox's as I would expect from your code, so I have no idea what isn't working for you.

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

Sorry Dale perhaps my new set is a little clearer for you.

#RequireAdmin
#include <IE.au3>
Global $oIE

While Not Activate()
    $oIE = _IECreate("http://www.yahoo.com/")
WEnd

$oElements = _IETagNameAllGetCollection($oIE)
For $oElement In $oElements
;
; MsgBox(0, "System", $oElement.tagname)
;
Next
MsgBox(0, "System", "Completed")

Func Activate()
    $sIE = WinGetHandle("Yahoo!")
    If Not @error Then
        If Not IsObj($oIE) Then
            $oIE = _IEAttach($sIE, "embedded")
; There is a problem when you enter on a page with Yahoo! as a title
        Else
            MsgBox(0, $sIE, ObjName($oIE))
        EndIf
        MsgBox(0, "The URL", _IEPropertyGet($oIE, "locationurl"))
        Return True
    Else
        MsgBox(0, "Application", "Returning False")
        Return False        
    EndIf   
EndFunc

I hope this you can find out why it is wrong, I run it once and it runs fine but I leave the windows with the browser page still at Yahoo! and the thing fails.

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

Your code is quite convoluted - I'm certain there will be better ways of accomplishing your goal, but I really have no idea what it is.

Please describe, in some detail, what you are trying to do.

Dale

p.s. I've asked you in each reply what you are trying to do and so far you've made little attempt to explain. I won't ask again - I'll simply ignore your post and more on to more interesting questions.

Edited by DaleHohm

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