I'm new to AutoHotKey, so this could be something bone-headed on my part. I put this together yesterday, and it worked fine all day. Today it is failing to fully execute at random times.
What I'm doing is forcing Chrome to use the System Print Dialog, and then printing only the first page.
!NumpadDiv::
{
Send ^P ; CTRL+SHIFT+p forces System Print Dialog
WinWait, Print, , 2 ; Wait for Print Dialog to appear
if ErrorLevel
{
MsgBox, WinWait timed out.
return
}
else
{
IfWinActive, Print ; Added to ensure Print window was active
{
SetKeyDelay, 300 ; Upped key delay. Thought this may help. It hasn't
Send {TAB 4} ; Tabs over to Page Range
Send 1 ; Print only first page
Send {Enter}
}
}
return
}
Today the script started failing at random times. Either it does not tab over to the page range, and will print all pages, or it will tab to it, enter 1 then not print. In both cases, it triggers my PC's error sound. Any help would be appreciated, I'm very confused since this was working without issue all day yesterday.
ControlSetText, Edit4, 1. Maybe, the control has another name, you can check that out with window spy. Also, theIfWinActiveis absolutely redundant, sinceWinWaitguarantees that anyway. - MCL