Jump to content

Help with filling an online form


Gerson
 Share

Recommended Posts

Hi I'm writing a script to help me with my work. I'm working with databases and have to fill up forms on IE. This is as far as I've come.

#include <IE.au3>

WinWait("Home")

Local $hWnd = WinGetHandle("Home")

Local $sHWND = String($hWnd) ; Convert to a string

$oIE = _IEAttach ($sHWND, "HWND")

$oForm = _IEFormGetObjByName ($oIE, "MainForm")

$oText = _IEFormElementGetObjByName ($oForm, "temp_specification_Client")

_IEFormElementSetValue ($oText, "Orleans")

Whats the mistake?

Link to comment
Share on other sites

Hi Gerson,

1st Welcome to the AutoIt Forums! :idiot:

Some of the following tips may not apply to you, but it may make your life a bit easier here on the forum in the future.

CODE
  • Did you know that we have an awesome search feature?

    You can find many answers to your current questions, just by typing in the right search patterns.

  • A suggestion is to use the Advanced Search mode:

  • Type your specific search term in quotes.
  • Click the forum you want to search in (the one most likely to have your information would generally be the Example Script forum and or the General Help and Support Forum).
  • Click on "Search titles only" radio button.
  • Click perform search.
The above will help you narrow down your searches and prevent you from unneccesarily posting a new thread.

[*]Also, you should try to read the Sticky posts that are at the top of each of the AutoIt Forums you enter such as:

[*]Keep in mind, the help file will be your best friend, however you may find some of the tutorials written by some of our elite forum members helpful.

