0

I've been trying to make a script where at specific minutes every hours, something happen. I've tried to add a loop so it can always check if it is now at the right minute of the hour. I tested the loop with a mouse click and it worked, I'm pretty sure the problem is when combining the if statement with a loop. I've been stuck for 1 hours trying to think of a way to fix it or find another way to do it.

^!p::


time:
formattime, time, , mm tt

 loop  
 {
   if (Time = "59 am")
      {
       goto action1
      }
   if (Time = "45 am")
      {
       goto action2
      }
   if (Time = "03 am")
      {
       goto action3
      }
   }
Return

action3:
 {
   msgbox, test
 }
return

action2:
 {
   msgbox, test2
 }
return

action1:
 {
   msgbox, test3
 }
return

Esc::ExitApp  ; Exit script with Escape key

1 Answer 1

1

Try this:

^!p::

loop {
  If (A_Hour > 12)  ; to work only at am time
    Continue
  Switch  A_Min {
    Case 59: ; any hour in am at 59 min
       goto action1
   Case 45: ; any hour in am at 45 min
       goto action2
   Case 3: ; any hour in am at 3 min
       goto action3
  }
}
Return

action3:
   msgbox, test
return

action2:
   msgbox, test2
return

action1:
   msgbox, test3
return


Esc::ExitApp  ; Exit script with Escape key
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.