One key with two functions

Get help with using AutoHotkey and its commands and hotkeys
Phobia
Posts: 6
Joined: 01 Aug 2019, 09:04

One key with two functions

01 Aug 2019, 11:55

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.
Sashkon
Posts: 16
Joined: 23 Dec 2017, 05:13
Facebook: Alexander Murvajev
Google: Alexander Murvajev
GitHub: Alexander

Re: One key with two functions

01 Aug 2019, 12:40

Hi, Try this
x presses x ,Click

Code: Select all

$x::SendInput, x{Click}
Last edited by Sashkon on 01 Aug 2019, 15:31, edited 3 times in total.
User avatar
Xtra
Posts: 1512
Joined: 02 Oct 2015, 12:15

Re: One key with two functions

01 Aug 2019, 12:43

Another example:

Code: Select all

~x::Click 
Phobia
Posts: 6
Joined: 01 Aug 2019, 09:04

Re: One key with two functions

01 Aug 2019, 12:48

Thanks. I will give this a try as soon as I get home.
Phobia
Posts: 6
Joined: 01 Aug 2019, 09:04

Re: One key with two functions

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?
Sashkon
Posts: 16
Joined: 23 Dec 2017, 05:13
Facebook: Alexander Murvajev
Google: Alexander Murvajev
GitHub: Alexander

Re: One key with two functions

01 Aug 2019, 13:08

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
Sashkon
Posts: 16
Joined: 23 Dec 2017, 05:13
Facebook: Alexander Murvajev
Google: Alexander Murvajev
GitHub: Alexander

Re: One key with two functions

01 Aug 2019, 13:40

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
Last edited by Sashkon on 01 Aug 2019, 22:25, edited 4 times in total.
Phobia
Posts: 6
Joined: 01 Aug 2019, 09:04

Re: One key with two functions

01 Aug 2019, 16:43

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?
Phobia
Posts: 6
Joined: 01 Aug 2019, 09:04

Re: One key with two functions

01 Aug 2019, 17:58

I need a loop when I hold a key down. Is this possible?
Sashkon
Posts: 16
Joined: 23 Dec 2017, 05:13
Facebook: Alexander Murvajev
Google: Alexander Murvajev
GitHub: Alexander

Re: One key with two functions

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
Phobia
Posts: 6
Joined: 01 Aug 2019, 09:04

Re: One key with two functions

02 Aug 2019, 07:58

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?

Return to “Ask For Help”

Who is online

Users browsing this forum: asad41163, Bing [Bot] and 209 guests