Help With Script Returning Wrong Var

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

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

Help With Script Returning Wrong Var

Post by CyberCitizen » Fri Feb 18, 2005 6:49 am

Hello,

I have nearly got the script running the way I want however it seems to have a small issue which I can not work out.

Note alot of mouse moves as the tab order for the program is all over the place.

The main part of the script works fine, however the issue lay's in

If>%ConfNum%=%CompSiteId%,NoSiteID,Finish

The details are being placed in the var ok, however if %ConfNum%=%CompSiteId% equals the same value It should move to the label Finish, however if they do not equal the same value it should move to NoSiteID.

This is not happening. What is happening is that both are moving to NoSiteId.

Please Help :!:


Script Below
========
CapsOff
Day>the_day
Month>the_month
Year>the_year
Let>Info=%the_day%/%the_month%/%the_year%
Run Program>calc
WaitWindowOpen>Calculator
GetClipBoard>ESN
Send Character/Text>%ESN%
Press F5
MoveWindow>Calculator,0,0
Wait>1

MouseMove>358,342
LDblClick
Press Ctrl
Send Character/Text>c
Release Ctrl
GetClipboard>ConfNum
Wait>0.1
MouseMove>387,432
LDblClick
Press Ctrl
Send Character/Text>c
Release Ctrl
GetClipboard>CompSiteId

Wait>0.1
MouseMove>639,543
Ask>Does The ESN Match The Site ID?,SiteID
If>SiteID=NO,End
If>SiteID=YES,Note

label>Note
MouseMove>475,630
LClick
Press Home
Send Character/Text>ESN Matches - User ID: %USER_NAME%
Press Enter
MouseMove>363,477
LClick
Press End
Press Shift
Press Home
Release Shift
Press Del
Wait>0.5
Send Character/Text>Info
Wait>0.5
MouseMove>789,398
LClick
MouseMove>382,693
LClick
MouseMove>278,395
LClick
MouseMove>406,454
LClick
Press End
Press Shift
Press Home
Release Shift
If>%ConfNum%=%CompSiteId%,NoSiteID,Finish
MsgBox>Errored At Confirming Conf & Site ID

Goto>End

Label>Finish
Press Del
Press Tab
Press Shift
Press Home
Release Shift
Press Del
Send Character/Text>Completed
Press Tab
Goto>End

Label>NoSiteID
Send Character/Text>No Site ID
Press Shift
Press Tab
Press Home
Release Shift
Press Del
Send Character/Text>L2BOH
Goto>End

Label>End
CloseWindow>Calculator

--
Michael Allen
NURV | CyberCitizen

"If you spend more on coffee than on IT security, you will be hacked."
White House cybersecurity advisor, Richard Clarke
Last edited by CyberCitizen on Sat Feb 19, 2005 3:16 am, edited 1 time in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Feb 18, 2005 7:47 am

This just means that ConfNum and CompSiteId are never equal - despite you thinking that they are. Enable the watch list with Debug/Show Watch List and then step through with the debugger to see the actual values. Or do this prior to the If line:

MessageModal>|%ConfNum%|%CompSiteId%|

This will allow you to compare them. If necessary check their length also - possibly one has an invisible char in it as a result of grabbing it from the clipboard.
MJT Net Support
[email protected]

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

Post by CyberCitizen » Sat Feb 19, 2005 2:36 am

This just means that ConfNum and CompSiteId are never equal
Thats Just It, I Have Already Tried The Msg Box & Confirmed That Both Numbers Do Equal In Most Cases.
possibly one has an invisible char
Thought About That 2 However The System It's Self Can Not Contain Spaces Or Invisable Char.
Enable the watch list with Debug/Show Watch List and then step through with the debugger to see the actual values
Attempted That However The Debugger Does Not Work Correctly For The System As It Has Trouble Going Back To The Required System & Thefore Attempts To Run The Script While In The Macro Editor.

Any Help Please?

Thanks For Any Help!
--
Michael Allen
NURV | CyberCitizen

"If you spend more on coffee than on IT security, you will be hacked."
White House cybersecurity advisor, Richard Clarke

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Re: Help With Script Returning Wrong Var

Post by Me_again » Sat Feb 19, 2005 4:14 am

CyberCitizen wrote:The main part of the script works fine, however the issue lay's in

If>%ConfNum%=%CompSiteId%,NoSiteID,Finish

The details are being placed in the var ok, however if %ConfNum%=%CompSiteId% equals the same value It should move to the label Finish, however if they do not equal the same value it should move to NoSiteID.
What am I missing? If the expression is true the first statement is executed. So if %ConfNum% does equal %CompSiteId% then it will go to NoSiteID, not Finish. I think you want

If>%ConfNum%=%CompSiteId%,Finish,NoSiteID

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

Post by CyberCitizen » Sun Feb 20, 2005 10:41 pm

Sorry My Mistake In What I Typed. It Should Be That If The %ConfNum% And %CompSiteId% Equal The Same. Then It Moves To NoSiteID. Because What We Want To See Is That They Do Not Equal.

