Script Example: Metro Card Balance Checker

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Script Example: Metro Card Balance Checker

Post by CyberCitizen » Sat Jun 22, 2013 4:50 am

Hey Guys,

Here is another one for you guys. Don't really know how much use it will be to anyone else but thought I would post it to show you the power of MS and Web Recorder.

In Adelaide we have a new train and bus ticketing system. This system uses a proximity card that has an electronic balance system. You can check the balance when validating or on a website. Although good it's a pain in the morning if your not sure how much credit you have.

Basically I have this script scheduled to run at 7:00am every morning it runs an IE window in the background (hidden) logs into the system and retrieves the balance. It then uses NotifyMyAndroid to push this balance to my phone (screen shot below).

Image

Code: Select all

// COMPILE_OPTS|C:\Downloads\Usenet\Metro Card Balance v1.1.exe|M:\Icons\subscriptions.ico|CONSOLE=0|INCLUDES=1| /LOGFILE=\dev\nul /NOSYSTRAY /HIDE|RUNTIMES=1|BMPS=1
Let>COMMA=,
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
Let>APP_TITLE=Metro Card Balance v1.1

DayOfWeek>CurrentDay
If>{(%CurrentDay%="1") OR (%CurrentDay%="7")}
  GoTo>Exit
EndIf

IEOnDownload>1,C:\Users\Michael Allen\Desktop,ie_res
IESetTimeout>10,ie_res
IECreate>IE[0]
IESHowIE>IE[0],1
IENavigate>%IE[0]%,https://mc.adelaidemetro.com.au,ie_res
IEWaitDocumentComplete>%IE[0]%,ie_res
IEClickTag>%IE[0]%,{""},{"aspnetForm"},{"INPUT"},{"ID"},{"tbLogin"},ie_res
IEFormFill>%IE[0]%,{""},{"aspnetForm"},{"ctl00$cphContent$ucLoginCustomer$tbLogin"},{"EMAIL@SERVER. COM"},0,ie_res
IEClickTag>%IE[0]%,{""},{"aspnetForm"},{"INPUT"},{"ID"},{"tbPassword"},ie_res
IEFormFill>%IE[0]%,{""},{"aspnetForm"},{"ctl00$cphContent$ucLoginCustomer$tbPassword"},{"PASSWORD"},0,ie_res
IEClickTag>%IE[0]%,{""},{"aspnetForm"},{"INPUT"},{"ID"},{"btnLogin"},ie_res
//IEWaitDocumentComplete>%IE[0]%,ie_res
//IEFormSubmit>%IE[0]%,{""},{"aspnetForm"},ie_res
IEWaitDocumentComplete>%IE[0]%,ie_res
IEExtractTag>%IE[0]%,,TABLE,6,0,TABLE6,ie_res
IEExtractTag>%IE[0]%,,TABLE,11,0,TABLE11,ie_res

Label>ReExtract
IEExtractTag>%IE[0]%,,TABLE,6,0,TABLE6,ie_res
IEExtractTag>%IE[0]%,,TABLE,11,0,TABLE11,ie_res
If>%TABLE6%=
  GoTo>ReExtract
Else
  StringReplace>%TABLE6%,Regular Fare,,TABLE6
  Trim>%TABLE6%,TABLE6
  StringReplace>%TABLE11%,Concession Fare,,TABLE11
  Trim>%TABLE11%,TABLE11
  Let>URL=application=MetroCard Balance&event=Regular Balance %TABLE6%&description=Concession Balance %TABLE11%
  StringReplace>%URL%,%SPACE%,%20,URL
  HTTPRequest>http://www.notifymyandroid.com/publicapi/notify?apikey=XXX&%URL%,,POST,,INFO
Endif

IEClickTag>%IE[0]%,{""},{""},{"A"},{"TEXT"},{"Log out"},ie_res
IEWaitDocumentComplete>%IE[0]%,ie_res
IEQuit>%IE[0]%,ie_res

Label>Exit
FIREFIGHTER

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sat Jun 22, 2013 9:16 am

