Jump to content

need helpe with WebBrowser Object


 Share

Recommended Posts

i design a web Browser program ..

and i face some problem with some command ..

the problem is when i open a link with new window in my program web Browser ..

the new window will opean in the Internet Explorer ..

microsoft provide a solution and it is in the below page

How To Cause Navigation to Occur in Same WebBrowser Window

http://support.microsoft.com/kb/185538/EN-US/

i use this solution in my program , but it's still opean with Internet Explorer when i opean a new window

this is an example of my program code ..

#include "GUIConstants.au3"
$GUIMain=GUICreate            ( "Event Test",      600,535 ,0,0)
$GUIEdit=GUICtrlCreateEdit    ( "Test Log:" & @CRLF,  10, 20, 580, 50)
$GUIProg=GUICtrlCreateProgress  (                      10,  5, 580,  10)
$GUIExit=GUICtrlCreateButton    ( " Close ",          250, 515, 80,  20)
GUISetState ()    
$oIE = ObjCreate("Shell.Explorer.2")
$CreateObj = GUICtrlCreateObj($oIE, 10, 80, 580, 430)
$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents")
$URL = "http://www.w3schools.com/js/tryit.asp?filename=tryjs_openwindow"
$oIE.Navigate( $URL )          
sleep(1000)          
GUISwitch ( $GUIMain )  
While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE or $msg = $GUIExit Then ExitLoop
Wend



; A few Internet Explorer Event Functions
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/webbrowser.asp

Func IEEvent_BeforeNavigate($URL, $Flags, $TargetFrameName, $PostData, $Headers, $Cancel)
;   Note: the declaration is different from the one on MSDN.
    GUICtrlSetData ( $GUIEdit, "BeforeNavigate: " & $URL & " Flags: " & $Flags & " tgframe: " & $TargetFrameName & " Postdat: " & $PostData & " Hdrs: " & $Headers & " canc: " & $Cancel  & @CRLF  , "append" )
EndFunc

Func IEEvent_ProgressChange($Progress,$ProgressMax)
    If $ProgressMax > 0 Then
        GUICtrlSetData($GUIProg, ($Progress * 100) / $ProgressMax )
    EndIf
EndFunc

Func IEEvent_StatusTextChange($Text)
    GUICtrlSetData ( $GUIEdit, "IE Status text changed to: " & $Text & @CRLF  , "append" )
EndFunc

Func IEEvent_PropertyChange( $szProperty)
    GUICtrlSetData ( $GUIEdit, "IE Changed the value of the property: " & $szProperty & @CRLF  , "append" )
EndFunc

Func IEEvent_DownloadComplete()
    GUICtrlSetData ( $GUIEdit, "IE has finished a navigation operation" & @CRLF  , "append" )
EndFunc

Func IEEvent_NavigateComplete($URL)  
;   Note: the declaration is different from the one on MSDN.
    GUICtrlSetData ( $GUIEdit, "IE has finished loading URL: " & $URL & @CRLF  , "append" )
EndFunc

Func IEEvent_($EventName)  
; This is an optional event function to catch non-defined events. 
; The parameter contains the name of the event being called.
    GUICtrlSetData ( $GUIEdit, "Uncatched event: " & $EventName & @CRLF  , "append" )
EndFunc 


Func IEEvent_NewWindow($URL , _
                            $Flags, _
                            $TargetFrameName, _
                            $PostData, _
                            $Headers, _
                            $Processed)
$Processed = True
MsgBox(4096, "Test", $URL, 10)

EndFunc

i attach this code in the attachment ...

plz i need ur helpe as soon as possible ...

and thanx alot

Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

The AutoIt event handling model, unfortunately, handles events asynchronously. Therefore, you don't hear about the event in AutoIt until it is already occurred in your cancel operation has no effect

You still may be able to do this however by inserting Javascript into the webpage. Please take a look at _IEHeadInsertEventScript

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 Problem when opening a new window on the webBrowser object the new window will open in the Internet Explorer

Posted Image

_IEHeadInsertEventScript

The Javascript can not control all command new windows And also must Wait page load before

Inserts a Javascript into the Head of the document

صرح السماء كان هنا

 

Link to comment
Share on other sites

If you must affect windows that are created as part of the onload for the document, there there is not likely to be a good answer for you here - you'll probably want to pick another language. You can tell _IECreate not to wait for the load to be complete and you can monitor readyState on your own with _IEPropertyGet and interact as soon as it is writable, but this still may not be enough for you. You can also use Javascript or VBScript from within AutoIt with the ScriptControl object (search the forum) and the Eval method, but you are really stretching the model to do that and you may again just be better off using a language that allows you to insert yourself into the event processing loop.

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

document Object

http://msdn2.microsoft.com/en-us/library/m...073(VS.85).aspx

DHTML Events

http://msdn2.microsoft.com/en-us/library/m...051(VS.85).aspx

_IEHeadInsertEventScript

Javascript commands

All these ways can not control the opening windows

New

the Solution

DWebBrowserEvents

http://support.microsoft.com/kb/185538/EN-US/

Func IEEvent_NewWindow($URL , _
                            $Flags, _
                            $TargetFrameName, _
                            $PostData, _
                            $Headers, _
                            $Processed)



$Processed = True

EndFunc

or

http://msdn2.microsoft.com/en-us/library/a...335(VS.85).aspx

Func object_NewWindow( _
    $ppDisp , _
    $Cancel)
    
Dim $Cancel = True
EndFunc

Thanks for help

Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

From your response, I really have no idea whether you found something that worked for you or not.

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