XButton2 press and release help
XButton2 press and release help
Im trying to set my side mouse button to have 2 functions. One when the key is pressed (and hold that action till that key is released), and another when that key is released. I've tried to use {Xbutton2 down} but it doesnt recognize it as a valid key. Any thought?
- BrockPlaysFortnite
- Posts: 84
- Joined: 06 Nov 2021, 08:47
Re: XButton2 press and release help
Ok I think I got it. Does this work?
Code: Select all
XButton2::
While GetKeyState("XButton2","p") ;while the 5th mouse button is held down
{
tooltip testing ;we will get a loop of the tooltip over and over
}
tooltip the key was released ;then we get out of the loop which means the key was released so you can make a new action on release :D
return
Fortnite Youtuber BrockPlaysFortnite | AHK completely redefined the way I do things. What used to take me hours to do over and over can now be done with the click of a button. Don't give up! It's worth learning it front to back
(Note: I'm still a noob so my code may suck sometimes and there is almost assuredly a better way to do it)
(Note: I'm still a noob so my code may suck sometimes and there is almost assuredly a better way to do it)
Re: XButton2 press and release help
Code: Select all
#Requires AutoHotkey v1.1.33
; #Requires AutoHotkey v2.0
XButton2::SoundBeep 1500
XButton2 Up::MsgBox 12345
1. Braces are omitted in specifying a hotkey.
2. Up is a hotkey modifier, but Down is not. Hotkeys without Up are triggered on the press (with some exceptions).
Explained: Introduction and simple examples • Up (has more examples)
Last edited by mikeyww on 26 Jan 2023, 16:49, edited 1 time in total.
- BrockPlaysFortnite
- Posts: 84
- Joined: 06 Nov 2021, 08:47
Re: XButton2 press and release help
Any idea why this wasn't working?mikeyww wrote: ↑26 Jan 2023, 16:45Concepts:Code: Select all
#Requires AutoHotkey v1.1.33 ; #Requires AutoHotkey v2.0 XButton2::SoundBeep 1500 XButton2 Up::MsgBox 12345
1. Braces are omitted in specifying a hotkey.
2. Up is a hotkey modifier, but Down is not. Hotkeys without Up are triggered on the press.
Explained: Introduction and simple examples
When I do this, the tooltip works correctly when I let go of Xbutton2
Code: Select all
;~ Xbutton2::
;~ tooltip testing down
Xbutton2 up::
tooltip testing up
Code: Select all
Xbutton2::
tooltip testing down
Xbutton2 up::
tooltip testing up
Last edited by BrockPlaysFortnite on 26 Jan 2023, 16:51, edited 1 time in total.
Fortnite Youtuber BrockPlaysFortnite | AHK completely redefined the way I do things. What used to take me hours to do over and over can now be done with the click of a button. Don't give up! It's worth learning it front to back
(Note: I'm still a noob so my code may suck sometimes and there is almost assuredly a better way to do it)
(Note: I'm still a noob so my code may suck sometimes and there is almost assuredly a better way to do it)
Re: XButton2 press and release help
A multi-line hotkey subroutine should end with a Return command. Without Return, the script proceeds to the next statement.
If you read the page that I cited in my post, you can see an example of a typical setup for a hotkey subroutine.
What do you believe will happen upon pressing F3?
Another idea is to try my XButton script to see if it works.
If you read the page that I cited in my post, you can see an example of a typical setup for a hotkey subroutine.
Code: Select all
#Requires AutoHotkey v1.1.33
F3::
Send x
F4::
Send y
Return
Another idea is to try my XButton script to see if it works.
- BrockPlaysFortnite
- Posts: 84
- Joined: 06 Nov 2021, 08:47
Re: XButton2 press and release help
Ahh you're right changing it to single lines works correctly I've spent so much time on silly mistakes like that over timemikeyww wrote: ↑26 Jan 2023, 16:50A multi-line hotkey subroutine should end with a Return command. Without Return, the script proceeds to the next statement.
If you read the page that I cited in my post, you can see an example of a typical setup for a hotkey subroutine.
What do you believe will happen upon pressing F3?Code: Select all
#Requires AutoHotkey v1.1.33 F3:: Send x F4:: Send y Return
Another idea is to try my XButton script to see if it works.
Code: Select all
Xbutton2::tooltip testing down
Xbutton2 up::tooltip testing up
Fortnite Youtuber BrockPlaysFortnite | AHK completely redefined the way I do things. What used to take me hours to do over and over can now be done with the click of a button. Don't give up! It's worth learning it front to back
(Note: I'm still a noob so my code may suck sometimes and there is almost assuredly a better way to do it)
(Note: I'm still a noob so my code may suck sometimes and there is almost assuredly a better way to do it)
Re: XButton2 press and release help
I did this but changed Soundbeep 1500 to 3 and MsgBox 12345 to l, Which is what i want my hotkeys to be. Yet I get an error saying Duplicate hotkey *XButton2 Up. Any ides on it maybe i just missed something. Your code worked perfectly till i changed the actions.mikeyww wrote: ↑26 Jan 2023, 16:45Concepts:Code: Select all
#Requires AutoHotkey v1.1.33 ; #Requires AutoHotkey v2.0 XButton2::SoundBeep 1500 XButton2 Up::MsgBox 12345
1. Braces are omitted in specifying a hotkey.
2. Up is a hotkey modifier, but Down is not. Hotkeys without Up are triggered on the press (with some exceptions).
Explained: Introduction and simple examples • Up (has more examples)
Re: XButton2 press and release help
I tried this and it worked but when i changed it to my desired keybinds:mikeyww wrote: ↑26 Jan 2023, 16:45Concepts:Code: Select all
#Requires AutoHotkey v1.1.33 ; #Requires AutoHotkey v2.0 XButton2::SoundBeep 1500 XButton2 Up::MsgBox 12345
1. Braces are omitted in specifying a hotkey.
2. Up is a hotkey modifier, but Down is not. Hotkeys without Up are triggered on the press (with some exceptions).
Explained: Introduction and simple examples • Up (has more examples)
Code: Select all
#Requires AutoHotkey v1.1.33
; #Requires AutoHotkey v2.0
XButton2::3
XButton2 Up::l
Re: XButton2 press and release help
Reading some documentation will quickly shed light on the problem and answer your question, as a remap of one key translates to a pair of hotkeys that includes both the key-down and key-up.
https://www.autohotkey.com/docs/v1/misc/Remap.htm#actually
You now know why the duplication error was generated.
The fix is easy, because you can use the Send command instead for both of your hotkeys. An example is provided on line 3 of my second post.
https://www.autohotkey.com/docs/v1/misc/Remap.htm#actually
You now know why the duplication error was generated.
The fix is easy, because you can use the Send command instead for both of your hotkeys. An example is provided on line 3 of my second post.