making a timer without reset

Ask gaming related questions
Shuu148
Posts: 39
Joined: 11 May 2023, 21:25

making a timer without reset

05 Jan 2024, 14:53

Hi all. I need help here. So i want to push the Button "f" and the timer should start. In 7.2 second a sound should play. During these 7.2 seconds, i cannot reset the timer, only after the 7.2 seconds i can activate the button again.

Code: Select all

~f::
{

    if (GetKeyState("f", "P") and cerbs = 0)
		SetTimer Timer1,7200
	    global cerbs := 1


	{

	}

	 if (GetKeyState("f", "P") and cerbs = 1)

		Soundbeep 1500
	{

	}




}

Timer1()
{
        global cerbs := 1
		static Start_Counter1 := 0
		if (Start_Counter1 < 1)
		{

			Start_Counter1++
			Soundbeep 1500


		}

	   if (Start_Counter1 == 1)
	   {
		global cerbs := 0
		Start_Counter1 := 0
	   }

}
User avatar
mikeyww
Posts: 28873
Joined: 09 Sep 2014, 18:38

Re: making a timer without reset

05 Jan 2024, 15:07

Hello,

Ideas are below. By default, a hotkey cannot be triggered while it is already executing and has not yet completed-- which conveniently matches your description.

Code: Select all

#Requires AutoHotkey v2.0

f:: {
 SoundBeep 1500
 go
 Sleep 7200
 SoundBeep 1000
}

go() {
 Loop 20 {
  Send 1
  Sleep 250
 }
}
User avatar
Noitalommi_2
Posts: 393
Joined: 16 Aug 2023, 10:58

Re: making a timer without reset

05 Jan 2024, 18:19

Hi,

not sure, something like this?

Code: Select all

#Requires AutoHotkey >=2.0

~f:: {

	static Status := true
	if Status {
		SetTimer(Timer.Bind(&Status), -7200)
		Status := false
	}
}

Timer(&Status) {

	SoundBeep
	Status := true
}
Shuu148
Posts: 39
Joined: 11 May 2023, 21:25

Re: making a timer without reset

06 Jan 2024, 03:05

Thx guys.

Return to “Gaming Help (v2)”

Who is online

Users browsing this forum: No registered users and 7 guests