How To Save Results Of Random Input Into File

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Thanks to Shade and Darkdiver I'm finally getting a little better grip on Code Creator. Got the emulations working good now and am able to fix most of the errors that pop up.

What I'm dealing with now is probably simple but everything that I've tried has failed miserably. How do you save the results of Set.Value when filling in an HTML element by using the Random.Macro. I need this for a couple of sites that the only way the register button works is through Emulations.

Here's my string and I need to save the result to a file along with another string; User:Pass.

Код:
HtmlElement he;
			// Setting value [{-Random.T...] to the element with tag [input:text]
			he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByName("form::account_id");
			if (he.IsVoid) {
				he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildById("account_id");
			}
			if (he.IsVoid) {
				he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByAttribute("input:text", "fulltag", "input:text", "text", 0);
			}
			if (he.IsVoid) return -1;
			
			

			// Executing macros
			 he.SetValue(instance.RiseMacros("Random.Text", new [] { "10", "cd" }), true);


WHAT GOES HERE NEXT? VARIABLE?
I've tried using Get.Value() but I don't know what to put in the parenthesis. I've tried everything and what's online as far as help doesn't help.
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
First way: create a new variable for generated value
PHP:
// searching field for login 
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByName("login");
if (he.IsVoid) return -1;

// create a new variable for login and generate a value
string login = instance.RiseMacros("Person.HumanLogin", new [] { "[Eng|4][RndNum|1970|1990]" });
he.SetValue(login, true);

// searching field for password
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByName("passwd");
if (he.IsVoid) return -1;

// create a new variable for password and generate a value
string password = instance.RiseMacros("Random.Text", new [] { "10", "cd" }); 
he.SetValue(password, true);
            
// add login and password (in format login:password) to file
instance.RiseMacros("File.AppendString", new [] { "C:\\1.txt", login + ":" + password, "true" });
Second way: use method GetValue() of HtmlElement class:
PHP:
// searching field for login 
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByName("login");
if (he.IsVoid) return -1;

// set a login value
he.SetValue(instance.RiseMacros("Person.HumanLogin", new [] { "[Eng|4][RndNum|1970|1990]" }), true);
            
// get a login value
string login = he.GetValue();
            
// searching field for password
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByName("passwd");
if (he.IsVoid) return -1;

// set a password value
he.SetValue(instance.RiseMacros("Random.Text", new [] { "10", "cd" }), true);
            
// get a password value
string password = he.GetValue(); 
            
// add login and password (in format login:password) to file
instance.RiseMacros("File.AppendString", new [] { "C:\\1.txt", login + ":" + password, "true" });
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Thank you again Shade, the second method worked perfectly. If I can figure out how to set up proxies, life would be sweet.
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Yes, again the info online was not much help. I would like to take a proxy from a file and set up the proxy. Is this hard to do in CC. I thought that I had the general idea, but I keep getting the error instance.SetProxy() as having 1 parameter. Don't know what to do.

By the way, thanks for all your help again.
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
Yes, again the info online was not much help. I would like to take a proxy from a file and set up the proxy. Is this hard to do in CC. I thought that I had the general idea, but I keep getting the error instance.SetProxy() as having 1 parameter. Don't know what to do.

By the way, thanks for all your help again.
I guess something like this:
PHP:
// gets a string from file which contains proxy in the format ip:port
string proxy = instance.RiseMacros("File.GetString", new [] { "\\Resources\\proxy.txt", "random", "false" });

// gets ip from this string
string ip = instance.RiseMacros("String.Split", new [] { proxy, ":", "0" });

// gets port from this string
// method Convert.ToInt32() - converts a string value to a integer value
// because port must be an integer
int port = Convert.ToInt32(instance.RiseMacros("String.Split", new [] { proxy, ":", "1" }));

// sets proxy to the instance 
// ip - ip of proxy
// port - port of proxy
// true - if proxy is SOCKS, else it's must be false
instance.SetProxy(ip, port, true);
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Thanks man, I was missing the convert to convert.toint.32 part. What is the best reference to find out this info?
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
http://msdn.microsoft.com - on this site you can find all information. But almost books contains basic information about standard methods and classes of .Net 3.5
 
  • Спасибо
Реакции: bigcajones

qmg

