Jump to content

disable refresh on gui embedded browser


Recommended Posts

Hi guys,

I'm kinda running into trouble here. I've 2 questions:

1) Is there a way to programatically disable the refresh option on an embedded browser within a gui?

Reason: If the browser is embedded in the gui then for many automation purposes, navigation should be under the gui's control, otherwise there's not much point in embedding.

I have found a few references on the internet, including some that say that the task is merely impossible, but then again, I found a javascriptwhich claims to do just that.

The relevant extract from webmasterworld.com is:

You can, but you basically have to disable a other things as well, including right click, the toolbar and button bar (using window.open with options).

//disable right mouse click Script 
document.onmousedown="if (event.button==2) return false"; 
document.oncontextmenu=new Function("return false"); 

document.onkeydown = showDown; 

function showDown(evt) { 
evt = (evt)? evt : ((event)? event : null); 
if (evt) { 
if (event.keyCode == 8 && (event.srcElement.type!= "text" && event.srcElement.type!= "textarea" && event.srcElement.type!= "password")) { 
// When backspace is pressed but not in form element 
cancelKey(evt); 
} 
else if (event.keyCode == 116) { 
// When F5 is pressed 
cancelKey(evt); 
} 
else if (event.keyCode == 122) { 
// When F11 is pressed 
cancelKey(evt); 
} 
else if (event.ctrlKey && (event.keyCode == 78 ¦¦ event.keyCode == 82)) { 
// When ctrl is pressed with R or N 
cancelKey(evt); 
} 
else if (event.altKey && event.keyCode==37 ) { 
// stop Alt left cursor 
return false; 
} 
} 
} 

function cancelKey(evt) { 
if (evt.preventDefault) { 
evt.preventDefault(); 
return false; 
} 
else { 
evt.keyCode = 0; 
evt.returnValue = false; 
} 
}

2) is there a way to avoid launching browser instances from within the gui?

Reason: Pretty much the same as reason for 1) really, but it would be counterproductive for automation if the user could launch another explorer window by pressing ctrl+n key combination.

I suppose that a javascript modification in pretty much the same manner as webmasterworld.com 's suggestion above could also do the trick.

In any case, If anyone has a better solution to either of these 2 questions, the a hint or possibly even better a suggested script would be greatly appreciated.

for now my main idea would be to have an adlib function that checks for those keypress combinations, however, here's the catch, once those combinations have taken place, should I use something like

#include <IE.au3>

_IEAction ( $o_object, "stop")

. I believe that if the explorer has the control, then it's probably better to get it to do the event refresh or alunch new browser cancelling.

Thanking you all in advance,

Regards,

IVAN

Edited by ivan
Link to comment
Share on other sites

any clues?

Ivan,

This is really complicated stuff and it is beyond the direct design scope of IE.au3, however it is possible.

You will need to tap into the event model and you will have to inject javascript into the page instead of trying to process the events from AutoIt... you cannot process these events from AutoIt because AutoIt handles them asynchonously and the event will typically already have been processed in the browser before your script has a changce to intervene. Scripts running in the browser work synchorously.

You can learn from the script above and from MSDN and you can use _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

Cheers Dale,

First, I must say I needed this for the rich media stuff I'm building, so Internet navigation is not really necessary, just the browser embedded in the gui to display cool stuff.

now, the html page is actually written on the hard drive using fileopen, filewriteline and fileclose, which gives me more control over what happens. In fact, this is where i can either write another file.js which is called from the html page stored on the hard drive, or i can write the script straight into the html page.

Once the page file exists in say, in temp dir, then i can navigate to it with ie.au3. Having said that, it does not imply that graphical resources be downloaded to the computer, or for that matter, to send and/or receive info from a server.

Also, it is possible to change info directly from html elements, such as table cells, so data updating can be performed sooner or later.

Unfortunately, my attempts at embedding the above script are not successful, yet, because I think the browser refusus to load the js or execute the <script> in the <head> section.

Regards,

Ivan

Link to comment
Share on other sites

I have a partial solution?

After the browser has been embedded in the gui and the first page has been displayed like shown in the extract below:

$GUIActiveX = GUICtrlCreateObj($oIE, 25, 100, 550, 200)

GUISetState()

_IENavigate ($oIE, $HtmlPage)

_IELoadWait ($oIE)

One can always change the state of the activeX control with $GUI_ENABLE/$GUI_DISABLE.

This provides a graphical display but kills any interaction the user can have with the browser, even the scroll bars.

IVAN

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