【问题标题】:AHK IF statementAHK IF声明
【发布时间】:2013-06-26 22:17:56
【问题描述】:
ArrayCount = 0
Loop, Read, Times.txt   ; This loop retrieves each line from the file.
{
    ArrayCount += 1  ; Keep track of how many items are in the array.
    ArrayTime%ArrayCount% := A_LoopReadLine  
}

WinGetTitle, Title, A
Loop %ArrayCount%
{
 element := ArrayTime%A_Index%
 Time = %A_WDay%%A_Hour%%A_Min%
 msgbox %Time% , %element%
 if (Time=%element%)
 {
  IfWinExist, Test.txt
  {
   WinActivate
    Sleep 500
    Send Hi{enter}
    msgbox %Time% , %element%
    Sleep 500
    WinActivate, %Title%
  }
 }
}

好的,所以主要问题是这部分:

如果(时间=%element%)

我也试过

如果(%Time%=%element%)

如果 (A_WDay . A_Hour . A_Min=%element%)

我认为还有一些其他类似的变化,我遇到的问题是它要么总是正确的,要么总是错误的,这取决于我是如何写的。 文本文件里面有一个这样的列表:

10000

10700

11400

20400

21100

我添加了一个包含当前测试时间的额外行,我添加了 msgbox 进行比较,我可以清楚地看到它们在它不起作用时是相同的,或者它们在它时是不同的做。很抱歉提出这样一个基本问题,但我觉得我已经尝试了很长时间,并且阅读了关于变量和 IF 语句的所有内容,感谢您的帮助。

还有一点是我需要它从周日午夜开始每 7 小时关闭一次,这就是我想出的,如果总体上可能有更好的方法,我也很乐意听到.

【问题讨论】:

    标签: arrays autohotkey


    【解决方案1】:

    试试这个:

    if % Time = element
    {
        MsgBox, Equal!
    }
    

    至于计划部分,请尝试通过 Windows 任务计划程序运行您的脚本(点击 Windows+R,输入 taskschd.msc 并按 Enter)。网上有教程解释如何创建新任务。

    【讨论】:

      【解决方案2】:

      关于定时器,以这个为例。

      SetTimer, AlertType1, 60000
      ToAlertType1:=1
      ToAlertType2:=1
      
      AlertType1:
      ;If A_WDay between 2 and 7              ; is day monday - sunday?
      ;{
      If (A_Hour = 7 or A_Hour = 13)
      {
          If (ToAlertType1)
          {
              SoundBeep, 500, 500
              ToAlertType2:=1
              ToAlertType1:=0
              MsgBox, 4096,%AppName%, Msg1.
              Return
          }
      }
      Else if (A_Hour = 21)
      {
          If (ToAlertType2)
          {
              SoundBeep, 500, 500
              ToAlertType2:=0
              ToAlertType1:=1
              MsgBox, 4096,%AppName%, Msg2.
              Return
          }
      }
      ;}
      Return
      

      【讨论】:

        猜你喜欢
        • 2016-03-26
        • 1970-01-01
        • 2020-04-07
        • 1970-01-01
        • 2014-12-03
        • 1970-01-01
        • 2016-06-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多