Re-trigger key when released Topic is solved

Ask gaming related questions
ryancoll22
Posts: 7
Joined: 13 Oct 2018, 03:14

Re-trigger key when released

13 Oct 2018, 03:19

I have software that allows for toggle behavior but I want to turn it into a momentary behavior.
Is there a way to re-trigger the tab key when it has been released? (without it repeating permanently)

thanks
Ryan
Net_Wars
Posts: 19
Joined: 10 Oct 2018, 11:11

Re: Re-trigger key when released

13 Oct 2018, 07:53

You mean to repeat the Tab key once after you press it?

Code: Select all

Tab::
Loop 1
Send, {Tab}
return
Edit: this won't help you. Don't use this
Last edited by Net_Wars on 13 Oct 2018, 09:42, edited 2 times in total.
User avatar
Nextron
Posts: 1318
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Re-trigger key when released

13 Oct 2018, 08:23

The code above would keep retriggering while you hold the key. This shouldn't:

Code: Select all

Tab::
	Send {Tab}
	KeyWait Tab
Return
Tab up::Send {Tab}
ryancoll22
Posts: 7
Joined: 13 Oct 2018, 03:14

Re: Re-trigger key when released

13 Oct 2018, 11:12

Thanks Nextron I appreciate that. It works perfectly when I test it in word but I can't for the life of me work out why it doesn't work for streamlabs obs :S I've set revealing a layer to a hotkey which works when the script is off but as soon as I turn on the script it doesn't register me pressing the key at all. Going to have to look into this a bit but thanks for the code :)
ryancoll22
Posts: 7
Joined: 13 Oct 2018, 03:14

Re: Re-trigger key when released

13 Oct 2018, 23:36

So I've been testing a bunch of things to see the issue. My program will register Tab when there's no script effecting it or when the script is simply Tab::Tab
I'm now trying to make a script that will send q 3 seconds after Tab is pressed down so it no longer relies on Tab up, that might help it work for me. But when I write:
Tab::
Send {Tab}
word sends tab but my software doesn't hear the tab being pressed. Can I do Tab::Tab and 3 seconds later send {q} somehow?
User avatar
Nextron
Posts: 1318
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Re-trigger key when released

14 Oct 2018, 04:52

I think you need to look for the answer in the time tab is pressed down. When you use Send {Tab}, it basically sends {Tab down}{Tab up}, with the delay in between depending on the sendmode (default 'event', but possible changed to 'input', basically removing the delay). When it's in 'event' mode, the delay can be increased or decreased with SetKeyDelay. So try adding the line SetKeyDelay,100,100 as the first line of your script and see if it makes a difference.

When using Tab::Tab you're remapping both the up and down event to respectively just another up and down event, so the delay is the same as the time it takes you the press a button, which usually is longer than artificial input.

To add a delay between commands, use Sleep 3000 on a line on its own, between those commands.
ryancoll22
Posts: 7
Joined: 13 Oct 2018, 03:14

Re: Re-trigger key when released

14 Oct 2018, 07:33

Thanks that seems to have done the trick :)
Hopefully it won't break my other scripts since it's a global change but I guess time will tell. I've done it as SetKeyDelay,1,1 which works so should be minimal difference
ryancoll22
Posts: 7
Joined: 13 Oct 2018, 03:14

Re: Re-trigger key when released

14 Oct 2018, 08:01

ok so the way it behaves is that pressing it triggers a down+up and releasing it triggers a down+up. But when I hold it I want it to stay held if that's possible. To give more background I use it in a game I play (overwatch) to hold up an info screen but with the way it's behaving now the screen goes away after a millisecond and I want it to stay up for the whole duration I'm pressing the tab key for. Is this possible?
User avatar
Nextron
Posts: 1318
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Re-trigger key when released

25 Oct 2018, 05:47

I don't understand. Does Overwatch bind two different functions to tab? It sounds conflicting that you simultaneously want both native and customized behavior.

Can you describe how behaves (on down, on up, on next down and up) without any script applied to it?
ryancoll22
Posts: 7
Joined: 13 Oct 2018, 03:14

Re: Re-trigger key when released

25 Oct 2018, 21:41

ok so I want tab to control something in obs (my stream software) and also bring up the overwatch info screen as usual.

without scripts the info screen in overwatch behaves as such:
Tab down = info up
Tab up = info gone (momentary)

without scripts tab is a shotcut to toggle an video layer on the screen on/off:
Tab down = video layer toggles
Tab up = (nothing I can see happens)

The show or hide in obs can be mapped to 2 separate keys if that helps but when both assigned to tab this is how it behaves.
What I'd like is for the video layer to only appear while the overwatch info screen is up and hide when it's gone. So to achieve this I'm looking to make a macro that acts like this:

Tab down = Tab down
Tab up = Tab up, Tab down, Tab up

This way the toggle video layer should hide as I lift tab and show when I push it down. Would this be possible? Also thanks for all the help so far, I very much appreciate it :)
User avatar
Nextron
Posts: 1318
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Re-trigger key when released  Topic is solved

26 Oct 2018, 07:01

Then you'd end up with this:

Code: Select all

Tab::
	Send {Tab down}
	KeyWait Tab
Return
Tab up::Send {Tab up}{Tab}
If that doesn't work as desired, it would be best to assign obs hide to a different key and add that key to the tab up script.
ryancoll22
Posts: 7
Joined: 13 Oct 2018, 03:14

Re: Re-trigger key when released

27 Oct 2018, 03:47

That works, thanks so much :D It sometimes gets stuck so I'll just need to adjust wait times I think but should be good if I don't press tab a lot quickly

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 8 guests