A brief description of the script and error:
For each row in excel, data is pasted into 3 boxes on a company java app. The 3rd paste is followed with an {Enter} which prompts the app to search for the information in the database, and if there's a result then a dialogue box for entering a new filename appears. If instead the database query returns empty, a dialog box appears with some words and an "ok" box.
Now this is where I start crying, because whether or not the database finds something ^v and then {Enter} should close either dialog box with no issues, except that after the "ok" box closes an identical box opens. I tried simply pressing enter twice, but the second enter is ignored. A MouseClick appears incorrectly on the taskbar. I think even a MsgBox command got ignored, but it was late at that point...
This script runs perfectly fine on my non-work laptop, or if all entries result with a saved file.
Can anyone please enlighten me on what might possibly be going on here?
Work laptop runs with windows 7 and 4GB of ram, though it seems like AHK uses hardly any resources.
Code: Select all
FileSelectFile, Path
Xl := ComObjCreate("Excel.Application")
Xl.Visible := false
oWorkbook := Xl.Workbooks.Open(Path) ;open an existing file
oSheet := oWorkbook.Sheets(1)
current_row := 2
Array := []
MsgBox % "pray"
while oSheet.Range("A" . current_row).Value != ""
{
addressFull := oSheet.Range("A" . current_row).value
address := oSheet.Range("B" . current_row).value
if address is number
address := Floor(address)
street := oSheet.Range("C" . current_row).value
zip := oSheet.Range("D" . current_row).value
zip := Format("{:05}", Floor(zip))
Array.Push([addressFull, address, street, zip])
current_row++
}
Xl.Quit
Xl := ""
Sleep 2000
For k, v in Array
{
submit_row(v[1], v[2], v[3], v[4])
}
MsgBox % "all done :)"
ExitApp
Escape::
Xl.Quit
Xl := ""
ExitApp
Return
;===Functions===========================================================================
submit_row(addressFull, address, street, zip)
{
MouseClick, Left, 1140, 250 ; address
Send, ^a
Send % address
Sleep 1500
MouseClick, Left, 1220, 250 ; street name
Send, ^a
Send % street
Sleep 1500
MouseClick, Left, 1304, 250 ; zip
Send, ^a
Send % zip
Send, {Enter}
Sleep 5000
MouseClick, Left, 554, 188 ; submit
Sleep 1500
MouseClick, Left, 600, 350 ; export
Sleep 2500
Send % addressFull
Sleep 2000
Send, {Enter} ; confirm
Sleep 3000
}