Jump to content
Macro Express Forums

external scripts - super frustrated


Recommended Posts

so i've had this mxpro software since about this past March 2014... i believe that it's the best thing since sliced bread and i've created some really powerful routines using it and have only recently found that this forum existed after searching for some assistance for some scenarios which i've 'hit a wall' with.

i believe that i've exhausted the provided programming parameters of mxpro for a few scenarios which i've encountered. at this point, i've been learning a bit of java, c, and vb out of the need to expand the capabilities that i thought i might be able to utilize using the 'external script' function.

 

i've searched this forum and others' for a solution but have not found anything which satisfies the requirements of what i envision. having said that, please forgive me if i may have overlooked a similar thread which has already covered this topic.

 

I'm looking to automate the entry of contents into a web form coded in html/java... fields and button(s).

i have seen routines in java and vba which can manipulate the data as i envision it.

thus, i thought that i could implement those scripts into my routine to manipulate the form as well....however, it seems that there are specific parameters which the external script command can accommodate.

 

for the record, i have successfully created a mxpro routine which does exactly what i want; however, since there are a few mouse movements involved, the routine will not execute reliably if the window is not sized properly, or if there are different text sizes or zoom properties. and tabbing thru fields DOES work, however, the webpage reacts differently if there are values entered into some fields and thus the amount of tabs can differ based upon what fields have values and those that do not. so the Tab order can change.

 

what i need to do is 3 things(in Internet Explorer):

