saving file issue

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
gregpet
Newbie
Posts: 13
Joined: Wed May 22, 2013 8:11 pm

saving file issue

Post by gregpet » Tue Jun 18, 2013 5:54 pm

I have a script that runs 4 reports in a RDP window using QuickBooks and as such uses image recognition. The script seems to hang on reports 3 and 4 at the file name dialog box. The script uses subroutines and those work fine for the reports 1 and 2.

When it gets to 3 it seems the cursor moves over a bit (like a space was sent) and then it hangs there. If it stop it, close the save file dialog box and restart the script from where the report was run - it works fine, but then hangs at report #4. doing the same thing, report #4 works.

I have tried playing wit wait times or using image recognition to try and make sure the cursor is in the file name box, but none of them seem to work.

Thanks for looking and all your help. This forum has been very helpful.

// REPORT #1
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_3.bmp,WINDOW:192.168.196.40 - Remote Desktop Connection,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
wait>0.2
LClick
Endif

//Wait for
WaitScreenImage>%BMP_DIR%\image_7.bmp,0.7,CCOEFF
SetFocus>192.168.196.40 - Remote Desktop Connection
wait>0.5

gosub excel
Let>SK_DELAY=15
Let>SK_IGNORECAPS=0
SendText>\\tsclient\C\Users\GPetersen\Documents\2013\Monthly\HTE P&L
wait>0.2
Press Enter
gosub confirm

wait>5

// REPORT #2
// Change date to first of year
SetFocus>192.168.196.40 - Remote Desktop Connection
Press Tab
Let>SK_DELAY=15
SendText>1/1/2013

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_6.bmp,WINDOW:192.168.196.40 - Remote Desktop Connection,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif

//Wait for
WaitScreenImage>%BMP_DIR%\image_9.bmp,0.7,CCOEFF
SetFocus>192.168.196.40 - Remote Desktop Connection
wait>1

gosub excel
Let>SK_DELAY=15
Let>SK_IGNORECAPS=0
SendText>\\tsclient\C\Users\GPetersen\Documents\2013\Monthly\HTE P&L YTD
wait>0.2
Press Enter
gosub confirm
gosub close

// REPORT #3
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_11.bmp,WINDOW:192.168.196.40 - Remote Desktop Connection,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
wait>0.1
LClick
Endif

//Wait for
WaitScreenImage>%BMP_DIR%\image_14.bmp,0.7,CCOEFF
SetFocus>192.168.196.40 - Remote Desktop Connection
wait>0.5

gosub excel
seems to hang here
Let>SK_DELAY=15
Let>SK_IGNORECAPS=0
SendText>\\tsclient\C\Users\GPetersen\Documents\2013\Monthly\HTE BS
wait>0.2
Press Enter
gosub confirm
gosub close

// REPORT #4
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_12.bmp,WINDOW:192.168.196.40 - Remote Desktop Connection,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
wait>0.1
LClick
Endif

//Wait for
WaitScreenImage>%BMP_DIR%\image_13.bmp,0.7,CCOEFF
SetFocus>192.168.196.40 - Remote Desktop Connection
wait>0.5

gosub excel
and again here
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_17.bmp,WINDOW:192.168.196.40 - Remote Desktop Connection,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
Let>SK_DELAY=15
Let>SK_IGNORECAPS=0
SendText>\\tsclient\C\Users\GPetersen\Documents\2013\Monthly\HTE CF
wait>0.2
Press Enter
gosub confirm
gosub close


SRT excel
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_4.bmp,WINDOW:192.168.196.40 - Remote Desktop Connection,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
wait>0.2
LClick
wait>.02
Endif

Press Down
wait>0.5
Press Enter
wait>0.3
Press Enter
Endif
//Wait for
WaitScreenImage>%BMP_DIR%\image_8.bmp,0.7,CCOEFF
SetFocus>192.168.196.40 - Remote Desktop Connection
wait>1
END>excel

SRT confirm
//Wait for
WaitScreenImage>%BMP_DIR%\image_16.bmp,0.7,CCOEFF
SetFocus>192.168.196.40 - Remote Desktop Connection
wait>0.2
Press Tab
wait>0.2
Press Enter
wait>10
END>confirm

