I still need help.

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
daniel
Junior Coder
Posts: 32
Joined: Mon Apr 25, 2005 5:04 pm

I still need help.

Post by daniel » Fri Jun 17, 2005 3:54 am

I'm trying to write a macro that copies different fields from a screen and pastes them into a different field. For example, if I already have keyed a person's last name, first name, and middle initial in one place and I want to copy the these three fields and paste them in a different location. The problem is that if the do the following:

Press HOME
Press TAB*5
Press LSHIFT 'This parts uses SHIFT and RIGHT to highlight the field
Press RIGHT*18
Release LSHIFT
Press LCTRL
Send>c
Release LCTRL
GetClipboard>lastname

This is supposed to save the copied field into the clipboard as a variable names "lastname".

Now if the I do following:

Press HOME
Press TAB*6
Press LSHIFT 'This parts uses SHIFT and RIGHT to highlight the field
Press RIGHT*18
Release LSHIFT
Press LCTRL
Send>c
Release LCTRL
GetClipboard>firstname

This is supposed save the first name field and paste into the clipboard as a variable names "firstname."

The problem that I'm having is that if I do the following:

MessageModal>lastname, firstname .........or even
MessageModal>%lastname%, %firstname %

This returns the same variable twice and not the first name and last name as I want them.

Is there anyone that can help me with this or at least let me know that it doesn't work so that I won't spend anymore time trying to figure this out and move on?

This is not hard so I do not know why I'm spending so much time trying to fix it. Is there anyone in the macro software place that can help me?

Do you guys recomment for me to use VBScript and write a function that returns that variable? How would I go about if I can't can use SHIFT and RIGHT to highlight the field in VBScript?


I was also thinking about using Mid(sReadine,x,y,l) but I can't really use this because we can only use this for a text file.

I would really appreciate if you could help me with this as soon as possible. Thank you and have a nice day. :( [size=18][/size]


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 » Fri Jun 17, 2005 5:47 am

You are on the right track, this should be quite simple. No need to do VBScripy or MidStr, etc.

Make sure there are no trailing spaces in your script. Do Edit/Remove Trailing Spaces.

Try to Single Step your macro and watch the movements. In the Editor do Debug/Step and watch where the cursor goes before the CTRL-C command happens. Also turn on Show Watch List and look at value of variables. Which one is being duplicated, firstname or lastname?

Or comment out the macro after the macro gets ready to copy the field contents. Is the cursor in the correct position?

This may just be a type on the forum but %firstname% is not the same as %firstname %

What program are you moving in? If a common program it will be easier for us to duplicate your problem exactly.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by support » Fri Jun 17, 2005 7:57 am

Using Shift-Right 18 times will only highlight the first 18 chars so assumes the field is never longer. Shift-End will highlight the entire field assuming you press Home first to ensure at the start of the field:

//Highlight entire field
Press Home
Press Shift
Press End
Release Shift

//Copy field to clipboard
Press CTRL
Send>c
Release CTRL

//Get clipboard data to variable
Wait>1
GetClipBoard>lastname

As Bob says, step through line by line with the debugger to see what is happening where. You may find it is just a timing issue and you need a delay at some point - if it works during debug it is because the act of debugging slows it down and this would suggest a delay is required at some point.
MJT Net Support
[email protected]

daniel
Junior Coder
Posts: 32
Joined: Mon Apr 25, 2005 5:04 pm

Post by daniel » Fri Jun 17, 2005 3:07 pm

I can't use SHIFT + END to highlight the field that I want because the screen that I'm copying the fields from is a telnet mainframe and if I press end, this won't define the actual field. The maximum length is 18, that's why I'm send RIGHT*18.

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

Post by CyberCitizen » Mon Jun 27, 2005 1:31 am

Hello Daniel,

I Also Had This Issue At One Stage & Was Gettign 2 Varibles With The Same Data & Could Not Work Out Why.

Turns Out That When I Was Copying The Data Into The Clipboard (Ctrl+C) It Was Taking About A Second. By Placing A Wait Command After The Copy, & Also One After The GetClipBoard This Fixed My Issue.

Once I Made This Adjustment My Scripts Worked Fine. It Was Just That MS Was Processing The Commands So Quickly That Windows Was Not Copying The Data To The Clipboard Quick Enough, So The Last Data It Was Copying Was Being Placed In 2 Varibles.

Hope This Helps.
FIREFIGHTER

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