Jump to content

Affect Web Page


Recommended Posts

I am trying to figure out how to affect the code on a web page via AutoIt but have not had any luck thus far. I've gone through the forums and experimented but I've still not been able to come to a solution.

The scenario: at my company we primarily use Xerox MFD's for printing, scanning, and copying. These machines rely on a central network share to store scanner templates. The scanner templates define who can scan and supplies the Xerox MFD's with the location for which to save the user's scanned documents. This template repository is supposed to be scanned by each Xerox machine daily to refresh and update its local copy of the scanner templates, which is an internal function of the Xerox MDF's. However, this function is extremely flaky and most often does not work.

I can manually force a template refresh but this is not an effective use of anyone's time. What I'd like to do is circumvent the built-in refresh and run a script that will open a browser, browse to the appropriate page of each Xerox machine and engage the manual refresh function which is rock solid. Verily, this is wherein lies my problem. I am not by any means familiar with java or how to interact with code present on a web page. I've been able to extract the following code which is what I believe I need to engage:

CODE

//=============================================================================

// Name: SetRefreshNowToTrue()

// Purpose: This function will submit a form that will make the refresh templates

// now flag to true.

// Inputs: none

// Output: nothing

//=============================================================================

function SetRefreshNowToTrue()

{

var theForm = document.forms[sET_REFRESH_NOW_FLAG_FORM];

// set a flag in the parent to indicate not to display the changes

// saved successfully (and to generate the pop-up)

parent.gUpdatingTemplateListNow = true;

// submit the form now

theForm.submit();

}

I'd like to also throw a thank you out to DaleHolm who's code suggestion helped me navigate through the java based menu tree on these Xerox machines, but I did run into a problem where once the code was executed, even though it seemed to run, once it completed running the code the AutoIt script would stop on an error and not process any code downstream from the error; but the code did work! This is the code from DaleHolm:

$sReturn = IEEval($oIE, "onForgetMe(0);")

Func IEEval($o_object, $s_eval)
    Return $o_object.document.parentwindow.eval($s_eval)
EndFunc   ;==>IEEval

Thank you in advance for any suggestions.

Link to comment
Share on other sites

Thank you, Valuater! I incorporated your code into my script but it did not work. It appears to be the same problem I had with DaleHolm's code, in that every time the script attempts to take action on $o_object, or $oIE, an error is generated and the script halts.

Specifically, I see the script halting at "Return $o_object.document.parentwindow.eval($s_eval)", although each call to IEEval() seems to execute because the web page opens up to the appropriate place.

For troubleshooting I commented out the IEEval() lines and just went with the SetRefreshNowToTrue() function, because the web page seems to be cached in such a way that it just opens to the correct place. However, SetRefreshNowToTrue() returns an error just as IEEval() does and I can't determine if the code did what I expected it to do.

Perhaps this is a product of my environment or this web page specifically?

Does anyone have any ideas of how I might troubleshoot this? I can look for a non-Xerox web page to play with in my environment. For reference I have embedded my script below:

#include <IE.au3>

$oIE = _IECreate("<IP_ADDRESS>/properties/index.dhtml",0,1,1,1)

$sReturn = IEEval($oIE, "FolderSelected('f49','i49');")
$sReturn = IEEval($oIE, "FolderSelected('f60','i60');")
$sReturn = IEEval($oIE, "NodeSelected('n61');")

SetRefreshNowToTrue($oIE)

;****************************************************
;***************** Custom Functions *****************
;****************************************************

Func IEEval($o_object, $s_eval)
    Return $o_object.document.parentwindow.eval($s_eval)
EndFunc   ;==>IEEval

Func SetRefreshNowToTrue($o_object)
    If Not IsObj($o_object) Then Return -1
    $theForm = $o_object.document.forms("SET_REFRESH_NOW_FLAG_FORM")
    $o_object.parent.gUpdatingTemplateListNow = True
    $theForm.submit()
EndFunc   ;==>SetRefreshNowToTrue
Link to comment
Share on other sites

Please provide specifics on the error that is generated. You may need to dig into the onForgetMe script and troubleshoot based on its logic (DebugView will show you the script source).

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