开发者

Autohotkey loop not working

My loop in my autohotkey script is only running through once. Can anyone tell me why? Thanks

Loop, 8 
{
  WinActivate, NDTr
  ControlClick, Button3 ;Select Batch, enter info, start collecting data
  WinWait, Batch Readings
  ControlClick, Edit1
  Send {BS}+{BS}+{BS}+{BS}+{BS}+{BS}
  Send 1
  ControlClick, Edit2
  Send {BS}+{BS}+{BS}+{BS}+{BS}+{BS}
  Send 15

  if A_Index = 4
  {
    Sleep, 20000
  }
  else if A_Index = 7
  {
    Sleep, 20000
  }
  else if A_Index 开发者_Go百科= 1
  {
    Sleep, 3000
  }
  else 
  {
    Sleep, 15000
  }

  ControlClick, Button1
  Sleep, 15000
}


WinWait looks like a likely culprit like anthv123 said. Double check your window's title and make sure it fits the TitleMatchMode that you're expecting.

Common debugging practices include adding different ToolTips in places along the problem code. For example tooltips above and below the WinWait line with texts "before" and "after" would tell you if it's pausing indefinitely at that part (if it never says "after").

Sleeping for 3-20 seconds isn't going to help your patience either.


Try using this to diagnose the issue. If "Batch Readings" takes longer than 5 seconds, you get an error letting you know and the loop continues

WinWait, Batch Readings,,5
if (errorLevel = 1)
   Msgbox % "Batch Readings timed out"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