How to make a toggle start at the same point every time

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ugochick
Posts: 31
Joined: 23 Mar 2021, 19:35

How to make a toggle start at the same point every time

Post by ugochick » 25 Jun 2022, 12:37

Hello!

I am having a problem and I was wondering if you can help me. I have this script that toggles between h and l with every press. It's almost perfect, but I would like to know if there's a way to make is start at h every time. instead of pressing the opposite of what was pressed last, I would like to make is so that if it wasn't pressed in the last, I don't know 10 seconds, then i restarts and goes back to h no matter what was sent last.
Do you know what I mean?

Code: Select all

x::

	Send, % (Toggle := !Toggle) ? "l" : "h"
	return
Your help would be greatly appreciated. Thank you!!!

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

Re: How to make a toggle start at the same point every time

Post by mikeyww » 25 Jun 2022, 12:44

Hotkey is X. L is sent first.

Code: Select all

x::
last := now, now := A_TickCount, (last + 10000 < now) && on := False
Send % (on := !on) ? "l" : "h"
Return

ugochick
Posts: 31
Joined: 23 Mar 2021, 19:35

Re: How to make a toggle start at the same point every time

Post by ugochick » 25 Jun 2022, 12:58

thank you so much!!!!!!

Post Reply

Return to “Ask for Help (v1)”