CyberCitizen,
Is your "proximity card" required to be placed near your Android phone to order to read the data?

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Sat Jun 22, 2013 10:48 am

armsys wrote:CyberCitizen,
Is your "proximity card" required to be placed near your Android phone to order to read the data?
No the proximity card is one of their own, it uses their network & they provide you a way of checking the balance on line. What this script does is pulls that online feed every day & pushes the balance to my phone via NotifyMyAndroid. So every day I get a current balanced delivered to my phone.
FIREFIGHTER

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sun Jun 23, 2013 10:28 pm

CyberCitizen wrote:No the proximity card is one of their own, it uses their network & they provide you a way of checking the balance on line.
In a nutshell, you supply userid and password. Then you receieve the current balance. Thanks for sharing your script.
For odd reason, MS only supports IE, not FF.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Jun 24, 2013 12:19 pm

armsys wrote: For odd reason, MS only supports IE, not FF.
I believe FF isn't supported because it's not a native Windows program.

@CyberCitizen
I don't have web recorder so I can't comment on your script....but I'm sure those that do find it useful.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Mon Jun 24, 2013 12:59 pm

Rain wrote:@CyberCitizen
I don't have web recorder so I can't comment on your script....but I'm sure those that do find it useful.
Hi RAIN,
WebRecorder appears to sit in C:\Program Files (x86)\Macro Scheduler 14\, doesn't it?

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Mon Jun 24, 2013 2:31 pm

Rain only has v12
FIREFIGHTER

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Mon Jun 24, 2013 2:43 pm

CyberCitizen wrote:Rain only has v12
Shocking! Why? Given his magnificent MS skills, isn't the v14 upgrade worthwhile? Hope Marcus would offer RAIN some generous discount.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Jun 24, 2013 3:17 pm

I'm running v13....upgrading to v14 with the price increase and only one year of upgrade protection is not in my budget at this time.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Mon Jun 24, 2013 3:27 pm

Rain wrote:I'm running v13....upgrading to v14 with the price increase and only one year of upgrade protection is not in my budget at this time.
Hi RAIN,
Marcus should consider extending the upgrade protection coverage to 2 years in order to attract more MS licensed users. Alternatively, Marcus offers an one-time price for life-time upgrade. Either helps expand MS users base.
RAIN, are you a contractor? The ultimate question: Whether MS can help you generate revenue.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Jun 24, 2013 11:10 pm

armsys wrote: Hi RAIN,
Marcus should consider extending the upgrade protection coverage to 2 years in order to attract more MS licensed users. Alternatively, Marcus offers an one-time price for life-time upgrade. Either helps expand MS users base.
RAIN, are you a contractor? The ultimate question: Whether MS can help you generate revenue.
Hi armsys,
I'm not a contractor.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jun 25, 2013 10:48 am

Guys,

I have PMd Rain.

We currently offer very attractive discounted prices for personal use. We also held our upgrade prices low for a while when v14 was released.

Armsys may forget that many people here are employed by companies and it is the employer's responsibility to pay for licenses/upgrades if they deem it beneficial.

I am happy to help loyal customers but cannot really be seen to be subsidising their employers!

For people NOT employed - or not using the software at their place of employment - and using it at home for their own use we already offer the heavily discounted personal use licenses.

I've always been happy to help loyal customers. But I don't think a public forum is the place for individual negotiation, or negotiation on others behalf.

Regarding the 2 year maintenance - this used to be the case but it caused all kinds of confusion and we had a lot of companies telling us how unusual it was. It is the industry norm for maintenance to be annual, and so we switched. And finally, 12 months of maintenance is now included with the software.

Could we please stay on topic. If someone has a purchasing query please could they contact the help desk direct, or feel free to PM me.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Jun 25, 2013 11:19 am

Marcus Tettmar wrote:Guys,
I have PMd Rain.
We currently offer very attractive discounted prices for personal use. We also held our upgrade prices low for a while when v14 was released.
Armsys may forget that many people here are employed by companies and it is the employer's responsibility to pay for licenses/upgrades if they deem it beneficial.
Sorry for the trouble caused. Thanks, Marcus.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts