Ok, I'm a newbie and not a coder and don't want to be. I just need to get one thing automated to save me time.
This is supposed to export a report from Peachtree Accounting to Excel, then save the Excel sheet in a specific folder.
I chunked the script and ran the Peachtree and Excel parts separately and the both work perfectly.
But together, it stops working after the report is exported. After exporting, the script wont switch focus to Excel or close Peachtree.
I've tried all kinds of variations of setfocus, closewindow, waitwindow... adding waits (up 30 seconds!) nothing seems to work.
I know there's a deeper way of using API to do it, but I do not understand that at all. Help! PLEASE!
//Detect and delete inventory file before beginning
let>filename=C:\Users\Charles\Documents\My Dropbox\PHG- East Inventory\PHG-East Inventory.xlsx
IfFileExists>filename
DeleteFile>filename
endif
//Open Peachtree, enter password
run>"C:\Program Files (x86)\Sage\Peachtree\peachw.exe"
WaitWindowOpen>COMPANY NAME Log In
Send>PASSWORD
press>Enter
//WaitWindowOpen>COMPANY NAME- Peachtree Accounting
//Open Inventory Report
Press ALT
send>ri
Release ALT
Let>WF_TYPE=3
WaitWindowOpen>Select a Report or Form
//select report
press Tab
press Down
Press ralt
Send>n
Release ralt
press down*2
Press Enter
WaitWindowOpen>Modify Report - Inventory for sales reps
press enter
Press enter
wait>5
//focus on Excel
WaitWindowOpen>Microsoft Excel - Book1
SetFocus>Microsoft Excel - Book1
//select column D and set formate to currency
MouseMove>828,187
LClick
MouseMove>922,106
lclick
//save file
press lalt
send fa
Release lalt
WaitWindowOpen>Save As
send>C:\Users\Charles\Documents\My Dropbox\PHG- East Inventory\PHG-East Inventory
Press Enter
//Close Excel
WaitWindowClosed>Save As
SetFocus>Microsoft Excel - PHG-East Inventory
Press ALT
Press F4
Release ALT
//Close Peachtree
CloseWindow>Select a Report or Form
WaitWindowClosed>Select a Report or Form
setfocus>* PACIFIC HOME & GARDEN INC. - Peachtree Accounting
Press ALT
Press F4
Release ALT
Still can't switch focus
Moderators: Dorian (MJT support), JRL
I believe the asterisk as the first character in the window_title will cause problems. It should only be used as the last character, and then only in the context of a "wild card" character.setfocus>* PACIFIC HOME & GARDEN INC. - Peachtree Accounting
I think you are missing the ">" character after send.send fa
i.e. send>fa
Try adding this as the first line in your script
Let>STEP_DELAY=500
It introduces additional waits automatically. It the script works with the step _delay, then you know it's a timing issue.
Use "View System Windows" to be sure you have the window titles
coded correctly. Sometimes window titles have an invisible trailing
space character you need to account for. Using the wild card * is good for this.
Sometimes you need to focus a window before sending keystrokes - WaitWindowOpen will NOT focus the window.WaitWindowOpen>Modify Report - Inventory for sales reps
press enter
Do this instead:
Code: Select all
WaitWindowOpen>Modify Report - Inventory for sales reps
SetFocus>Modify Report - Inventory for sales reps
Wait>0.5
press enter
Do this instead
Remove the asterisk from the front and put it instead at the end
Code: Select all
setfocus>PACIFIC HOME & GARDEN INC. - Peachtree Accounting*
Try using the debugger. With the script open in the editor, and the cursor on the first line of the script, press F8 to execute the script one line at a time.(from the help file) ...looks at all windows and sets focus to the first one it finds whose title *contains* the entered text
That did not work. I got an error saying the window did not exist. As I said, the name of the window is "* PACIFIC HOME & GARDEN INC. - Peachtree Accounting" I'm not adding the asterisk for search purposes, its part of the name.
Interestingly, when I put the asterisk back, the whole script works now. Not sure what changed, but it seems to work now. Thanks for your help!
Interestingly, when I put the asterisk back, the whole script works now. Not sure what changed, but it seems to work now. Thanks for your help!