Looping

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
scotters
Newbie
Posts: 3
Joined: Fri Aug 19, 2005 5:27 pm

Looping

Post by scotters » Fri Aug 19, 2005 5:33 pm

Hi,
Im new to this program but familiar with VBScript. I want to build a macro that will 1) prompt the user as to how many times to run the loop and 2)request input on each occurance of the loop.

This macro will basically ask how many orders there are, then ask for each order number one by one, followed by some keystrokes. The purpose is to increase the speed of a very monotonous task.

I can't seem to get the looping part to work. Here is my code thus far:

VBSTART

Function GetName

GetName = InputBox("How many picking lists do you want to pick : ")

End Function

VBEND

VBEval>GetName,name
MessageModal>You want to pick this many picking lists : %name%
For x = 1 to %name%
PList = InputBox("Scan Picking List : ")
Press Tab
Press Tab
Press Tab
Press Tab
Send Character/Text>%PList%
Press Enter
Next

Thanks for anyone's help!

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

Post by support » Fri Aug 19, 2005 6:41 pm

This code will do it:

Input>NumLists,Enter number of picking lists required
Let>k=0
Repeat>k
Let>k=k+1
SetFocus>some_window_title
Press Tab
Press Tab
Press Tab
Press Tab
Send Character/Text>%PList%
Press Enter
Until>k=NumLists

You MUST have a SetFocus line or the Press Tabs and Sends will land on whatever last had the focus - which in this case will be Macro Scheduler due to the Input box. Modify the SetFocus line to have it focus the application you are automating.

Please read the Scripting Windows for Beginners guide in the help file to get you started with writing scripts in Macro Scheduler. It will all become much clearer :-)
MJT Net Support
[email protected]

scotters
Newbie
Posts: 3
Joined: Fri Aug 19, 2005 5:27 pm

Almost there

Post by scotters » Fri Aug 19, 2005 6:59 pm

Hi, Thanks for the snippet. I added the second prompt (to request the individual picking list). The only problem I'm having now is that it doesn't focus to the input box on each loop. How do I do that?

Input>NumLists,Enter number of picking lists required

Let>k=0

Repeat>k

Let>k=k+1

Input>PList,Scan picking list

SetFocus>Microsoft Business Solutions-Axapta - Calculated Industries [CIAXPROD - AXDB]

Press CTRL
Send Character/Text>f
Release CTRL

Send Character/Text>%PList%
Press Enter

Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab
Press Tab

Until>k=NumLists

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

Post by support » Fri Aug 19, 2005 8:38 pm

Try this prior to the Input line:

SetFocus>Macro Scheduler 7.3
MJT Net Support
[email protected]

scotters
Newbie
Posts: 3
Joined: Fri Aug 19, 2005 5:27 pm

Post by scotters » Fri Aug 19, 2005 9:21 pm

it didn't work.... I'm not sure what to do here. it doesn't show up in the task bar either so an Alt Tab won't work....

Does MS like Arrays? I'm thinking I could first store all the data in a big ol' array and then run a loop on the program and have it spit out the stored data there...

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

Post by support » Fri Aug 19, 2005 9:26 pm

The Input box should always appear.

Yes, you can use arrays.
MJT Net Support
[email protected]

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