However If They Do Not Equal Then It Should Go To The Finish Process.

What Seems To Be Happening Is They Both Go To The Finish Process, If They Equal Or Not.
--
Michael Allen
NURV | CyberCitizen

"If you spend more on coffee than on IT security, you will be hacked."
White House cybersecurity advisor, Richard Clarke

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sun Feb 20, 2005 11:22 pm

I'm not following you. Your logic is correct. Nothing wrong with it. If it is not going to the place you expect then clearly the values are not what you think they are.
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Feb 21, 2005 2:59 am

What happens if you use Let> to define test values for %ConfNum% And %CompSiteId% before the If> ?

Guest

Post by Guest » Mon Feb 21, 2005 3:30 am

support wrote:I'm not following you. Your logic is correct. Nothing wrong with it. If it is not going to the place you expect then clearly the values are not what you think they are.
I Have Tripple Checked Them. I Have Also Called A Msg Box To Check The Values Before The Scrip & After The Script On Both Occations.

When The Values Equal It Goes To The Label Finish. When They Do Not Equal They Go To Finish As Well.

Have I Got The If Command Correct?

Apart From That I Cant See Anything Wrong With The Script.

Here Is A Quick One Which I Cant Seem To Get To Work. Maybe I'm Missing Something. I Have Spent To Long On This Script Already.

Let>a=test1
Let>b=test1

If>a=b,Correct,Incorrect

Label>Correct
Msg>Correct

Label>Incorrect
Msg>Incorrect


If>a=b,Correct,Incorrect <-- Doesn't Matter If Its Correct Or Not It Will Always Return The Incorrect Value?

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

Post by CyberCitizen » Mon Feb 21, 2005 4:21 am

Sorry Last Post Was From Me I Forgot To Log In. My Bad.
--
Michael Allen
NURV | CyberCitizen

"If you spend more on coffee than on IT security, you will be hacked."
White House cybersecurity advisor, Richard Clarke

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Feb 21, 2005 5:21 am

You are continuing from Correct right through Incorrect. Need to branch out. These are not subroutines. They will continue to the next line of script. See my changes
a=test1
Let>b=test1

If>a=b,Correct,Incorrect

Label>Correct
Msg>Correct

GoTo>End

Label>Incorrect
Msg>Incorrect

Label>End
If you change to MessageModal, you will see that you are actually getting both MSG messages, but the last one overwrites the first one.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by CyberCitizen » Mon Feb 21, 2005 11:09 pm

Bob,

Thanks for your reply. I made the change to the little script & that worked.

However I already had a Goto>End setup on my main script. Any ideas as to why that is not working?
--
Michael Allen
NURV | CyberCitizen

"If you spend more on coffee than on IT security, you will be hacked."
White House cybersecurity advisor, Richard Clarke

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Feb 22, 2005 1:20 am

I went to your original code, stripped out all lines but those related to the IF> issue. I hard coded the values, and everything works OK. When values are different it branches to Finish. If I change the values to match, the branch changes to NoSiteID.

Code: Select all

Let>ConfNum=56
Let>CompSiteId=67

If>%ConfNum%=%CompSiteId%,NoSiteID,Finish
MsgBox>Errored At Confirming Conf & Site ID

Goto>End

Label>Finish
Message>Finished
Goto>End

Label>NoSiteID
Message>NoSiteID
Goto>End

Label>End
A few comments to help you troubleshoot this:
1. There is no command MsgBox in Macro Scheduler. And this one would not run anyway if it was valid, because your IF> command has paths to follow for True and False, line would be skipped.
2. Throw in a MessageModal> after you do each of the CTL-c, Get Clipboard, like this:

Code: Select all

GetClipboard>%ConfNum%
MessageModal>%ConfNum%
3. It has alrady been suggested that you should turn on the WatchList and single step through looking at the values. If you do this you will also see the values you are comparing.
4. I suspect that CTL-c may not be working properly for you. Some programs are case sensitive, try CTL-C instead.
5. Also try commenting out all lines that do not affect the IF> test that is failing. I physically removed them, but they should have no affect, except the CTL-c commands you need vs. my hard-coded values.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by CyberCitizen » Tue Feb 22, 2005 6:16 am

Hey Guys Thanks For All The Help.

I Have Sorted The Problem.

What Was Happening Is That The Computer Was Running Quite Slow & When It Was Copying The Fields & Then Entering Them As Var, It Would Cause A Small Delay.

This Then Resulting In The ConfNum And CompSiteId Not Being The Same When Checking.

Therefore The Script Would Then Say Did Not Match Goto Finish.

Because The Data It Was Storing In The Clipboard Was Still The ESN & The ESN Will Never Match The Conf It Would Always Goto Finish.

After Putting A Couple Of Wait Commands In The Script It Allowed Enough Time For The Details To Be Copied Into The Clipboard & Then Written As A Var.

Again Thanks For All Your Help.
--
Michael Allen
NURV | CyberCitizen

"If you spend more on coffee than on IT security, you will be hacked."
White House cybersecurity advisor, Richard Clarke

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