shx Posted January 19, 2009 Share Posted January 19, 2009 I see that the IE management can allow an auto it application to navigate fill in information and submit forms and web pages. My question is that I want to present a web page but not allow the user to click on certain links and buttons on that page. Does the udf have this functionality? I thought that the InternetExplorer.Application object it is using has a before navigate event. That would be something that might work. where, if i could fire off some code to check on the destination url before the navigations takes place I could prevent its navigation. any ideas would be appreciated. Thanks, Steven Link to comment Share on other sites More sharing options...
Valuater Posted January 19, 2009 Share Posted January 19, 2009 If you already know what you are looking for.... example from "Welcome to Autoit 1-2-3" ; Read the contents of the body of a webpage and search for a string. If the string is found, replace it ; with a new string and write it back to the webpage. #include <IE.au3> $oIE = _IECreate() _IENavigate($oIE, "http://www.autoitscript.com/") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "automation") Then MsgBox(0, "Success", "The string was found") $newbody = StringReplace($body, "automation", "AUTOMATION - Yeah!") _IEBodyWriteHTML($oIE, $newbody) Else MsgBox(0, "Fail", "The string was NOT found") EndIf Exit 8) Link to comment Share on other sites More sharing options...
shx Posted January 19, 2009 Author Share Posted January 19, 2009 If you already know what you are looking for.... example from "Welcome to Autoit 1-2-3" ; Read the contents of the body of a webpage and search for a string. If the string is found, replace it ; with a new string and write it back to the webpage. #include <IE.au3> $oIE = _IECreate() _IENavigate($oIE, "http://www.autoitscript.com/") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "automation") Then MsgBox(0, "Success", "The string was found") $newbody = StringReplace($body, "automation", "AUTOMATION - Yeah!") _IEBodyWriteHTML($oIE, $newbody) Else MsgBox(0, "Fail", "The string was NOT found") EndIf Exit 8) I see that it changes text that the user sees but I'm not sure how this would help. Are you saying to search for the link url and blank it out ? Steven Link to comment Share on other sites More sharing options...
Valuater Posted January 20, 2009 Share Posted January 20, 2009 Yes, that was one direction 8) Link to comment Share on other sites More sharing options...
shx Posted January 20, 2009 Author Share Posted January 20, 2009 (edited) Yes, that was one direction8)I was looking for a way to capture the before navigate event. I really would appreciate some help or direction with it.I found objevent function that might help me do what I need.Can someone tell me will it let me stop a navigation by checking the url the web browser is navigating to.ThanksSteven Edited January 20, 2009 by shx Link to comment Share on other sites More sharing options...
Valuater Posted January 20, 2009 Share Posted January 20, 2009 (edited) you can continually read the input ( where the URL is normally typed in ) and test it for a name or ??? #include <IE.au3> $oIE = _IECreate("www.autoit3.com") While 1 $URL = _IEPropertyGet($oIE, "locationurl") ToolTip($URL, 10, 10, "Thanks Valuater... 8) ", 1) Sleep(1000) WEnd 8) Edited January 20, 2009 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted January 20, 2009 Share Posted January 20, 2009 Edited 3 times... works now 8) Link to comment Share on other sites More sharing options...
DaleHohm Posted January 20, 2009 Share Posted January 20, 2009 (edited) Unfortunately, the way that AutoIt handles events does not allow you to cancel an event that has been triggered. AutoIt actually handles events asynchronously rather than synchronously and by the time you have a chance to work on it, it has already been fired. Therefore, you must either rewrite the links in the HTML code (As Valuater is suggesting) or you must add your own event functions to the links them in the HTML so that you can cancel the event processing synchronously. Take a look at _IEHeadInsertEventScript and _IELinkGetCollection. There is an example of doing this somewhere in the forum. Dale Edited January 20, 2009 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 More sharing options...
shx Posted January 20, 2009 Author Share Posted January 20, 2009 Unfortunately, the way that AutoIt handles events does not allow you to cancel an event that has been triggered. AutoIt actually handles events asynchronously rather than synchronously and by the time you have a chance to work on it, it has already been fired.Therefore, you must either rewrite the links in the HTML code (As Valuater is suggesting) or you must add your own event functions to the links them in the HTML so that you can cancel the event processing synchronously. Take a look at _IEHeadInsertEventScript and _IELinkGetCollection. There is an example of doing this somewhere in the forum.DaleValuater,Thanks for your help. I think the _IEHeadInsertEventScript is the direction which I want to go.Dale,Thanks for the answer. I looked at the _IEHeadInsertEventScript function, and it looks like I could use it to do what I need.Just one more question. Is there a good location where I can see a listing of the different objects and their associated events that the javascript could interface with. I see there is document, window, and link? being used in the examples.Thanks again for all your help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now