Getting variables with js prompt boxes?

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Getting variables with js prompt boxes?

by etzel on Mon Feb 23, 2009 6:07 pm

I am trying to use js prompt boxes eg.

Code: Select all
var SUB = prompt("Type your Subject Line", "Subject Line");
var MSG = prompt("Type or Paste your Message Text Here", "Message Text");
var DEL = prompt("Choose your Delay Seconds", "Delay Seconds");


To grab information in iMacros scripts.. Then use said information in a script like so

Code: Select all
SET !ERRORIGNORE YES
var SUB = prompt("Enter your Subject Line", "Type your subject line here");
var MSG = prompt("Type or Paste your Message Text Here", "Type or Paste your message here");
var DEL = prompt("Delay Seconds", "Type Here");
TAB T=1
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=2 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=3 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=4 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=5 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=6 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=7 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=8 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=9 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=10 TYPE=IMG ATTR=SRC:http://website.com/mail.gif
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}
TAG POS=1 TYPE=A ATTR=TXT:NEXT
WAIT SECONDS=#DOWNLOADCOMPLETE#


Trouble is, it doesn't work... The JS prompt command is not recognised and therefore the variables are not entered... Do I have to tell iMacros that I am using JS or do I have to use the !SUB, !MSG, !DEL, {{!SUB}}, {{!MSG}} & {{!DEL}} that I'd use with the built in !VAR's? Alternatively, could I simply use the JS equivalent, ("SUB"), ("MSG") & ("DEL")?

I could of course simply use the built in !VAR's and have in fact done so previously, but now I'd like to be able to get the macro to stop whenever captcha is encountered, to do that, I need an if found, then ...... & prompt, else continue. If I am going to do that I need to use a "normal" scripting language and as JS is supported, I was thinking of using it for the prompt commands and variables(also, I'd need a 4th !VAR to do this with iMacros scripts).

Some input would be gratefully received, this is an ongoing project and time is of the essence. Also, this would increase the usefulness of the application, simply because it would allow normal users to utilise it to automate more complex tasks :D
etzel
 
Posts: 6
Joined: Wed Jan 14, 2009 6:46 am

Re: Getting variables with js prompt boxes?

by Tech Support on Wed Feb 25, 2009 8:35 am

You can not mix Javascript and iMacros code. But you can simply use the iMacros PROMPT command: http://wiki.imacros.net/PROMPT
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

Re: Getting variables with js prompt boxes?

by etzel on Wed Feb 25, 2009 10:50 am

Righto, I'll work this out, it may just kill me first, but I will work it out :roll:

I played around a little and wrote the following in a .txt file, loaded that to iMacros for Firefox, then renamed the #Current.iim to testmacro.js

It works well insofar as it does what I have asked it to do so far

Code: Select all
var uname;
var uname = prompt("Please enter your Username:", "Username...");
var pwd;
var pwd = prompt("Please enter your Password:", "Password...");
alert("Your Username is: "+uname)
alert("Your Password is: "+pwd)
var sub;
var sub = prompt("Please enter your Subject Line here:", "Subject Line...");
var msg;
var msg = prompt("Please enter your Message Text here:", "Message Text");
var t;
var del;
var t = prompt("Enter your Message Delay in Seconds:", "Delay Seconds");
var del=t*1000
alert("Subject Line is: "+sub)
alert("Message Text is: "+msg)
alert("Delay Milliseconds are: "+del)


Now, how to use this progress to make something useful?

Any ideas?

For starters, I note that iimSet is available in the .js files, as is iimPlay, so the possibility may exist that if I use something like this:

Code: Select all
int ret_code = iimSet ( String SUB, String sub)
int ret_code = iimSet ( String MSG, String msg )
int ret_code = iimSet ( String DEL, String del )


Then I could pass the variables generated in the js script (after iimPlay) into a macro?

I am thinking that maybe I could use something like this (ie. I set a variable (num) as being between 1-10, then run iimPlay on a single line macro tagpos.iim, using num = num++ after each, while num<11, else, run nxtpg.iim)..

Code: Select all
TAG POS={{num}} TYPE=IMG ATTR=SRC:http://website.com/mail.gif


I am wondering, can we use the .js getElementByID for checking to see if captcha is present? If so, extract full html source of the image, then do a js prompt displaying that (var captchatxt = prompt('<a><img src="(extracted url)"></a>' , 'Enter Captcha Text here...');) with a textbox with a variable to pass to imacros if needed to fill in the relevant textfield? Else, play msgsend.iim, on submitting captcha, play msgsend.iim..., which would merely be:

Code: Select all
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:aiPrompt CONTENT={{SUB}}
TAG POS=1 TYPE=TEXTAREA ATTR=ID:aiTextbox CONTENT={{MSG}}
TAG POS=1 TYPE=IMG ATTR=SRC:http://website.com/submit.gif
WAIT SECONDS={{DEL}}


Then write a return to start loop for the .js script?

I mean, it is hardly elegant, but provided we can get the .js to find the catcha element by id, to extract the full url source of the image and provided it displays, this would be A solution

Etzel
etzel
 
Posts: 6
Joined: Wed Jan 14, 2009 6:46 am

Re: Getting variables with js prompt boxes?

by winstongel on Fri Apr 10, 2015 12:33 am

Check this....Javascript Prompt Box examples

Winston
winstongel
 
Posts: 1
Joined: Fri Apr 10, 2015 12:30 am


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 2 guests

-->