[*]Forum Etiquette:

  • Making a new thread:

    • Use the Search feature first to see if your question has already been answered.
    • Look in the help file as well before even thinking of posting (When what you want could be obtained by simply reading the help file, you don't generally get a good response from your AutoIt community).
    • Titles are very important here. 1 word titles or titles like "help me", "write something for me", "I'm a noob" etc... aren't tolerated.
    • Make sure you are posting in the correct forum:

      • General Help and Support:

        • This forum is for AutoIt related support questions only. If you have a question related to another language, or nothing at all to do with AutoIt then you need to post in the chat forum, or in that languages perspective forum.
      • Example Script:

        • This forum is for AutoIt scripts/executables only.
        • Source code is preferred but not necessary, you do have the right to just post the binary of your project if you wish.
        • Please don't post questions in this forum unless it's directly related to a thread already existing.
    • Use common sense when creating a new thread.

      Ask yourself if the title is descriptive enough to even interest someone (preferably those that know what they are talking about) to even look at your thread, let alone reply in it.

    • Think about how it would show in the search feature if someone were to look for something just like you are looking for (think of the keywords you used yourself and obviously didn't find anything (because we know you used the search feature :) ) and use those types of keywords in your title as well).
  • Thread content:

    • Be descriptive with your query. (Make sure we actually know what you want to do).
    • Show you've made an effort in coding what you want (provide the reproducer code (generally no more than 50 lines as people lose interest in debugging someones script for free)).
    • Don't talk in ebonics. A lot of the forum members are adults, and a lot of them know how to help you, but talk like a child, you'll be treated as such.
    • Don't ask for help making keyloggers, spam (even if it's to do as a prank), or anything that can be thought of as malicious. You'll more than likely have the thread locked by a moderator, and take a bashing from your fellow AutoIt community.
    • When posting code, use code boxes. This can be accomplished by using [code ]<content here>[/code ] (No spaces between the brackets []).

      Using code boxes will keep the indentation and make it easier to read for others to help you.

  • Bumping your threads:

    • Use common courtesy here.

      Keep in mind every time you bump your thread to the top of the forum, you knock the other threads down a notch.

      Everyone posting for help has just as much right for their threads to get read as you do.

      Because of that, do not bump your post more than once in a 24 hour period.

      A Bump is simply posting in your thread with nothing that pertains to your query with the sole purpose of moving it up.

      Deleting previous bumps, and posting new ones is not tolerated, and the moderators can find those deletions, so do yourself a favor and don't cross that line >_< .

  • Rude or obnoxious content:

    This falls pretty much under the common sense thing. If you use it (common sense) before posting, you won't have issues.

    • Don't use foul language, remember, a lot of the community is at work when they read these threads.
    • Don't provoke or instigate an argument with someone.
  • Double Posting:

    • It's understood that sometimes there's a lag in the system, and sometimes people don't see their post go up right aways so they post again.

      If this happens to you, simply notify a moderator with the report feature in the post, and politely ask them to delete it.

    • If you're just creating another topic because your original topic is not being answered the way you want or at all, this is not tolerated. You could lose your posting privileges all together over it.
  • Non-English languages

    • If English is not your primary language, please make an attempt to interpret (yourself or online) and post that interpretation.

      We have wonderful users from around the world, so after you've done your post in English, back it up with your question also in your native tongue (You may find your answer much quicker using both).

That's it for now, I hope you have a wonderful learning experience, and hope to see you contribute to the community as your knowledge grows.
Link to comment
Share on other sites

How far do you get? Where is it failing?

You don't need to convert the HWND to a string...

Local $hWnd = WinGetHandle("Home")
 
   $oIE = _IEAttach ($hWnd, "HWND")

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Hi Gerson,

1st Welcome to the AutoIt Forums! :idiot:

Some of the following tips may not apply to you, but it may make your life a bit easier here on the forum in the future.

CODE
  • Did you know that we have an awesome search feature?

    You can find many answers to your current questions, just by typing in the right search patterns.

  • A suggestion is to use the Advanced Search mode:

  • Type your specific search term in quotes.
  • Click the forum you want to search in (the one most likely to have your information would generally be the Example Script forum and or the General Help and Support Forum).
  • Click on "Search titles only" radio button.
  • Click perform search.
The above will help you narrow down your searches and prevent you from unneccesarily posting a new thread.

[*]Also, you should try to read the Sticky posts that are at the top of each of the AutoIt Forums you enter such as:

[*]Keep in mind, the help file will be your best friend, however you may find some of the tutorials written by some of our elite forum members helpful.

[*]Forum Etiquette:

  • Making a new thread:

    • Use the Search feature first to see if your question has already been answered.
    • Look in the help file as well before even thinking of posting (When what you want could be obtained by simply reading the help file, you don't generally get a good response from your AutoIt community).
    • Titles are very important here. 1 word titles or titles like "help me", "write something for me", "I'm a noob" etc... aren't tolerated.
    • Make sure you are posting in the correct forum:

      • General Help and Support:

        • This forum is for AutoIt related support questions only. If you have a question related to another language, or nothing at all to do with AutoIt then you need to post in the chat forum, or in that languages perspective forum.
      • Example Script:

        • This forum is for AutoIt scripts/executables only.
        • Source code is preferred but not necessary, you do have the right to just post the binary of your project if you wish.
        • Please don't post questions in this forum unless it's directly related to a thread already existing.
    • Use common sense when creating a new thread.

      Ask yourself if the title is descriptive enough to even interest someone (preferably those that know what they are talking about) to even look at your thread, let alone reply in it.

    • Think about how it would show in the search feature if someone were to look for something just like you are looking for (think of the keywords you used yourself and obviously didn't find anything (because we know you used the search feature :) ) and use those types of keywords in your title as well).
  • Thread content:

    • Be descriptive with your query. (Make sure we actually know what you want to do).
    • Show you've made an effort in coding what you want (provide the reproducer code (generally no more than 50 lines as people lose interest in debugging someones script for free)).
    • Don't talk in ebonics. A lot of the forum members are adults, and a lot of them know how to help you, but talk like a child, you'll be treated as such.
    • Don't ask for help making keyloggers, spam (even if it's to do as a prank), or anything that can be thought of as malicious. You'll more than likely have the thread locked by a moderator, and take a bashing from your fellow AutoIt community.
    • When posting code, use code boxes. This can be accomplished by using [code ]<content here>[/code ] (No spaces between the brackets []).

      Using code boxes will keep the indentation and make it easier to read for others to help you.

  • Bumping your threads:

    • Use common courtesy here.

      Keep in mind every time you bump your thread to the top of the forum, you knock the other threads down a notch.

      Everyone posting for help has just as much right for their threads to get read as you do.

      Because of that, do not bump your post more than once in a 24 hour period.

      A Bump is simply posting in your thread with nothing that pertains to your query with the sole purpose of moving it up.

      Deleting previous bumps, and posting new ones is not tolerated, and the moderators can find those deletions, so do yourself a favor and don't cross that line >_< .

  • Rude or obnoxious content:

    This falls pretty much under the common sense thing. If you use it (common sense) before posting, you won't have issues.

    • Don't use foul language, remember, a lot of the community is at work when they read these threads.
    • Don't provoke or instigate an argument with someone.
  • Double Posting:

    • It's understood that sometimes there's a lag in the system, and sometimes people don't see their post go up right aways so they post again.

      If this happens to you, simply notify a moderator with the report feature in the post, and politely ask them to delete it.

    • If you're just creating another topic because your original topic is not being answered the way you want or at all, this is not tolerated. You could lose your posting privileges all together over it.
  • Non-English languages

    • If English is not your primary language, please make an attempt to interpret (yourself or online) and post that interpretation.

      We have wonderful users from around the world, so after you've done your post in English, back it up with your question also in your native tongue (You may find your answer much quicker using both).

That's it for now, I hope you have a wonderful learning experience, and hope to see you contribute to the community as your knowledge grows.
what this guy said.
Link to comment
Share on other sites

Local $hWnd = WinGetHandle("Home")

   $oIE = _IEAttach ($hWnd, "HWND")

I made that change but it still doesn't work. The script runs through but the form elements don't get filled. I'm pretty sure of the form and element names. I used DebugBar to confirm those values.

This is the code I have so far to try filling up the first name of a yahoo mail signup form.

#include <IE.au3>
    WinWait("Yahoo")
    Local $hWnd = WinGetHandle("Yahoo")
    $oIE = _IEAttach ($hWnd, "HWND")
    $oForm = _IEFormGetObjByName ($oIE, "regFormBody")
    $oText = _IEFormElementGetObjByName ($oForm, "First Name")
    _IEFormElementSetValue ($oText, "PLEASE WORK!!!")

Where's the bug?

Link to comment
Share on other sites

Local $hWnd = WinGetHandle("Home")

   $oIE = _IEAttach ($hWnd, "HWND")

I made that change but it still doesn't work. The script runs through but the form elements don't get filled. I'm pretty sure of the form and element names. I used DebugBar to confirm those values.

This is the code I have so far to try filling up the first name of a yahoo mail signup form.

#include <IE.au3>
    WinWait("Yahoo")
    Local $hWnd = WinGetHandle("Yahoo")
    $oIE = _IEAttach ($hWnd, "HWND")
    $oForm = _IEFormGetObjByName ($oIE, "regFormBody")
    $oText = _IEFormElementGetObjByName ($oForm, "First Name")
    _IEFormElementSetValue ($oText, "PLEASE WORK!!!")

Where's the bug?

It could be possible that you are not waiting long enough for _IE to load

make these following changes and check it out

_IELoadWait($oIE,0, 20000)

after

$oIE = _IEAttach ($hWnd, "HWND")

this will wait till the page is loaded or till 20 seconds before it times out

so your code should look like this

#include <IE.au3>
    WinWait("Yahoo")
    Local $hWnd = WinGetHandle("Yahoo")
    $oIE = _IEAttach ($hWnd, "HWND")
                _IELoadWait($oIE,0, 20000)  
                $oForm = _IEFormGetObjByName ($oIE, "regFormBody")
    $oText = _IEFormElementGetObjByName ($oForm, "First Name")
    _IEFormElementSetValue ($oText, "PLEASE WORK!!!")
Link to comment
Share on other sites

Hey guys,

The following script -

#include <IE.au3>
    WinWait("Yahoo")
    Local $hWnd = WinGetHandle("Yahoo")
    $oIE = _IEAttach ($hWnd, "HWND")
    $oForm = _IEFormGetObjByName ($oIE, "regFormBody")
    $oText = _IEFormElementGetObjByName ($oForm, "username")
    _IEFormElementSetValue ($oText, "PLEASE WORK!!!")

works. The algorithm also works with other forms. But it doesn't .work for my company's page. I can't post the page link here, but I'd like to know if there are other things that affect the working of this algorithm. For eg. security issues, https instead of http. stuff like that..

Link to comment
Share on other sites

hi again,

I was playing around with @error, and found that _IEFormGetObjByName returns 7 which is "no match". So thats the problem.

This is the code i have for my company site form.

#include <IE.au3>
    WinWait("Spectrel")
    Local $hWnd = WinGetHandle("Spectrel")
    $oIE = _IEAttach ($hWnd, "HWND")
                _IELoadWait($oIE,0, 20000)  
                MsgBox (0,"Load wait", @error)
                $oForm = _IEGetObjByName ($oIE, "MainForm")
                MsgBox (0,"Get obj by name", @error)
    $oText = _IEFormElementGetObjByName ($oForm, "temp_specification_Title")
    MsgBox (0,"form elemernt get obj by name", @error)
    _IEFormElementSetValue ($oText, "PLEASE WORK!!!")
    MsgBox (0,"form element set value", @error)

The @error values displayed are 0,7,3,3 in the order of the code.

0 - No error

7 - No match

3 - Invalid Data Type

This is the html code segment on the website form used by _IEGetObjByName

<form enctype="multipart/form-data" name="MainForm" method="POST">

It some how doesn't detect this form.

Link to comment
Share on other sites

Most likely cause is Frames. If the elements you want are in Frames or iFrames, you need to drill into them with _IEFrameGet* functions. DebugBar can help you with this if you know what to look for.

Also, suggest you run this from SciTe while degugging (Tools, Go) as IE.au3 will write NoMatch and other messages to the console for you and shorted your debugging cycles.

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

I looked for iframes in the source code. These are the instances:

<iframe id="childEM_91919523__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919526__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919534__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919537__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919541__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919551__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">

Debug bar shows another iframe in addition to the ones above (in the Script tab). Which begins like

<IFRAME>src=https://java.spectrel.com/hybrid...

Is there dynamic code being generated here by a script?

Link to comment
Share on other sites

I looked for iframes in the source code. These are the instances:

<iframe id="childEM_91919523__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919526__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919534__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919537__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919541__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">
<iframe id="childEM_91919551__iframe" src="java script:false;" frameBorder="0" class="menuContainerIframeUnderlay" style="display:none;">

Debug bar shows another iframe in addition to the ones above (in the Script tab). Which begins like

<IFRAME>src=https://java.spectrel.com/hybrid...

Is there dynamic code being generated here by a script?

Quite possibly. The answer is the same however... use the _IEFrame* functions.

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