Long timer needs a small helping hand. Topic is solved

Ask gaming related questions (AHK v1.1 and older)
RainerAHK87
Posts: 4
Joined: 02 Dec 2018, 05:39

Long timer needs a small helping hand.

02 Dec 2018, 06:39

Hello.
Been using AHK for a long time, I mostly google around a lot for what I want AHK to do for me, then copy \ paste code parts and fiddle around until I can make it work. So my code might be real ugly. :) Unfortunately, I am stuck this time, after two days of google\trial\error testing, I had to registered a account to seek help from the gods on these forums. Sorry I just can't find any good info on this specific issue after -a lot- of google and testing. Help please! :)

This is what I have:

Code: Select all

~f7::Pause, Toggle

#If !A_IsPaused
~$e::SetTimer, e, % (Toggle_e := !Toggle_e) ? 2910 : "Off"
e:
Send, %A_ThisLabel%
return
#If

The core of the problem:
I don't want the script to activate e when I press e second time to toggle the loop off. I DO want it to send e keyboardclick when I initialy press e the first time to activate the loop, and that's working as intended. But when the loop is active I wish I could press the e toggle button again to turn the loop off without sending e again ingame. Hope I manage to explain so it's understandable.

Ingame Function:
Just to further complicate and give insight I can describe what the scrips purpose is:
I have four charges of a ability with slow recharge, when I use the ability I get a three second stacking buff. I want to loop the ability every 2.9-ish for perfect stack overlapping. Problem is that, some times, I want to use just one charge, not all of them, and not two of them. So clicking my e bind once gives me my desired first charge use, but when i click it again to turn the loop off it wastes one of my precious charges.


Help is very much appreciated guys, very very appreciated. Sorry for coming here with probably standard question but I've been trying a lot before i ask.
Thanks a lot in advance.




I will add a bunch of silly #hashtags to the bottom here, so that other people with my problem maybe can find this and learn. If anyone have any smart hashtags they think I should add here please go ahead and suggest. Or if this hashtaging is pointless go ahead and tell me and I'll remove this part. Just trying to make this accessible to others. #sendonce #looptoggle #Donotactivate #toggle #send #donotsend #pressbindonce #cantturnloopoffwithoutactivatingbind #toggleoff #togglenosend #nosendtoggle #sendontoggle #sendwhentoggle #turnoff #sendoff #dontsend #send #can't #cant #loop #excludefromloop #include #ignoresend #ignorebind #halt #help #notworking
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Long timer needs a small helping hand.  Topic is solved

02 Dec 2018, 08:15

I'd try

Code: Select all

~f7::Pause, Toggle

#If !A_IsPaused
$e::
	SetTimer, e, % (Toggle_e := !Toggle_e) ? 2910 : "Off"
	If (Toggle_e)
		Gosub, e
Return
e:
	Send, %A_ThisLabel%
return
#If
RainerAHK87
Posts: 4
Joined: 02 Dec 2018, 05:39

Re: Long timer needs a small helping hand.

02 Dec 2018, 09:38

Thank you for such a quick and on point reply. Thank you, very, very much! That does exactly what I wished for.

Problem fixed.
:superhappy:


For anyone who might see this and notices a small difference in our code:

Code: Select all

~$e::

$e::
The ~ signals activation when the binded button is pressed down, instead of the defaulted activation on key release.
Something that I override to when pressed down in my game anyway.

Thanks again, for cleaning up my code a bit and making the world a more cooperative and happy place. :)
RainerAHK87
Posts: 4
Joined: 02 Dec 2018, 05:39

Re: Long timer needs a small helping hand.

04 Dec 2018, 07:59

There is one more thing here I'd wish to have cleaned up if anyone can spot it.
The script send a Caps Lock click some times and some times not, strange. This activates one of my other abilities that's bound to Caps Lock and when that happen it destroys what I try to do with the loop. Any simple way to not have the Caps Lock send happen but still have script functioning the same way?
Thanks.
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Long timer needs a small helping hand.

04 Dec 2018, 14:42

When CapsLock is on, it will be toggled off temporarily during the Send. To prevent that, replace Send, %A_ThisLabel% with Send, {Blind}%A_ThisLabel%.

For gameing, it's wise to always use Send, {Blind}...
RainerAHK87
Posts: 4
Joined: 02 Dec 2018, 05:39

Re: Long timer needs a small helping hand.

12 Dec 2018, 06:38

Thanks a lot! That perfected it.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: ReyAHK and 43 guests