add exception

Ask gaming related questions (AHK v1.1 and older)
hakwish
Posts: 9
Joined: 15 May 2021, 16:30

add exception

Post by hakwish » 26 Jan 2022, 11:22

hi plz i just need to add exception to my Z,Q,S,D
i need to add shift, ctrl, and alt
i have tried ~*Alt:: but did not work, thank you for helping me :)

Code: Select all

#InstallKeybdHook
waiting_time_if_i_press_a_key_on_keyboard = 450 ;time/ms
*²:: reload
~*Alt::
~*Space::
~*z::
~*q::
~*s::
~*d::ZQSDSpaceAlt := A_TickCount + waiting_time_if_i_press_a_key_on_keyboard
;=======================================================Mono============================================================== .
XButton2:: 
SetTimer T1,% (T1:=!T1)?500:"Off"
IF !Active := T1?Active "1":StrReplace(Active,1)
	ToolTip

T1:
IF Wait() Or !T1 Or SubStr(Active, 0) <> 1
	Return

ToolTip, MONO, 830, 630
Sendinput {Blind}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}

Return 
;=======================================================Multi============================================================== .
XButton1:: 
SetTimer T2,% (T2:=!T2)?500:"Off"
If !Active := T2?Active "2":StrReplace(Active,2)
	ToolTip
T2:
IF Wait() Or !T2 Or SubStr(Active, 0) <> 2
	Return

ToolTip, MULTI, 1045, 630
Sendinput {Blind}{Numpad0}{h}{w}{p}{j}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}
Return 
;=======================================================Burst============================================================ .
$ù:: 
SetTimer T3,% (T3:=!T3)?400:"Off"
If !Active := T3?Active "3":StrReplace(Active,3)
	ToolTip
T3:
IF Wait() Or !T3 Or SubStr(Active,0) <> 3
	Return

ToolTip, BURST, 935, 630
Sendinput {Blind}{y}{x}{m}{k}{v}{*}{^}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}
return 
;=======================================================ZQSD============================================================== .
Wait()
{	Global
	IF (ZQSDSpaceAlt < A_TickCount)
		Return, A_TimeIdleKeyboard < waiting_time_if_i_press_a_key_on_keyboard
	Else
		Return, False
}
;=======================================================Color============================================================== .
[Mod edit: [code][/code] tags added.]

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

Re: add exception

Post by mikeyww » 26 Jan 2022, 18:12

You haven't said what happens when you run this script, or what should happen when you run it.

hakwish
Posts: 9
Joined: 15 May 2021, 16:30

Re: add exception

Post by hakwish » 27 Jan 2022, 04:27

hi thank you, bellow you will find the full script
when i runt it there is a loop starting sending numbers
i have made exceptions when i press z,q,s,d, space the loop will not stop, but if i press any auther button it will stop and this is what i needed,
but this time i just need to add shift alt ctrl (modifiers) to not stop the loop

=====================

Code: Select all

#InstallKeybdHook
waiting_time_if_i_press_a_key_on_keyboard = 450 ;time/ms
*²:: reload
~*Space::
~*z::
~*q::
~*s::
~*d:: ZQSDSpace := A_TickCount + waiting_time_if_i_press_a_key_on_keyboard
;=======================================================Mono============================================================== .
XButton2:: 
SetTimer T1,% (T1:=!T1)?500:"Off"
IF !Active := T1?Active "1":StrReplace(Active,1)
	ToolTip

T1:
IF Wait() Or !T1 Or SubStr(Active, 0) <> 1
	Return

ToolTip, MONO, 830, 630
Sendinput {Blind}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}

Return 
;=======================================================Multi============================================================== .
XButton1:: 
SetTimer T2,% (T2:=!T2)?500:"Off"
If !Active := T2?Active "2":StrReplace(Active,2)
	ToolTip
T2:
IF Wait() Or !T2 Or SubStr(Active, 0) <> 2
	Return

ToolTip, MULTI, 1045, 630
Sendinput {Blind}{Numpad0}{h}{w}{p}{j}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}
Return 
;=======================================================Burst============================================================ .
$ù:: 
SetTimer T3,% (T3:=!T3)?400:"Off"
If !Active := T3?Active "3":StrReplace(Active,3)
	ToolTip
T3:
IF Wait() Or !T3 Or SubStr(Active,0) <> 3
	Return

ToolTip, BURST, 935, 630
Sendinput {Blind}{y}{x}{m}{k}{v}{*}{^}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}
return 
;=======================================================ZQSD============================================================== .
Wait()
{	Global
	IF (ZQSDSpace < A_TickCount)
		Return, A_TimeIdleKeyboard < waiting_time_if_i_press_a_key_on_keyboard
	Else
		Return, False
}
;=======================================================Color============================================================== .
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 27 Jan 2022, 12:20, edited 1 time in total.
Reason: Please use code tags. Thank you!

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

Re: add exception

Post by mikeyww » 27 Jan 2022, 06:45

When I tried a modifier with one of the other keys, the routine was triggered. That is what the wildcard (*) does. Try the following script by itself.

Code: Select all

~*Space::
~*z::
~*q::
~*s::
~*d::MsgBox, Test

hakwish
Posts: 9
Joined: 15 May 2021, 16:30

Re: add exception

Post by hakwish » 27 Jan 2022, 12:11

hi, i wanted something like this : but did not word (thank you for you help :) )

Code: Select all

~*Space::
~*z::
~*q::
~*s::
~*d::   
~*+:: for shift
~*!:: for alt
~*^:: for ctrl
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 27 Jan 2022, 12:20, edited 1 time in total.
Reason: Please use code tags. Thank you!

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

Re: add exception

Post by mikeyww » 27 Jan 2022, 12:28

This worked when I pressed Alt.

Code: Select all

#InstallKeybdHook
waiting_time_if_i_press_a_key_on_keyboard = 450 ;time/ms
~*Alt::
~*Space::
~*z::
~*q::
~*s::
~*d::MsgBox, Test

Post Reply

Return to “Gaming Help (v1)”