Read one line, enter it into a webfield, read the next...
Moderators: Dorian (MJT support), JRL
Read one line, enter it into a webfield, read the next...
Hey, thanks a lot for reading
Im a newbie into this and im wondering how (because im sure it is? ) to read one line from a .txt file, enter it into a webfield, click OK, then, read line two, enter it, ok ... etc. etc. untill there are no more lines.
Any ideas ?
Im a newbie into this and im wondering how (because im sure it is? ) to read one line from a .txt file, enter it into a webfield, click OK, then, read line two, enter it, ok ... etc. etc. untill there are no more lines.
Any ideas ?
Automating web stuff is a little more challenging than a standard desktop application, because the web site design can change at any time (you have no control over this usually unless you are the web developer also).
If the webpage is really simple, you could automate the data entry
with mouse movements and simulated keyboard inputs.
If the page is more complex, requiring scrolling, needing to make decisions, etc, then it is better to script the IE browser object inside of macro scheduler. There are many examples of this on the forum and in the standard examples which were most likely installed by default. This does require you to know some HTML and web development terminology. This is much more like programming than the previous solution.
Depending upon the web page and what you are trying to do, sometimes it's also possible to use the HTTPRequest command in macro scheduler to do what's called a HTTP Post and send the data directly to the web application. This doesn't require a browser to be open or scripted. But does require you to know HTML concepts and terminology. You will be responsible for examining the pure HTML of web pages and figuring out what the variable names are, etc to be successful at this.
If the webpage is really simple, you could automate the data entry
with mouse movements and simulated keyboard inputs.
If the page is more complex, requiring scrolling, needing to make decisions, etc, then it is better to script the IE browser object inside of macro scheduler. There are many examples of this on the forum and in the standard examples which were most likely installed by default. This does require you to know some HTML and web development terminology. This is much more like programming than the previous solution.
Depending upon the web page and what you are trying to do, sometimes it's also possible to use the HTTPRequest command in macro scheduler to do what's called a HTTP Post and send the data directly to the web application. This doesn't require a browser to be open or scripted. But does require you to know HTML concepts and terminology. You will be responsible for examining the pure HTML of web pages and figuring out what the variable names are, etc to be successful at this.
I am extremly happy for your quick and really in-depth response here, thanks a lot! i tend to see you amongst my forum searches aswell as the top replier
I do understand it will be something like this; written by Marcus Tettmar
from http://www.mjtnet.com/blog/2007/07/02/r ... in-memory/
Let>k=1
Label>start
ReadLn>c:\\\temp\\\test.txt,k,line
If>line=##EOF##,finish
MessageModal>line
Let>k=k+1
Goto>start
Label>finish
But im not sure how to fit it into my simple script..
1. goto google.com
2. read line1
3. enter it into the searchfield
4. click search
5. repeat
Here is my script:
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]
IE_Navigate>%IE[0]%,http://google.com/,r
IE_Wait>%IE[0]%,r
Wait>delay
IE_Wait>%IE[0]%,r
Wait>delay
Let>FrameName={""}
Let>FormName={"f"}
Let>FieldName={"q"}
Let>FieldValue={"hey hey"}
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r
Let>FrameName={""}
Let>FormName={"f"}
Let>TagValue={"btnG"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r
IE_Wait>%IE[0]%,r
Wait>delay
Label>end_script
I do understand it will be something like this; written by Marcus Tettmar
from http://www.mjtnet.com/blog/2007/07/02/r ... in-memory/
Let>k=1
Label>start
ReadLn>c:\\\temp\\\test.txt,k,line
If>line=##EOF##,finish
MessageModal>line
Let>k=k+1
Goto>start
Label>finish
But im not sure how to fit it into my simple script..
1. goto google.com
2. read line1
3. enter it into the searchfield
4. click search
5. repeat
Here is my script:
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]
IE_Navigate>%IE[0]%,http://google.com/,r
IE_Wait>%IE[0]%,r
Wait>delay
IE_Wait>%IE[0]%,r
Wait>delay
Let>FrameName={""}
Let>FormName={"f"}
Let>FieldName={"q"}
Let>FieldValue={"hey hey"}
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r
Let>FrameName={""}
Let>FormName={"f"}
Let>TagValue={"btnG"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r
IE_Wait>%IE[0]%,r
Wait>delay
Label>end_script
What do you want to do with the results which are returned after clicking "search"?1. goto google.com
2. read line1
3. enter it into the searchfield
4. click search
5. repeat
If you only want to do google searches, then it is very easy to construct a URL and send this to google using HTTPRequest like so:
Code: Select all
Let>page=http://www.google.com/search?h1=en&source=hp&q=
Let>searchterm=macroscheduler
Let>searchpage=%page%%searchterm%
HTTPRequest>searchpage,,GET,,result
MessageModal>result
You could save the result directly to a text file and then open this file in the browser if you wanted.... depends upon what you want to do with the results.
Simply replace the variable "searchterm" with each line of input from your text file. It could need URL encoding if it contains certain special characters or spaces (easy to do in VBScript).
i see, i kind of wanted it to be really human though. And for it to handle sessions and things, even at a later stage implement the Screencapture command to screenshot the HTML result page one gets after a search,
by the way, the result from i.ex line1 from my test.txt, if i want that to be instead of my example ("hey hey"), it will be my replacing it with %line% ?
by the way, the result from i.ex line1 from my test.txt, if i want that to be instead of my example ("hey hey"), it will be my replacing it with %line% ?
Code: Select all
MouseMove>0,0
Let>k=1
Label>start
ReadLn>c:\\\temp\\\test.txt,k,line
If>line=##EOF##,finish
MessageModal>line
Let>k=k+1
Goto>start
Label>finish
Let>delay=1
IE_Create>0,IE[0]
IE_Navigate>%IE[0]%,http://google.com/,r
IE_Wait>%IE[0]%,r
Wait>delay
IE_Wait>%IE[0]%,r
Wait>delay
Let>FrameName={""}
Let>FormName={"f"}
Let>FieldName={"q"}
Let>FieldValue={"%line%"}
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r
Let>FrameName={""}
Let>FormName={"f"}
Let>TagValue={"btnG"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r
IE_Wait>%IE[0]%,r
Wait>delay
Label>end_script
On Debug - Run, it gives me an error on line 1 already Invalid numeric value .
Edit: i know i have the correct script based off the other article, but to get that to understand it needs run MY macro process over and over untill it is done is harder ...
Im not looking for results right away, i can setup a listener on the other side to see if its working like i need it to, the key here would be to get this part working, then using this puppy to screenshot the result, like if it was an IE window:
Code: Select all
Wait>3.5
GetScreenRes>sX,sY
Min>min
Sec>sec
Hour>hour
ScreenCapture>0,0,sX,sY,c:\temp\cap.%hour%.%min%.%sec%.jpg
Last edited by a2a on Fri Jul 16, 2010 8:37 pm, edited 2 times in total.
Thanks again, testing it out, its got a lot of backlashes just because the original aricle has:adroege wrote:Why so many backslashes? I think this is a problem.ReadLn>c:\\\temp\\\test.txt,k,line
http://www.mjtnet.com/blog/2007/07/02/r ... in-memory/
I did an edit on my last post and filled in my vision too. sorry for the confusion here ...
Code: Select all
ReadLn>c:\temp\test.txt,k,line
folder names like so.
Seems to be rocking it GOOD!! Thank you a lot for guiding me. In the end i now see it all has the same structure as good ol .BAT scripting (atleast with the labels and goto`s )
Full code again, WITH the screencap:
It works!, but i think i have gotten a wrong impression about what that screencap actually does i was hoping for it to show me what the Webpage would show haha. If thats not posible (no actuall window to capture), what was that you told about getting results to a .txt ? in .html perhaps so one could just rename and view the results locally ?
Full code again, WITH the screencap:
Code: Select all
MouseMove>0,0
Let>k=1
Label>start
ReadLn>C:\temp\test.txt,k,line
If>line=##EOF##,finish
MessageModal>line
Let>k=k+1
Let>delay=1
IE_Create>0,IE[0]
IE_Navigate>%IE[0]%,http://google.com/,r
IE_Wait>%IE[0]%,r
Wait>delay
IE_Wait>%IE[0]%,r
Wait>delay
Let>FrameName={""}
Let>FormName={"f"}
Let>FieldName={"q"}
Let>FieldValue={%line%}
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r
Let>FrameName={""}
Let>FormName={"f"}
Let>TagValue={"btnG"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r
IE_Wait>%IE[0]%,r
Wait>delay
Wait>10
GetScreenRes>sX,sY
Min>min
Sec>sec
Hour>hour
ScreenCapture>0,0,sX,sY,c:\temp\cap.%hour%.%min%.%sec%.jpg
Label>finish
Goto>start
It works!, but i think i have gotten a wrong impression about what that screencap actually does i was hoping for it to show me what the Webpage would show haha. If thats not posible (no actuall window to capture), what was that you told about getting results to a .txt ? in .html perhaps so one could just rename and view the results locally ?