If Alt&Tab held for certain amount of time, release tab

Get help with using AutoHotkey and its commands and hotkeys
delseyyy
Posts: 5
Joined: 01 Jan 2018, 17:00

If Alt&Tab held for certain amount of time, release tab

27 May 2018, 08:00

Basically, I have a problem with my keybord when it's automatically changing profiles. (Different profiles for chrome, desktop, word etc because of different hotkeys)
These problems occur, when the profile changes while you are holding a key. Often, it will think that you are still pressing a key, even if you dont.

For example, when I tab into chrome with alt+tab, it will keep alt and tab pushed down, which is pretty annoying (try it). These problems occur with CTRL and ALT-Tab because those are generally the keys i have pushed down when changing profiles.

Basically, I would like a script, that performs an action when alt&tab is pushed down together for a certain amount of time (which i will have to figure out myself). What action that is, I will have to figure out on my own aswell, but there arent many options:
- Send {'t Up}
- Send {'t}

Could someone please help me with detecting the keystrokes?
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: If Alt&Tab held for certain amount of time, release tab

29 May 2018, 17:27

1st: do something when alt+tab is pressed : https://autohotkey.com/docs/Hotkeys.htm

Code: Select all

~!Tab::
2nd: Create a loop : https://autohotkey.com/docs/commands/Loop.htm / https://autohotkey.com/docs/commands/Return.htm / https://autohotkey.com/docs/commands/Sleep.htm

Code: Select all

~!Tab::
Loop, 10 ; Loops 10 times 
{
	Sleep, 100 ; Waits 0,1 Seconds
}
return
3rd: Check if the keys are still pressed (if not return) : https://autohotkey.com/docs/commands/GetKeyState.htm

Code: Select all

~!Tab::
Loop, 10
{
	if(!GetKeyState("Alt") and !GetKeyState("Tab", "p")) ; Checks if Alt and Tab are released
	{
		return
	}
	Sleep, 100
}
return
4th: Send Tab up if both keys are still pressed : https://autohotkey.com/docs/commands/Send.htm

Code: Select all

~!Tab::
Loop, 10
{
	if(!GetKeyState("Alt") and !(GetKeyState("Tab", "p")))
	{
		return
	}
	Sleep, 100
}
if(GetKeyState("Alt") and GetKeyState("Tab", "p"))
{
	Send, {Tab up}
}
return	
return
If there are better solutions for this you can correct me :D

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Gully, TheMainEvent and 70 guests