I am trying to automate a rather nice piece of software which interfaces to a color measurement device. However, I think at times my input goes into the wrong window. I am pretty sure I have the correct window names as I cut and pasted from recorded macros.... and the program works correctly sometimes... other times I seem to need to repeat the keystrokes. I scanned the forum and the site - sorry if I missed anything.
I had working dialog box code, but it halted badly when I put it into this code... I think I am misunderstanding something about setting focus or suffink.
The code is logically very simple - just selection of menu items and buttons on windows. Thanks in advance for any advice.
Here is some sample code - %short_wait% is set to 3:
// Instrument/Calibration
Wait>%SHORT_WAIT%
Press ALT
Wait>%KEYPRESS_WAIT%
Release ALT
Wait>%SHORT_WAIT%
Send>i
Wait>%SHORT_WAIT%
Send>c
Wait>%SHORT_WAIT%
Wait>%SHORT_WAIT%
Wait>%SHORT_WAIT%
WaitWindowOpen>Instrument Calibration
MoveWindow>Instrument Calibration,322,219
ResizeWindow>Instrument Calibration,381,300
Wait>%SHORT_WAIT%
// I think this caused program to hang WaitReady>1
// Message>After Cal Window + %dResult%
// xxx Dialog box requesting confirmation that door is empty and closed
// Temp hardwired time
Wait>30
// Message>After myDialog + %dResult%
// Setfocus>Instrument Calibration
Wait>%SHORT_WAIT%
Send>m
Wait>%MEASURE_WAIT%
// xxx White calibration error handling
// xxx Dialog box requesting confirmation that door is open
// Temp hardwired time
Wait>30
Wait>%SHORT_WAIT%
Send>m
Wait>%MEASURE_WAIT%
// xxx Black calibration error handling
WaitWindowOpen>X-RiteColor Master - CM2
MoveWindow>X-RiteColor Master - CM2,-4,-4
ResizeWindow>X-RiteColor Master - CM2,1032,746
SetFocus>X-RiteColor Master - CM2
// Temp Label to skip over working code
Wait>%SHORT_WAIT%
// Label>ALLOK
// Instrument/Create Standard
Wait>%SHORT_WAIT%
Press ALT
Wait>%KEYPRESS_WAIT%
Release ALT
Wait>%SHORT_WAIT%
Send>i
Wait>%SHORT_WAIT%
Send>s
WaitWindowOpen>Standard Wizard - Reflectance Data Options
MoveWindow>Standard Wizard - Reflectance Data Options,199,157
ResizeWindow>Standard Wizard - Reflectance Data Options,627,425
SetFocus>Standard Wizard - Reflectance Data Options
Wait>%SHORT_WAIT%
// Next
Press Alt
Wait>%SHORT_WAIT%
Send>n
Wait>%SHORT_WAIT%
Release Alt
Wait>%SHORT_WAIT%
Press Alt
Wait>%SHORT_WAIT%
Send>n
Wait>%SHORT_WAIT%
Release Alt
Wait>%SHORT_WAIT%
//The following didn't seem to help
WaitWindowOpen>Standard Wizard - Measure Reflectance Data
MoveWindow>Standard Wizard - Measure Reflectance Data,199,157
ResizeWindow>Standard Wizard - Measure Reflectance Data,627,425
SetFocus>Standard Wizard - Measure Reflectance Data
Wait>%SHORT_WAIT%
// xxx Dialog box requesting confirmation that door is empty and closed
// (Same setup as white calibration)
Press Alt
Wait>%SHORT_WAIT%
Release Alt
Wait>%SHORT_WAIT%
Press Alt
Wait>%SHORT_WAIT%
Send>e
Wait>%SHORT_WAIT%
Release Alt
Wait>%MEASURE_WAIT%
Press Alt
Wait>%SHORT_WAIT%
Send>e
Wait>%SHORT_WAIT%
Release Alt
Wait>%MEASURE_WAIT%
Press Alt
Wait>%SHORT_WAIT%
Send>e
Wait>%SHORT_WAIT%
Release Alt
Wait>%MEASURE_WAIT%
Press Alt
Wait>%SHORT_WAIT%
Send>n
Wait>%SHORT_WAIT%
Release Alt
Wait>%SHORT_WAIT%
WaitWindowOpen>Standard Name
MoveWindow>Standard Name,199,157
ResizeWindow>Standard Name,627,425
SetFocus>Standard Name*
Wait>%SHORT_WAIT%
// xxx Currently relies on an odd regional setting
GetDate>%revshortdatetime%
Wait>%SHORT_WAIT%
ConCat>%revshortdatetime%,-
Wait>%SHORT_WAIT%
GetTime>%twentyfourtime%
Wait>%SHORT_WAIT%
ConCat>%revshortdatetime%,%twentyfourtime%
Wait>%SHORT_WAIT%
Send>%revshortdatetime%
Wait>%SHORT_WAIT%
Press ALT
Wait>%SHORT_WAIT%
Send>e
Wait>%SHORT_WAIT%
Release ALT
WaitWindowOpen>X-RiteColor Master - CM2
MoveWindow>X-RiteColor Master - CM2,-4,-4
ResizeWindow>X-RiteColor Master - CM2,1032,746
//Instrument/Measure Trial
Wait>%SHORT_WAIT%
Press ALT
Wait>%KEYPRESS_WAIT%
Release ALT
Wait>%SHORT_WAIT%
Send>i
Wait>%SHORT_WAIT%
Send>t
Wait>%SHORT_WAIT%
// Start Measuring
Let>%MEASURE_COUNTER%=0
Repeat>%MEASURE_COUNTER%
Press F8
Wait>%MEASURE_GAP%
Let>%MEASURE_COUNTER%=%MEASURE_COUNTER%+1
Until>%MEASURE_COUNTER%,%TODBASE_COUNT%
Newbie with lots of problems with changing windows
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:
Maybe these general guidelines will help
Before using Send/Press/MouseMove, etc. any Keyboard/Mouse commands, you should have focus in the correct window, the window must be ready to accept input, and the cursor needs to be in the correct position. Those guidelines work best when done in that sequence.
Typical commands to do that might look something like this:
WaitWindowOpen>WindowName*
SetFocus>WindowName*
WaitReady>1
Tab*n or MouseMove>x,y and LClick
Send>Whatever characters
WaitReady>1
Sometimes a small Wait>.2 is helpful after Press CTRL/ALT/SHIFT before using Send>
SK_DELAY may also need to be increased in some circumstances.
=============================
Note that I did not see any SetFocus> in the script you provided. I can see keys being sent but nothing that is moving the cursor to any positon. Mabe not needed in this application. It is correct that you do not need to do that when doing CTL/ALT/SHIFT combinations. It is also curious to see the ALT key held down for a period of time and then released with pressing another key to go with it.
Before using Send/Press/MouseMove, etc. any Keyboard/Mouse commands, you should have focus in the correct window, the window must be ready to accept input, and the cursor needs to be in the correct position. Those guidelines work best when done in that sequence.
Typical commands to do that might look something like this:
WaitWindowOpen>WindowName*
SetFocus>WindowName*
WaitReady>1
Tab*n or MouseMove>x,y and LClick
Send>Whatever characters
WaitReady>1
Sometimes a small Wait>.2 is helpful after Press CTRL/ALT/SHIFT before using Send>
SK_DELAY may also need to be increased in some circumstances.
=============================
Note that I did not see any SetFocus> in the script you provided. I can see keys being sent but nothing that is moving the cursor to any positon. Mabe not needed in this application. It is correct that you do not need to do that when doing CTL/ALT/SHIFT combinations. It is also curious to see the ALT key held down for a period of time and then released with pressing another key to go with it.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Window focus
Bob,
Thanks, mousemove certainly did improve my reliability in getting input to the right screen.
I had avoided it as I thought keys would be more reliable.... not so if they are going to the wrong screen
Regards,
Kathryn
Thanks, mousemove certainly did improve my reliability in getting input to the right screen.
I had avoided it as I thought keys would be more reliable.... not so if they are going to the wrong screen
Regards,
Kathryn