I am attempting to write some scripts to automate repetitive tasks at work. I am unfamiliar with scripting and have been crawling the AutoHotkey V2 documentation in search of some guidance without success. Here is my current script:
Code: Select all
#Requires AutoHotkey v2.0
; BK Dir = "CFC - BK" & PV Dir = "CFC"
winTitle := "Aloha Configuration Center : Quality Dining"
; Waits for the control to become available
ControlWait(classNN)
{
controlVisible := false
while (controlVisible == false)
{
try
{
Sleep 100
controlVisible := ControlGetVisible(classNN, winTitle)
}
}
return 0
}
; Exports Data Distribution reports!
ExportDD(CFCDirectory, suffix)
{
; Launch CFC
Run "C:\BootDrv\" . CFCDirectory . "\ShellInstaller\CFCShellBootstrapper.exe"
; Wait for user to press enter after typing password
KeyWait "Enter", "D"
; Export DD
ControlWait("WindowsForms10.Window.8.app.0.58072d_r9_ad12") ; Wait for "Reports" to be visible
ControlClick("x60 y140", winTitle) ; Click "Reports"
ControlClick("x60 y170", winTitle) ; Click (hover over?) "Aloha Configuration Center"
ControlClick("x60 y170", winTitle) ; Click Data Distribution
ControlWait("WindowsForms10.COMBOBOX.app.0.58072d_r9_ad11") ; Wait for store selection to load
ControlClick("x170 y230", winTitle) ; Click "Sort By"
ControlClick("x170 y280", winTitle) ; Click "Last Export Time"
ControlClick("x170 y270", winTitle) ; Click "Select All"
ControlClick("x210 y730", winTitle) ; Click "Generate Report"
Sleep 5000 ; Wait for export to load
ControlClick("x170 y190", winTitle) ; Click "Export"
Send "^lC:\Users\alentine\OneDrive - Quality Dining, Inc\Documents\Records\Data Distribution{Enter}" ; Navigate to the DD reports folder
Send "{Tab 6}DD " . FormatTime(A_Now, "ShortDate") . " " . suffix . "{Enter}" ; Type in the name and date for the DD export and press enter
WinClose (winTitle) ; Close CFC
return 0
}
ExportDD("CFC - BK", "Fast")
ExportDD("CFC", "Full")
My ControlWait function will not work at all. It will continue to try I am unable to find a solution to have the script wait for the control to load before pressing it. Window Spy returns this when selecting the control I wish the script to wait for: Any help, advice, or resources would be greatly appreciated!