I have a Weighbridge application at work that runs on top of Paradox databases. When you exit via the GUI say by clicking the cross in the top right or {ALT} {F4} it does the right thing and cleans up after itself as it closes. If you simply say pskill ProcessName from a batch file then it leaves a heap of temporary paradox *.db files.
The problem is to try and get a backup of the application in a consistent state. Simply killing the application from a batch file doesn't work.
Enter autohotkey. Autohotkey is feature rich enough so that you can program it to send any key sequence or mouse click to a window and code it to handle different things that occur in the application.
So I am using it to exit the application or any of it's windows just before a backup.
; auto hot key script to exit weighbridge as if it was a user
; so weighbridge cleans up temp c:\weighbridge\*.db files
; james mcdonald
; 5:23 PM 10/03/2009
; this is called from backup_wb.bat
; it tries to cover all the use conditions where a user would leave different windows open
; Password Error Dialog
IfWinExist Error
{
WinActivate
Send {Escape}
}
; username / password prompt
IfWinExist Password
{
WinActivate
Send !{F4}
}
IfWinExist Vehicle List
{
WinActivate
Send !{F4}
}
IfWinExist Carrier List
{
WinActivate
Send !{F4}
}
IfWinExist Incomplete List
{
WinActivate
Send !{F4}
}
IfWinExist Customer List
{
WinActivate
Send !{F4}
}
IfWinExist Source List
{
WinActivate
Send !{F4}
}
IfWinExist Destination List
{
WinActivate
Send !{F4}
}
IfWinExist Transaction List
{
WinActivate
Send !{F4}
}
; a common report I'm not sure if there needs to be more for reports
; but should do
IfWinExist Customer by Item Report
{
WinActivate
Send !{F4}
}
IfWinExist Report Menu
{
WinActivate
Send !{F4}
}
IfWinExist WeighBridge
{
WinActivate
Send !{F4}
}
IfWinExist WeighBridge
{
WinActivate
Send !{F4}
}
IfWinExist WeighBridge
{
WinActivate
Send !{F4}
}
; snooze for 4 seconds before continuing backup_wb.bat
Sleep 4000
0 Comments