1. copy the source code of a webpage(which i have already successfully done using right click and moving down the right click menu to 'view source' - there are frames in the page so ctrl>U doesn't work); additionally, i would like this to occur without opening a separate view source window;

2. be able to enter data directly into a form field based upon its field ID/name/value(in other words, not using Tab to move to the field to manipulate its contents);

3. be able to click on a 'submit' button using its name/ID/value(not using the mouse).

 

-the above, all without using the keyboard or mouse. ultimately, i need the routine to be scalable... meaning whatever the user preferences are(i.e. Internet Explorer zoom setting, window size, text size, etc etc) the routine needs to still complete as programmed.

 

i figure that using other programming languages which are more suitable to manipulating web pages and its contents would only expand the ability that mxpro routines can accomplish.

 

i have downloaded, viewed, and ran the external scripts which the gentleman from Insight wrote years ago which all work fine... however, creating my own scripts yielded ONLY the simple "Hello World" output to console from VB's 'MsgBox("Hello World!")' command to print to the console... console.log("Hello World") doesn't output, nor does System.out.println("Hello World"); anything that i have tried does not log to the console or function as it would in an API. i have changed the output type or language type to match the entered type within the 'external script' command. i tried these simple examples to test the external script function... let alone more complex routines to complete the 3 scenarios i outlined above.

 

any suggestions are appreciated and sorry for the long post! just wanted to be thorough. i'm sure more info may be necessary which i can provide.

Link to comment
Share on other sites

duchi-

 

Nice post, indeed. Very understandable.

 

Read this article covering the interface between MXPro's External Script and Internet Explorer. It will be a starting point for you to see how the DOM on IE web pages are accessed and read via MXPro without having to download the source page, or use the mouse or the tab. It does not cover writing data into fields, at least not that I remember. Placing data into fields without using the mouse or tab key is very, very easy to do in the IE DOM with MXPro.

 

Here also is a link to a 10 minute preliminary video covering a product I am working on which is, more or less, an interface between MXPro, HTML, VBScript and Javascript.

Link to comment
Share on other sites

thank you for your quick response Joe! and Cory via PM.

all i can say is wow!... i am enlightened. i have just read the article and i apologize for not checking the Articles first... i had read the first 3 but had not yet made it down to Anchors Aweigh. thought is was about boating or pirates and not a clever pun. :rolleyes:

 

guess i'll need to get to learning VB or .net or something that can better manipulate the DOM of a webpage.

 

i also watched the vid and think that the application is brilliant!

Link to comment
Share on other sites

Joe, your code sample hints at the potential of using External Scripts. Thank you for sharing. But there are a lot of details to understand.

 

Would you consider posting code samples for simpler tasks? For example, how to activate a hypertext link, "click" a pushbutton, or pick a radio button.

Link to comment
Share on other sites

Alan, it seems like you're attempting to automate something very similar to what i am looking to accomplish.

i've been searching high and low for a couple months now for ways to use java, or vb, or something similar to fill fields and click buttons and finally came across this series which the info in the article got me to thinking:

https://www.youtube.com/playlist?list=PL6OYc4rwKjcOu3UL7LYpvO_S2waYO-hVU

it's about web scraping using excel but he goes thru and explains ALOT of VBA scripting to accomplish it. it's very intuitive and goes on to how to create and use forms and form controls and assigning tasks to those controls for much of the same logic you and i are looking for

thought this might be of some help here regarding external scripts with automating processes using mxp.

Link to comment
Share on other sites

  • 3 weeks later...

after months of sorting out programming code, i've FINALLY been able to get VB coding to work in not only Excel but in mep as well in the external script function...i pieced this together from the youtube series i referenced above.

i'm posting it to save people from going thru what i went thru to search for something "simple" to manipulate a form on a webpage.

you'll have to modify it to fit your specific requirements but this will give you a very good start.

 

what it does:

it will designate and open an Internet Explorer window with the website you specify.

it will automatically populate username and password fields with data you specify.

it will 'click' on a button to submit the form and logon to the website.

 

remarks:

the line 'DoEvents is not an accepted statement in mep; thus it has been commented out.

this is just a start... it is not a do all fix all type script.

i've tested this and it works within the mep environment under VBscript.

you will need to modify some of the coding to adapt to your requirements...specifically the html tags that the data you need is contained within which could be: name, ID, or value. edit - i couldn't change the color of the elements that should be changed... the 'TagName' modifier of objIE.Document.getElementsByTagName in the For loops should be changed to the tag identifier which suits your requirements.

the items marked in GREEN need to be modified to fit your requirements.(except "InternetExplorer.Application") i couldn't change the color of this since it appears as a string in quotes in the code snippet and inherits this color code.

obviously feel free to re-name the variables to whatever you desire.

there is no encryption for the fields available in this script. if someone can see this script, your script password contents are visible as well.

 

this can be tailored to fit the needs of various requirements and not just a logon screen.

it can be thought of as being similar to the 'remember me' or autofill type website automation; however it can be modified to do a lot more than just a username and password autofill.

be sure to review the TOS of any website you use this on.

 

i use this with a hotkey combo to open a browser and auto logon to a website which i use daily and it works perfectly.

hopefully you can utilize it for your use as well if it requires this type of automation.

 

the cool thing about using this is that there is no tabular navigation or mouse manipulations required... it can be used in an Internet Explorer window with any zoom setting and window size and almost any version(i think). completely scalable as i would describe it...and super fast and efficient.

set objIE = createObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate ("http://www.your_website_goes_here.com")
 
''make sure page is fully loaded
Do
''DoEvents
        If Err.Number <> 0 Then
        objIE.Quit
        Set objIE = Nothing
    End If
Loop Until objIE.ReadyState = 4
 
 
''auto enter field data into webpage
Set the_input_elements = objIE.Document.getElementsByTagName("input")
For Each input_element In the_input_elements
    If input_element.getAttribute("name") = "field_tag_goes_here" Then
       input_element.Value = "enter_user_name_here"
       End If
    If input_element.getAttribute("name") = "field_tag_goes_here" Then
       input_element.Value = "enter_password_here"
       Exit For
       End If
Next
 
''click on Login button
Set the_input_elements = objIE.Document.getElementsByTagName("input")
For Each input_element In the_input_elements
    If input_element.getAttribute("name") = "name_of_button_goes_here" Then
       input_element.Click
       Exit For
       End If
Next
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...