Well when you start the timer, you are straight away going into the main loop.
The first time you do TimerDiff($timer_1) the result will be 0. It will then continue to loop and repeat this test for 1 second before this condition is met:
Code:
If(TimerDiff($timer_1) >= $Delay_1) Then
If you change it to
Code:
If(TimerDiff($timer_1) <= $Delay_1) Then
Then the first time it tests this condition, TimerDiff($timer_1) will be 0 so it will be
So the condition will be true.
However, you're going to have more problems because you then initialise timer_1 again, so you're always going to end up executing the code inside your first if(...) statement.
From what it looks like, you're trying to send a certain key sequence with specified delays between each key. Rather than use multiple timers for each delay, you might find it easier to make a sort-of 'state machine' where you use 1 timer but check for different values depending on which 'state' the program is in. This would be much easier to expand.
Something like this:
Code:
Global Const $_MAX_STATE = 5
Global $elapsedTime ; running total of elapsed milliseconds
Global $state = 0 ; will be a value from 0 to however many stages you have
Global $waitForNextState = 1 ; so we don`t keep executing the current state every time around the loop
Global $times[$_MAX_STATE] = [0, 1000, 3000, 3500, 4800] ; Delay from the start before next state
Global $keys[$_MAX_STATE] = ["2", "3", "1", "8", "6"] ; value to print on each state
Global $timer_1 = TimerInit()
Global $diff = 0
While 1
$diff = TimerDiff($timer_1)
; if we`ve reached the next state, reset $waitForNextState so we can pass the next condition
if($diff > $times[$state] AND $waitForNextState = 0) Then
$waitForNextState = 0
EndIf
; if we`re at the time specified by the current state and we haven`t already printed this state`s output
if($diff > $times[$state] AND $waitForNextState <> 0) Then
ConsoleWrite($keys[$state] & @CRLF)
$waitForNextState = 1 ; we`ve printed the output, so don't do it again until next state
If $state < $_MAX_STATE-1 Then
$state = $state + 1
Else
; Reached the last state - reset state machine to 0
$state = 0
; and reset timer
$timer_1 = TimerInit()
EndIf
EndIf
sleep(50)
WEnd