How to add datetime to an input at playback : Automation API

How to add datetime to an input at playback

Class library usage, coding and language questions.

How to add datetime to an input at playback

Postby Gav » Fri Oct 21, 2011 3:48 pm

Hi,

I have an input field that I want to type "cheese" into. Is there a way I could add the current datetime so that when the recording plays back it inputs "cheese20111021-14:46:23"? I imagine it'll have something to do with variables, but I'm not sure how to go about doing that.

Thanks,

Gav
Gav
 
Posts: 21
Joined: Thu Oct 20, 2011 11:52 am

Re: How to add datetime to an input at playback

Postby Ciege » Fri Oct 21, 2011 4:49 pm

Are you using the Recorder or your own code?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: How to add datetime to an input at playback

Postby Gav » Fri Oct 21, 2011 5:47 pm

Hi Ciege,

It doesn't really matter how the step gets into the recording (sometimes I record, sometimes I add manually if the edit box is already in the repo). All I need it to do is append something to the end of my original input. I'm ideally wanting something unique, so datetime, or seconds/milliseconds.

Gav
Gav
 
Posts: 21
Joined: Thu Oct 20, 2011 11:52 am

Re: How to add datetime to an input at playback

Postby Ciege » Fri Oct 21, 2011 6:11 pm

OK, well then you can add code similar to this:
Code: Select all
strYear = System.DateTime.Now.Year.ToString();
strMonth = System.DateTime.Now.ToString("MM");
strDay = System.DateTime.Now.ToString("dd");
strHour = System.DateTime.Now.ToString("hh");
strMinute = System.DateTime.Now.ToString("mm");
strSecond = System.DateTime.Now.ToString("ss");

strDateTimeStamp = strYear + "_" + strMonth + "_" + strDay + "___" + strHour + "_" + strMinute + "_" + strSecond;


Then your input variable would be:
Code: Select all
"Cheese" + strDateTimeStamp;
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests