G'Day,
Been looking for a good program like this for a while now - came across it via download.com. Love the scripting ability & well supported forum! Will purchase shortly.
Only been trying out the scripting for the last day or two - well documented & heaps of potential.
I just have a little problem which someone might have an answer for…
The Task
I'm using AC3D for 3d modelling & I've written a script that will produce 48 variations of a model - same model but different co-ordinates.
Basically a loop - taking co-ordinate details/new filename from Excel, over to AC3D - move the model, export & save - back to Excel… etc
The Problem
Arose when instead of pasting co-ordinates, sometimes %xloc%, %zloc% or %newfilename% was pasted (sometimes a mixture).
I added in all the wait>2's but still had the same problem, then added in the wait>0.1's which seems to have done the job in the meantime.
I was wondering however if there's a easier (more reliable) way of moving data (simple data - don't confuse me just yet please ) from one application to another to avoid this problem. Is there anyway of knowing how much time would be required between operations of this nature or generally or is it a matter of trial & error...
Thanks
Robbie
Don't laugh at my coding... day 2 folks
The Script
// C:\My Download Programs - Demo Versions\MJT Net Ltd\Macro Scheduler\temp 02.scp
// Recorded on Wednesday, April 6, 2005, at 11:08 PM
//Recorded Events
Let>WW_TIMEOUT=5
CapsOff
let>counter=0
label>start
setfocus>Microsoft Excel - Wonderland Modelling Macro Structure
WaitWindowOpen>Microsoft Excel - Wonderland Modelling Macro Structure
MoveWindow>Microsoft Excel - Wonderland Modelling Macro Structure,-4,-4
ResizeWindow>Microsoft Excel - Wonderland Modelling Macro Structure,1288,998
// goto cell c11 - no coding here, some issues to sort out - tried something & had lots of fun
//counter change by 1 & check if finished
let>counter=%counter%+1
if>%counter%>48,finished
//new counter no. & collect info of new location & filename
send>%counter%
press right * 4
wait>2
press lctrl
wait>0.1
send>c
wait>0.1
release lctrl
wait>0.1
getclipboard>%xloc%
wait>0.1
press right
wait>0.1
press esc
wait>2
press lctrl
wait>0.1
send>c
wait>0.1
release lctrl
wait>0.1
getclipboard>%zloc%
wait>0.1
press esc
wait>2
press right
wait>0.1
press lctrl
wait>0.1
send>c
wait>0.1
release lctrl
wait>0.1
getclipboard>%newfilename%
wait>0.1
press esc
wait>2
SetFocus>Inivis AC3D
WaitWindowOpen>Inivis AC3D
MoveWindow>Inivis AC3D,-4,-4
ResizeWindow>Inivis AC3D,1288,998
//move cursor to x move cell & enter new x & z locations
MouseMove>38,288
LClick
wait>2
Press Tab
wait>0.1
Press Shift
wait>0.1
Press Tab
wait>0.1
Release Shift
wait>0.1
send>%xloc%
press tab * 2
wait>2
send>%zloc%
wait>1
//move model
MouseMove>145,286
LClick
wait>2
//export model to file
press lalt
release lalt
send>fe
wait>2
press enter
wait>2
send>%newfilename%
wait>2
press enter
wait>2
setfocus>Microsoft Excel - Wonderland Modelling Macro Structure
WaitWindowOpen>Microsoft Excel - Wonderland Modelling Macro Structure
MoveWindow>Microsoft Excel - Wonderland Modelling Macro Structure,-4,-4
ResizeWindow>Microsoft Excel - Wonderland Modelling Macro Structure,1288,998
//restart routine
press left * 6
goto>start
//end of routine
label>finished
Copying/pasting data between applications & timing issue
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
As far as I can understand what you are doing, it all looks good. Here are some comments:
1. This section: might be more reliable like this:
May make no difference in this application.
2. This definitely has all the looks of a recorded macro with all of the Wait>s that you asked about. At some point you will find it easier to write the scripts directly vs. recording, and you will see that most of the Wait>s are not needed. You could probably remove all of them.
3. There are a few times when Wait> is needed, but it might be easier to insert them as needed to counter those few race conditions that need it. There is a variable SK_DELAY for keyboard entry speed with the Send> command. The default is 0, but I have usually set a value of 2, like this: Let>SK_DELAY= 2. Probably could live with 0, but I found fewer problems by using 2 as a regular work habit at this time, after many years of using Macro Scheduler. I usually set this at the beginning of every script that uses keyboard data entry.
4. Recording has also added many Window Move and Resizing commands which can also be removed in many instances. You do need to use the SetFocus> before using Keyboard/mouse commands like Send>, Press, MouseMove, etc. And also keep the WaitWindowOpen> also.
================================
Looks great for day 2, Robbie. Welcome to the family.
1. This section:
Code: Select all
press lalt
release lalt
send>fe
Code: Select all
press lalt
send>fe
release lalt
2. This definitely has all the looks of a recorded macro with all of the Wait>s that you asked about. At some point you will find it easier to write the scripts directly vs. recording, and you will see that most of the Wait>s are not needed. You could probably remove all of them.
3. There are a few times when Wait> is needed, but it might be easier to insert them as needed to counter those few race conditions that need it. There is a variable SK_DELAY for keyboard entry speed with the Send> command. The default is 0, but I have usually set a value of 2, like this: Let>SK_DELAY= 2. Probably could live with 0, but I found fewer problems by using 2 as a regular work habit at this time, after many years of using Macro Scheduler. I usually set this at the beginning of every script that uses keyboard data entry.
4. Recording has also added many Window Move and Resizing commands which can also be removed in many instances. You do need to use the SetFocus> before using Keyboard/mouse commands like Send>, Press, MouseMove, etc. And also keep the WaitWindowOpen> also.
================================
Looks great for day 2, Robbie. Welcome to the family.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Thanks for the welcome & the ideas Bob.
I'll check out the SK_Delay after & see if I can't clean up using it. As for removing the Wait commands, as I mentioned I put those in to avoid the errors I was facing - it may well be that SK_Delay will do the same job (that would save a lot of headaches in the future).
Actually the only parts of the script that weren't recorded were the opening lines, moving between the applications & the MoveMouse bit. I've had quite a bit of experience writing macros in Excel - I've found recording is beneficial in seeing how things come together but a good manual is essential. And with experience you get to know what you can trim off...
Thanks again. Appreciate it.
Robbie
Will let you know how I go on the skdelay front.
I'll check out the SK_Delay after & see if I can't clean up using it. As for removing the Wait commands, as I mentioned I put those in to avoid the errors I was facing - it may well be that SK_Delay will do the same job (that would save a lot of headaches in the future).
Actually the only parts of the script that weren't recorded were the opening lines, moving between the applications & the MoveMouse bit. I've had quite a bit of experience writing macros in Excel - I've found recording is beneficial in seeing how things come together but a good manual is essential. And with experience you get to know what you can trim off...
Thanks again. Appreciate it.
Robbie
Will let you know how I go on the skdelay front.
There are much easier, more reliable ways of getting data from Excel. One is using DDE, the other VBScript.
DDE:
http://www.mjtnet.com/forum/viewtopic.p ... =excel+dde
VBScript:
http://www.mjtnet.com/forum/viewtopic.p ... =excel+dde
You can also run Excel macros/VBA routines:
http://www.mjtnet.com/forum/viewtopic.p ... =excel+dde
DDE:
http://www.mjtnet.com/forum/viewtopic.p ... =excel+dde
VBScript:
http://www.mjtnet.com/forum/viewtopic.p ... =excel+dde
You can also run Excel macros/VBA routines:
http://www.mjtnet.com/forum/viewtopic.p ... =excel+dde
MJT Net Support
[email protected]
[email protected]
Wow, thanks Support.
I like the look of those - the DDE one looks great. I take it that as long as your Excel file is open there's no need to go backwards & forwards as I've done here.
Just on Bob's point (going back to some basics), would the SK_Delay command negate the need to worry about all the wait commands I stuck in?
Thanks
Robbie
I like the look of those - the DDE one looks great. I take it that as long as your Excel file is open there's no need to go backwards & forwards as I've done here.
Just on Bob's point (going back to some basics), would the SK_Delay command negate the need to worry about all the wait commands I stuck in?
Thanks
Robbie
Correct. With DDE you just need to make sure Excel and the xls file in question is open and then you just need a DDE call for each cell of data. No going backwards and forwards, no need for focusing or keystroke simulation.RobbieVL wrote:I like the look of those - the DDE one looks great. I take it that as long as your Excel file is open there's no need to go backwards & forwards as I've done here.
SK_DELAY can be used to set the delay time between each character that is sent by the Send Character/Text (Send) command. It's impossible for me to say whether it's use will negate the use of other Wait commands, which cause a delay between lines of script, without sitting in front of your PC and running through the script with the debugger. But I guess there will be some circumstances where they effectively do the same thing. I.e. This:RobbieVL wrote:Just on Bob's point (going back to some basics), would the SK_Delay command negate the need to worry about all the wait commands I stuck in?
Send>H
Wait>0.002
Send>i
Is the same as this:
Let>SK_DELAY=2
Send>Hi
Each places a delay of 2 milliseconds between sending the letter H and the letter i.
Hope this helps.
MJT Net Support
[email protected]
[email protected]