Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

Ask gaming related questions
SurfNSlide
Posts: 11
Joined: 13 May 2019, 04:10

Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

08 Jun 2019, 12:44

Hi,

title pretty much says all, I spent hours trying it to get to work, trying countless combinations, none worked.

since ALT is my Crouch Hold & Slide Key I CANNOT rebind it, same goes with TAB for Spotting, so please dont suggest that...
I do have a crouch Toggle key though (y, German keyboard), which could be toggled when Tab is pressed and LAlt needs to be disabled.
Ive arrived at a somewhat working skript by now, but its not too reliable: Sometimes the Y press isnt recognized correctly it seems, maybe a small delay can change that?! Sleep command doesnt really seem to work with SendInput (which I want for speed/reliability I think) or Im too stupid to do correctly ^^

heres my code so far:

Code: Select all

*LAlt::return
Hotkey, *LAlt, Off

#If GetKeyState("LAlt", "P")
*Tab::
Hotkey, *LAlt, On
KeyWait, LAlt, LD
Send {Blind}{y}
Send {Tab down}
KeyWait, Tab
Send {Blind}Tab up}
Hotkey, *LAlt, Off
return
#if
update, this seems more efficient and reliable, still far from perfect though:

Code: Select all

LAlt & Tab::
Send {Blind}{LAlt up}
Send {Blind}{y 8}
Send {Blind}{Tab down}
Send {Blind}{y 8}
KeyWait, Tab
Send {Tab up}
if GetKeyState("LAlt", "P")
	Send {LAlt down}
return
Output from keyhistory:

Code: Select all

A4  038	 	d	0.03	LAlt           	
09  00F	h	d	0.02	Tab            	
07  000	i	d	0.00	not found      	
07  000	i	u	0.00	not found      	
A4  038	i	u	0.00	LAlt           	
59  02C	i	d	0.00	y              	
59  02C	i	u	0.00	y              	
07  000	i	d	0.00	not found      	
A4  038	i	d	0.00	LAlt           	
07  000	i	u	0.01	not found      	
07  000	i	d	0.00	not found      	
07  000	i	u	0.00	not found      	
A4  038	i	u	0.00	LAlt           	
09  00F	i	d	0.00	Tab            	
07  000	i	d	0.00	not found      	
A4  038	i	d	0.00	LAlt           	
07  000	i	u	0.02	not found      	
09  00F	h	d	0.47	Tab            	
09  00F	h	d	0.03	Tab            	
09  00F	h	d	0.03	Tab            	
09  00F	s	u	0.00	Tab            	
07  000	i	d	0.02	not found      	
07  000	i	u	0.00	not found      	
A4  038	i	u	0.00	LAlt           	
09  00F	i	u	0.00	Tab            	
07  000	i	d	0.00	not found      	
A4  038	i	d	0.01	LAlt           	
07  000	i	u	0.00	not found      	
A4  038	 	u	0.27	LAlt 
Last workaround would be just making my LAlt Key my AppsKey and LWin to LAlt (i Have LWin and Appskey caps already switched so I can use it in gaming, but would like to avoid with alt, since its an actually useful key at this position and im used to it out of games).
User avatar
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

09 Jun 2019, 18:32

Here Try this

Code: Select all

if Not A_IsAdmin AND A_OSVersion <> WIN_XP
{
    Run *RunAs "%A_ScriptFullPath%"
    ExitApp
}

Activated := 0

#if (Activated = 0) and WinActive("Counter-Strike: Global Offensive")

LAlt & Tab::
KeyWait, LAlt
SendInput, {Blind}{LAlt Down}
Activated := 1
return


#if (Activated = 1) and WinActive("Counter-Strike: Global Offensive")
!TAB::
SendInput, {Blind}{LAlt up}{Tab Down}{LAlt Down}
KeyWait, Tab
SendInput, {Blind}{Tab Up}
return

$LAlt UP::
SendInput, {Blind}{LAlt up}
Activated := 0
return
:wave: There is always more than one way to solve a problem. ;)
SurfNSlide
Posts: 11
Joined: 13 May 2019, 04:10

Re: Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

11 Jun 2019, 06:23

thanks, I will give it a try without the CSGO parts (as I have AltTab rebound completely on my Mouse (Swiftpoint Z) anyway.
Will report how it goes.
Are there any issues for you using the above code at all?

EDIT: Am I right in assuming that I have to add an #if in seperate line at the end of the code you posted to make the rest of my HKs ignore the activated condition?
ALso I already got my skript run as admin at windows startup without UAP annoyance every time, so I guess it shouldnt make a difference, right?!
I used this guide: https www.sevenforums.com /tutorials/11949-elevated-program-shortcut-without-uac-prompt-create.html Broken Link for safety
YoucefHam wrote:
09 Jun 2019, 18:32

Code: Select all

LAlt & Tab::
[...]
!TAB::
$LAlt UP::
EDIT 2: Some further questions arised:
ANy reason for the different capitalization of TAB/Tab or spelling of Alt/LAlt/!
Also I use the hook for my whole script (#InstallKeybdHook directive in header, so the $ can be omitted Im guessing?!

best regards
SurfNSlide
Posts: 11
Joined: 13 May 2019, 04:10

Re: Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

11 Jun 2019, 12:43

I tested, doesnt work at all for me: neither is the Tab function triggering, nor is AltTab disabled by any means...
BTW: I was wondering why I would KeyWait on Alt magically being released on pressing LAlt & Tab. I suppose thats the reason it doesnt work...
User avatar
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

11 Jun 2019, 14:31

you would KeyWait on Alt because if you don't you are going to release Alt with your hand.
:wave: There is always more than one way to solve a problem. ;)
SurfNSlide
Posts: 11
Joined: 13 May 2019, 04:10

Re: Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

18 Jun 2019, 03:44

I know, but I would need a working code example, because I know what to do in theory. most of it doesnt seem to be practical though
SurfNSlide
Posts: 11
Joined: 13 May 2019, 04:10

Re: Disable LAlt & Tab, keep native functions of BOTH keys when pressed TOGETHER

21 Jun 2019, 10:01

Also your answer doesnt really explain anything I asked... What exactly should the snippet do you posted? Because its entirely unclear to me... aside from geting the alt key stuck down every time

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 11 guests