Page 1 of 1

One key with two functions

Posted: 01 Aug 2019, 11:55
by Phobia
I am wanting to make one key do two things. For example if I hit the X key on the keyboard, is it possible to make a script that uses the X key as normal then additionally can add a left mouse click. For an example say I’m playing a FPS and X is my zoom and left click is my fire. The script I am wondering if possible would allow you to press X which would zoom then instantly fire making quick scopes possible with one key press.

Re: One key with two functions

Posted: 01 Aug 2019, 12:40
by Sashkon
Hi, Try this
x presses x ,Click

Code: Select all

$x::SendInput, x{Click}

Re: One key with two functions

Posted: 01 Aug 2019, 12:43
by Xtra
Another example:

Code: Select all

~x::Click 

Re: One key with two functions

Posted: 01 Aug 2019, 12:48
by Phobia
Thanks. I will give this a try as soon as I get home.

Re: One key with two functions

Posted: 01 Aug 2019, 13:07
by Phobia
If I wanted three different keys to do the same thing would I just make a script like this

~x::Click
~c::Click
~v::Click

All in one script?

Re: One key with two functions

Posted: 01 Aug 2019, 13:08
by Sashkon
Xtra wrote:
01 Aug 2019, 12:43
Another example:

Code: Select all

~x::Click 
This doesn't work for quickscope, because click first then x

Re: One key with two functions

Posted: 01 Aug 2019, 13:40
by Sashkon
Phobia wrote:
01 Aug 2019, 13:07
If I wanted three different keys to do the same thing would I just make a script like this

~x::Click
~c::Click
~v::Click

All in one script?
Yes, Do all hotkeys in one file.
and add #IfWinActive so your keys will active only when they needed.

Code: Select all

#IfWinActive, ahk_exe game.exe
	$x::SendInput, x{Click}
	$c::SendInput, c{Click}
	$v::SendInput, v{Click}
#IfWinActive

Re: One key with two functions

Posted: 01 Aug 2019, 14:23
by Xtra
Yes

Re: One key with two functions

Posted: 01 Aug 2019, 16:43
by Phobia
It works but here’s an issue. If I hit it it works one time. Then if I let off and hit it again it will repeatedly work without letting off. Anyway to make it do so on the first click?

Re: One key with two functions

Posted: 01 Aug 2019, 17:58
by Phobia
I need a loop when I hold a key down. Is this possible?

Re: One key with two functions

Posted: 01 Aug 2019, 22:30
by Sashkon
You can press x and on key up - press click

Code: Select all

$x::
	SendInput, x
	KeyWait, x
	SendInput, {Click}
	return

Re: One key with two functions

Posted: 02 Aug 2019, 07:58
by Phobia
Sashkon wrote:
01 Aug 2019, 22:30
You can press x and on key up - press click

Code: Select all

$x::
	SendInput, x
	KeyWait, x
	SendInput, {Click}
	return
This will make it click when letting off of x?