How do i make a key do 2 different things? help! Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
royeonald
Posts: 2
Joined: 18 May 2022, 14:55

How do i make a key do 2 different things? help!

Post by royeonald » 18 May 2022, 15:28

Hello!

so i want to create a script that does 2 things:

the first one being the spacebar becomes the left mouse button
and when i double click the spacebar it becomes as if i'm pressing both the left mouse button and the M key at the same time and when i double click again it turns back to only the left mouse button
so:
spacebar > becomes left mouse button > doubleclick > becomes left mouse button + the M key> doubleclick again > back to only left mouse button

and the second part similar to the first one in which the Alt key this time is now the right mouse button but this time when i press the P key the Alt key becomes as if i'm pressing both the right mouse button and the H key at the same time and when i press the P key again the Alt key turns back to only the right key button
so:
Alt key> becomes right mouse button > press P key > becomes right mouse button + the H key > press P key again > back to only right mouse button

and that's all! hopefully i didnt do a bad job explaining it and thank you in advance! :DDD

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

Re: How do i make a key do 2 different things? help!  Topic is solved

Post by mikeyww » 18 May 2022, 19:48

Welcome to this AutoHotkey forum!

Code: Select all

Space::
If !Ts
 SetTimer, Ts, -300
Ts++
Return
Ts:
If GetKeyState("Space", "P") || Ts = 1 {
 If both {
  Send {LButton down}{m down}
  SoundBeep, 1500
  KeyWait, Space
  Send {m up}{LButton up}
  SoundBeep, 1000
 } Else {
  Click, D
  KeyWait, Space
  Click, U
 }
} Else {
 both := !both
 SoundBeep, 1000 + 500 * both
}
Ts =
Return
Part 2 gets harder: your shot at it!

royeonald
Posts: 2
Joined: 18 May 2022, 14:55

Re: How do i make a key do 2 different things? help!

Post by royeonald » 19 May 2022, 10:37

mikeyww wrote:
18 May 2022, 19:48
Welcome to this AutoHotkey forum!

Code: Select all

Space::
If !Ts
 SetTimer, Ts, -300
Ts++
Return
Ts:
If GetKeyState("Space", "P") || Ts = 1 {
 If both {
  Send {LButton down}{m down}
  SoundBeep, 1500
  KeyWait, Space
  Send {m up}{LButton up}
  SoundBeep, 1000
 } Else {
  Click, D
  KeyWait, Space
  Click, U
 }
} Else {
 both := !both
 SoundBeep, 1000 + 500 * both
}
Ts =
Return
Part 2 gets harder: your shot at it!
Thank youuuu very much sir! i kinda felt a bit guilty for just asking for a finished script from the start without even trying to make my own first, really really really appreciate it and i will definitely do my best to give the second part a shot and keep you updated, again really thanks a lot and have a nice day!

Post Reply

Return to “Ask for Help (v1)”