Client
Регистрация
12.06.2011
Сообщения
15
Благодарностей
7
Баллы
3
Similar question...

I'm a noob to php Code Creator. Showing the code really helped me understand the syntax for macros.
What I'm trying to do is navigate to a web page by reading a line from a text file.
I can't seem to get the builder to build, so I know I'm probably missing something simple.
This is an example:
PHP:
		string mywebsiteurl = instance.RiseMacros("File.GetString", new [] { "C:\\Users\\Auction\\Dropbox\\mywebsiteurls.txt", "0", "true" });
		
		// Going to website
		$tb = $instance->MainTab;
		if (($tb->IsVoid) || ($tb->IsNull)) return -1;
		if ($tb->IsBusy) $tb->WaitDownloading();
		$tb->Navigate({ mywebsiteurl });
		if ($tb->IsBusy) $tb->WaitDownloading();
Any thoughts?
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
I'm a noob to php Code Creator. Showing the code really helped me understand the syntax for macros.
What I'm trying to do is navigate to a web page by reading a line from a text file.
I can't seem to get the builder to build, so I know I'm probably missing something simple.
This is an example:
PHP:
        string mywebsiteurl = instance.RiseMacros("File.GetString", new [] { "C:\\Users\\Auction\\Dropbox\\mywebsiteurls.txt", "0", "true" });
        
        // Going to website
        $tb = $instance->MainTab;
        if (($tb->IsVoid) || ($tb->IsNull)) return -1;
        if ($tb->IsBusy) $tb->WaitDownloading();
        $tb->Navigate({ mywebsiteurl });
        if ($tb->IsBusy) $tb->WaitDownloading();
Any thoughts?
Hi, qmg.

What is it?
$tb->Navigate({ mywebsiteurl });
I mean "{" and "}".
It should be like this:
$tb->Navigate($mywebsiteurl);
And when you use PHP need not use any types. The variables in PHP start with "$" and uses "->" instead of ".". This line should be look like this:
$mywebsiteurl = $instance->RiseMacros("File.GetString", array( "C:\\Users\\Auction\\Dropbox\\mywebsiteurls.txt", "0", "true" ));
 
  • Спасибо
Реакции: qmg

qmg

Client
Регистрация
12.06.2011
Сообщения
15
Благодарностей
7
Баллы
3
Hi, qmg.

What is it?

I mean "{" and "}".
It should be like this:

And when you use PHP need not use any types. The variables in PHP start with "$" and uses "->" instead of ".". This line should be look like this:
Thanks - that DID allow me to build and run debug.
However, it did not actually navigate to the page in the file, nor did it delete the line in the text file.

My code now looks like this:
PHP:
		$mywebsiteurl = $instance->RiseMacros("File.GetString", array( "C:\\Users\\Auction\\Dropbox\\mywebsiteurls.txt", "0", "true" )); 
	    
		// Going to website
        $tb = $instance->MainTab;
        if (($tb->IsVoid) || ($tb->IsNull)) return -1;
        if ($tb->IsBusy) $tb->WaitDownloading();
        $tb->Navigate($mywebsiteurl);
        if ($tb->IsBusy) $tb->WaitDownloading();

P.S. I assumed the space in mywebsiteurls.tx t was a typo.

Thanks in advance!
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
Thanks - that DID allow me to build and run debug.
However, it did not actually navigate to the page in the file, nor did it delete the line in the text file.

My code now looks like this:
PHP:
        $mywebsiteurl = $instance->RiseMacros("File.GetString", array( "C:\\Users\\Auction\\Dropbox\\mywebsiteurls.txt", "0", "true" )); 
        
        // Going to website
        $tb = $instance->MainTab;
        if (($tb->IsVoid) || ($tb->IsNull)) return -1;
        if ($tb->IsBusy) $tb->WaitDownloading();
        $tb->Navigate($mywebsiteurl);
        if ($tb->IsBusy) $tb->WaitDownloading();

P.S. I assumed the space in mywebsiteurls.tx t was a typo.

Thanks in advance!
Hi, qmg.

Maybe this file not exist. Check path to file.
On my machine this code work fine.
You can check that the macro returns in debug, just look for your variable ($mywebsiteurl) in local variables.
If all ok then the macro returns string from this file and removes it else returns empty string.
 

Кто просматривает тему: (Всего: 2, Пользователи: 0, Гости: 2)