SRT close
// CLOSE P&L Window
SetFocus>192.168.196.40 - Remote Desktop Connection
Press CTRL
wait>0.1
Press F4
wait>0.1
release CTRL
END>close

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Jun 18, 2013 9:39 pm

Hi gregpet,
Try:

Code: Select all

/ REPORT #3
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_11.bmp,WINDOW:192.168.196.40 - Remote Desktop Connection,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>0.1
  LClick
Else
  MDL>Fatal: Image_11 Not Found
  Exit
Endif

//Wait for
Let>WSI_Timeout=10
WaitScreenImage>%BMP_DIR%\image_14.bmp,0.7,CCOEFF
If>WSI_Timedout=TRUE
  MDL>Fatal: Image_14 Not Found
  Exit
Endif
// ^^^^^^^^^ Let us know your result here. Thanks.
SetFocus>192.168.196.40 - Remote Desktop Connection
wait>0.5
gosub excel
seems to hang here
Let>SK_DELAY=15
Let>SK_IGNORECAPS=0
SendText>\\tsclient\C\Users\GPetersen\Documents\2013\Monthly\HTE BS
wait>0.2
Press Enter
gosub confirm
gosub close

gregpet
Newbie
Posts: 13
Joined: Wed May 22, 2013 8:11 pm

Post by gregpet » Wed Jun 19, 2013 7:16 pm

Adding those lines there were no messages. Here is the log where it hangs:

WaitScreenImage>C:\Users\GPetersen\Documents\Macro Scheduler 14\Month End Reports HTE\image_8.bmp,0.7,CCOEFF
6/19/2013 14:04:48:078 - 156: //SetFocus>192.168.196.40 - Remote Desktop Connection
6/19/2013 14:04:49:092 - 157: wait>1
6/19/2013 14:04:49:092 - 158: END>excel
6/19/2013 14:04:49:092 - 103: Let>SK_DELAY=15
6/19/2013 14:04:49:092 - 104: Let>SK_IGNORECAPS=0
6/19/2013 14:04:49:997 - 105: SendText>\\tsclient\C\Users\GPetersen\Documents\2013\Monthly\HTE BS
6/19/2013 14:04:50:200 - 106: wait>0.2
6/19/2013 14:04:50:231 - 107: Press Enter
6/19/2013 14:04:50:231 - 108: gosub confirm
6/19/2013 14:04:50:231 - 161: //Wait for
6/19/2013 14:05:01:307 - 162: WaitScreenImage>C:\Users\GPetersen\Documents\Macro Scheduler 14\Month End Reports HTE\image_16.bmp,0.7,CCOEFF
--- I stopped it here becuase it was not doing anything.
6/19/2013 14:05:01:307 - Finished Macro : Month End Reports HTE

Looks to me like it thinks it put the file name in and is waiting for the confirm save as image to appear.

I cut Report #3 and #4 lines with the subroutines and place it in another script. I then called that script from the main one. Report #3 ran fine, hung in the same place for #4

I cut the Report #4 code with the subroutines from that and created a new script. I then called each of those from the main script and it worked fine.

Why did it work in seperate scripts (3 now) and not all in one? All subroutines are the same.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Jun 19, 2013 10:06 pm

Gregpet,
Thanks for your feedback.
Your crystal-clear problem narrative is helpful in troubleshooting.
gregpet wrote:6/19/2013 14:05:01:307 - 162: WaitScreenImage>C:\Users\GPetersen\Documents\Macro Scheduler 14\Month End Reports HTE\image_16.bmp,0.7,CCOEFF
--- I stopped it here becuase it was not doing anything.
It means the subject screen has never appeared. Try:

Code: Select all

SetFocus>192.168.196.40 - Remote Desktop Connection
Wait>1
Let>WSI_Timeout=30
WaitScreenImage>C:\Users\GPetersen\Documents\Macro Scheduler 14\Month End Reports HTE\image_16.bmp,0.7,CCOEFF
If>WSI_Timedout=TRUE
  MDL>Error: Image_16 not found. Report to Gregpet immediately!
  Exit
Endif

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