autohotkeyahk | holding a mouse-button to hold another key?












0
















UPDATED-STATEMENT: 20181102@112800@SUN Post created
UPDATED-STATEMENT: 20181104@133200@TUE Suggested pre-requisite code that worked only for a short while
UPDATED-STATEMENT: 20190101@184318@TUE Pre-requisite code no longer works in csgo anymore and never had with kf2 so I need help with another solution as to why it doesn't work perhaps an update happened preventing it from working for csgo



win10_v1803.17134.345_home
autohotkeyahk_v1.1.30.00


How to hold w when holding XButton1 on Logitech G502 using AutoHotKey? Problem is when holding the key with the script below it just sends a single output and not producing typical Windows-behavior which is really holding it (see below for example). Keep in mind that just because i'm intentionally using this for the purpose of playing fps games, but globally remapping it is much easier than including every game I so happen to play to be part of changing the LogitechG502's control buttons.




I think it's cool to move forward in-game while grabbing hot cheetos with my other hand



Would suggestions here make games wanna change?



Are games becoming dependent to knowing what their users are keystroking?




PROBLEM




  • I don't have a way to remap XButton1 on my LogitechG502 to replicate holding w


    • ahk-while command works but doesn't behave properly and acts as a press-release-press-release really fast even when slowed down using ahk-sleep

    • see below for solution on setting up several ahk-commands to remap LogitechG502's XButton1 to w to move forward while ingame




SOLUTION




  • None-so-far


    • Code suggested by user3419297 no longer works after a csgo update that was relevant to this very post




SAMPLE




  • Notworking: XButton1::SendInput, w ; mouse advanced button back as holding forward in-game


    • Holding for 3-sec, XButton1 (w/ script above) gives me: w

    • Holding for 3-sec, w gives me: wwwwwwwwwwwwwwwwwwwwwwwwww



  • Worksbutimproperuseoftoggle (or fast repetition of pressing down W):


    • doesn't replicate holding w properly as this method is way faster of a repeat even when slowed down by ahk-sleep




$XButton1::
while GetKeyState("XButton1", "P")
Send w
return



  • Workbutnotanymore


    • This pre-requisite code doesn't work anymore after 2-months of usage and perhaps that may be due to a csgo update as I don't have another fps shooter to test it with




#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook
#If WinActive ahk_exe csgo.exe || WinActive ahk_exe game2.exe || WinActive ahk_exe game3.exe
XButton1::w
#IfWinActive









share|improve this question

























  • Unclear what are your problem and solution.

    – harrymc
    Nov 2 '18 at 13:27











  • Problem is that the suggested answer by @user3419297, gets the job done by actually holding w, but it's too fast and not properly replicating how window's holds down a key.

    – fohrums
    Nov 3 '18 at 12:28
















0
















UPDATED-STATEMENT: 20181102@112800@SUN Post created
UPDATED-STATEMENT: 20181104@133200@TUE Suggested pre-requisite code that worked only for a short while
UPDATED-STATEMENT: 20190101@184318@TUE Pre-requisite code no longer works in csgo anymore and never had with kf2 so I need help with another solution as to why it doesn't work perhaps an update happened preventing it from working for csgo



win10_v1803.17134.345_home
autohotkeyahk_v1.1.30.00


How to hold w when holding XButton1 on Logitech G502 using AutoHotKey? Problem is when holding the key with the script below it just sends a single output and not producing typical Windows-behavior which is really holding it (see below for example). Keep in mind that just because i'm intentionally using this for the purpose of playing fps games, but globally remapping it is much easier than including every game I so happen to play to be part of changing the LogitechG502's control buttons.




I think it's cool to move forward in-game while grabbing hot cheetos with my other hand



Would suggestions here make games wanna change?



Are games becoming dependent to knowing what their users are keystroking?




PROBLEM




  • I don't have a way to remap XButton1 on my LogitechG502 to replicate holding w


    • ahk-while command works but doesn't behave properly and acts as a press-release-press-release really fast even when slowed down using ahk-sleep

    • see below for solution on setting up several ahk-commands to remap LogitechG502's XButton1 to w to move forward while ingame




SOLUTION




  • None-so-far


    • Code suggested by user3419297 no longer works after a csgo update that was relevant to this very post




SAMPLE




  • Notworking: XButton1::SendInput, w ; mouse advanced button back as holding forward in-game


    • Holding for 3-sec, XButton1 (w/ script above) gives me: w

    • Holding for 3-sec, w gives me: wwwwwwwwwwwwwwwwwwwwwwwwww



  • Worksbutimproperuseoftoggle (or fast repetition of pressing down W):


    • doesn't replicate holding w properly as this method is way faster of a repeat even when slowed down by ahk-sleep




$XButton1::
while GetKeyState("XButton1", "P")
Send w
return



  • Workbutnotanymore


    • This pre-requisite code doesn't work anymore after 2-months of usage and perhaps that may be due to a csgo update as I don't have another fps shooter to test it with




#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook
#If WinActive ahk_exe csgo.exe || WinActive ahk_exe game2.exe || WinActive ahk_exe game3.exe
XButton1::w
#IfWinActive









share|improve this question

























  • Unclear what are your problem and solution.

    – harrymc
    Nov 2 '18 at 13:27











  • Problem is that the suggested answer by @user3419297, gets the job done by actually holding w, but it's too fast and not properly replicating how window's holds down a key.

    – fohrums
    Nov 3 '18 at 12:28














0












0








0


1







UPDATED-STATEMENT: 20181102@112800@SUN Post created
UPDATED-STATEMENT: 20181104@133200@TUE Suggested pre-requisite code that worked only for a short while
UPDATED-STATEMENT: 20190101@184318@TUE Pre-requisite code no longer works in csgo anymore and never had with kf2 so I need help with another solution as to why it doesn't work perhaps an update happened preventing it from working for csgo



win10_v1803.17134.345_home
autohotkeyahk_v1.1.30.00


How to hold w when holding XButton1 on Logitech G502 using AutoHotKey? Problem is when holding the key with the script below it just sends a single output and not producing typical Windows-behavior which is really holding it (see below for example). Keep in mind that just because i'm intentionally using this for the purpose of playing fps games, but globally remapping it is much easier than including every game I so happen to play to be part of changing the LogitechG502's control buttons.




I think it's cool to move forward in-game while grabbing hot cheetos with my other hand



Would suggestions here make games wanna change?



Are games becoming dependent to knowing what their users are keystroking?




PROBLEM




  • I don't have a way to remap XButton1 on my LogitechG502 to replicate holding w


    • ahk-while command works but doesn't behave properly and acts as a press-release-press-release really fast even when slowed down using ahk-sleep

    • see below for solution on setting up several ahk-commands to remap LogitechG502's XButton1 to w to move forward while ingame




SOLUTION




  • None-so-far


    • Code suggested by user3419297 no longer works after a csgo update that was relevant to this very post




SAMPLE




  • Notworking: XButton1::SendInput, w ; mouse advanced button back as holding forward in-game


    • Holding for 3-sec, XButton1 (w/ script above) gives me: w

    • Holding for 3-sec, w gives me: wwwwwwwwwwwwwwwwwwwwwwwwww



  • Worksbutimproperuseoftoggle (or fast repetition of pressing down W):


    • doesn't replicate holding w properly as this method is way faster of a repeat even when slowed down by ahk-sleep




$XButton1::
while GetKeyState("XButton1", "P")
Send w
return



  • Workbutnotanymore


    • This pre-requisite code doesn't work anymore after 2-months of usage and perhaps that may be due to a csgo update as I don't have another fps shooter to test it with




#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook
#If WinActive ahk_exe csgo.exe || WinActive ahk_exe game2.exe || WinActive ahk_exe game3.exe
XButton1::w
#IfWinActive









share|improve this question

















UPDATED-STATEMENT: 20181102@112800@SUN Post created
UPDATED-STATEMENT: 20181104@133200@TUE Suggested pre-requisite code that worked only for a short while
UPDATED-STATEMENT: 20190101@184318@TUE Pre-requisite code no longer works in csgo anymore and never had with kf2 so I need help with another solution as to why it doesn't work perhaps an update happened preventing it from working for csgo



win10_v1803.17134.345_home
autohotkeyahk_v1.1.30.00


How to hold w when holding XButton1 on Logitech G502 using AutoHotKey? Problem is when holding the key with the script below it just sends a single output and not producing typical Windows-behavior which is really holding it (see below for example). Keep in mind that just because i'm intentionally using this for the purpose of playing fps games, but globally remapping it is much easier than including every game I so happen to play to be part of changing the LogitechG502's control buttons.




I think it's cool to move forward in-game while grabbing hot cheetos with my other hand



Would suggestions here make games wanna change?



Are games becoming dependent to knowing what their users are keystroking?




PROBLEM




  • I don't have a way to remap XButton1 on my LogitechG502 to replicate holding w


    • ahk-while command works but doesn't behave properly and acts as a press-release-press-release really fast even when slowed down using ahk-sleep

    • see below for solution on setting up several ahk-commands to remap LogitechG502's XButton1 to w to move forward while ingame




SOLUTION




  • None-so-far


    • Code suggested by user3419297 no longer works after a csgo update that was relevant to this very post




SAMPLE




  • Notworking: XButton1::SendInput, w ; mouse advanced button back as holding forward in-game


    • Holding for 3-sec, XButton1 (w/ script above) gives me: w

    • Holding for 3-sec, w gives me: wwwwwwwwwwwwwwwwwwwwwwwwww



  • Worksbutimproperuseoftoggle (or fast repetition of pressing down W):


    • doesn't replicate holding w properly as this method is way faster of a repeat even when slowed down by ahk-sleep




$XButton1::
while GetKeyState("XButton1", "P")
Send w
return



  • Workbutnotanymore


    • This pre-requisite code doesn't work anymore after 2-months of usage and perhaps that may be due to a csgo update as I don't have another fps shooter to test it with




#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook
#If WinActive ahk_exe csgo.exe || WinActive ahk_exe game2.exe || WinActive ahk_exe game3.exe
XButton1::w
#IfWinActive






keyboard mouse autohotkey gaming






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 at 5:31







fohrums

















asked Nov 2 '18 at 11:48









fohrumsfohrums

74312




74312













  • Unclear what are your problem and solution.

    – harrymc
    Nov 2 '18 at 13:27











  • Problem is that the suggested answer by @user3419297, gets the job done by actually holding w, but it's too fast and not properly replicating how window's holds down a key.

    – fohrums
    Nov 3 '18 at 12:28



















  • Unclear what are your problem and solution.

    – harrymc
    Nov 2 '18 at 13:27











  • Problem is that the suggested answer by @user3419297, gets the job done by actually holding w, but it's too fast and not properly replicating how window's holds down a key.

    – fohrums
    Nov 3 '18 at 12:28

















Unclear what are your problem and solution.

– harrymc
Nov 2 '18 at 13:27





Unclear what are your problem and solution.

– harrymc
Nov 2 '18 at 13:27













Problem is that the suggested answer by @user3419297, gets the job done by actually holding w, but it's too fast and not properly replicating how window's holds down a key.

– fohrums
Nov 3 '18 at 12:28





Problem is that the suggested answer by @user3419297, gets the job done by actually holding w, but it's too fast and not properly replicating how window's holds down a key.

– fohrums
Nov 3 '18 at 12:28










2 Answers
2






active

oldest

votes


















2














This should work:



; maximum number of hotkeys that can be pressed within 2 seconds (default rate of hotkey activations)
; without triggering a warning dialog:
#MaxHotkeysPerInterval 10000

$XButton1::
while GetKeyState("XButton1", "P")
{
Send w
Sleep 20 ; ms or more if you want to reduce the frequency of the send command
}
return


Untested.



https://autohotkey.com/docs/commands/While.htm



https://autohotkey.com/docs/commands/_MaxHotkeysPerInterval.htm






share|improve this answer


























  • Tested working, but it is really fast and replacing Send to SendInput is even faster. It isn't the same behavior as holding w. I am also not understanding the reason for the pound-sign line with the interval 10000.

    – fohrums
    Nov 3 '18 at 11:58











  • You can reduce the frequency of the send command within the loop by adding a sleep (time before repeating the send command) in it. See the edited answer.

    – user3419297
    Nov 3 '18 at 13:04











  • That does help with it being fast, but when testing it in-game I get movefoward-stop-moveforward-stop action. It's not the right type of behavior i'm looking for. Maybe it isn't with the ahk-while, but perhaps a way to just hold down a key?

    – fohrums
    Nov 4 '18 at 13:04



















2














Try also the remapping:



#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook

#IfWinActive Title of my game

XButton1::w

#IfWinActive


Replace Title of my game with the exact title of the game window as shown in Window Spy.



https://autohotkey.com/docs/commands/_IfWinActive.htm



EDIT:



You can use the #If- or the #IfWinActive- directive to create context-sensitive hotkeys for more than one applications/windows:



#If WinActive("Title of my game1") || WinActive("Title of my game2") ; "||" means "OR"

XButton1::w
XButton2::x

#If WinActive("Title of my game3")

XButton1::a
XButton2::b

#If ; turn off context sensitivity

; In all other applications/windows you can make XButton1 and XButton2 to do something else, e.g.:

XButton1:: Send ^c ; copy
XButton2:: Send ^v ; paste


https://autohotkey.com/docs/commands/_If.htm






share|improve this answer


























  • This works, but I wanted to avoid having to implement the title of game and create multiple same code for each (gametitle). So the lines w/ the poundsign is needed including the last line #ifwinactive?

    – fohrums
    Nov 6 '18 at 12:35






  • 1





    See EDIT in my answer.

    – user3419297
    Nov 6 '18 at 13:06











  • That helps with the redundancy, but this code doesn't work with Killing Floor 2. Do you know if it's because it uses the Unreal Engine?

    – fohrums
    Dec 7 '18 at 23:33











  • This is strange, but this all of a sudden doesn't work for csgo anymore. Not sure if it was an update or what.

    – fohrums
    Jan 1 at 8:42











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1372164%2fautohotkeyahk-holding-a-mouse-button-to-hold-another-key%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














This should work:



; maximum number of hotkeys that can be pressed within 2 seconds (default rate of hotkey activations)
; without triggering a warning dialog:
#MaxHotkeysPerInterval 10000

$XButton1::
while GetKeyState("XButton1", "P")
{
Send w
Sleep 20 ; ms or more if you want to reduce the frequency of the send command
}
return


Untested.



https://autohotkey.com/docs/commands/While.htm



https://autohotkey.com/docs/commands/_MaxHotkeysPerInterval.htm






share|improve this answer


























  • Tested working, but it is really fast and replacing Send to SendInput is even faster. It isn't the same behavior as holding w. I am also not understanding the reason for the pound-sign line with the interval 10000.

    – fohrums
    Nov 3 '18 at 11:58











  • You can reduce the frequency of the send command within the loop by adding a sleep (time before repeating the send command) in it. See the edited answer.

    – user3419297
    Nov 3 '18 at 13:04











  • That does help with it being fast, but when testing it in-game I get movefoward-stop-moveforward-stop action. It's not the right type of behavior i'm looking for. Maybe it isn't with the ahk-while, but perhaps a way to just hold down a key?

    – fohrums
    Nov 4 '18 at 13:04
















2














This should work:



; maximum number of hotkeys that can be pressed within 2 seconds (default rate of hotkey activations)
; without triggering a warning dialog:
#MaxHotkeysPerInterval 10000

$XButton1::
while GetKeyState("XButton1", "P")
{
Send w
Sleep 20 ; ms or more if you want to reduce the frequency of the send command
}
return


Untested.



https://autohotkey.com/docs/commands/While.htm



https://autohotkey.com/docs/commands/_MaxHotkeysPerInterval.htm






share|improve this answer


























  • Tested working, but it is really fast and replacing Send to SendInput is even faster. It isn't the same behavior as holding w. I am also not understanding the reason for the pound-sign line with the interval 10000.

    – fohrums
    Nov 3 '18 at 11:58











  • You can reduce the frequency of the send command within the loop by adding a sleep (time before repeating the send command) in it. See the edited answer.

    – user3419297
    Nov 3 '18 at 13:04











  • That does help with it being fast, but when testing it in-game I get movefoward-stop-moveforward-stop action. It's not the right type of behavior i'm looking for. Maybe it isn't with the ahk-while, but perhaps a way to just hold down a key?

    – fohrums
    Nov 4 '18 at 13:04














2












2








2







This should work:



; maximum number of hotkeys that can be pressed within 2 seconds (default rate of hotkey activations)
; without triggering a warning dialog:
#MaxHotkeysPerInterval 10000

$XButton1::
while GetKeyState("XButton1", "P")
{
Send w
Sleep 20 ; ms or more if you want to reduce the frequency of the send command
}
return


Untested.



https://autohotkey.com/docs/commands/While.htm



https://autohotkey.com/docs/commands/_MaxHotkeysPerInterval.htm






share|improve this answer















This should work:



; maximum number of hotkeys that can be pressed within 2 seconds (default rate of hotkey activations)
; without triggering a warning dialog:
#MaxHotkeysPerInterval 10000

$XButton1::
while GetKeyState("XButton1", "P")
{
Send w
Sleep 20 ; ms or more if you want to reduce the frequency of the send command
}
return


Untested.



https://autohotkey.com/docs/commands/While.htm



https://autohotkey.com/docs/commands/_MaxHotkeysPerInterval.htm







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 3 '18 at 13:10

























answered Nov 2 '18 at 13:36









user3419297user3419297

1,856267




1,856267













  • Tested working, but it is really fast and replacing Send to SendInput is even faster. It isn't the same behavior as holding w. I am also not understanding the reason for the pound-sign line with the interval 10000.

    – fohrums
    Nov 3 '18 at 11:58











  • You can reduce the frequency of the send command within the loop by adding a sleep (time before repeating the send command) in it. See the edited answer.

    – user3419297
    Nov 3 '18 at 13:04











  • That does help with it being fast, but when testing it in-game I get movefoward-stop-moveforward-stop action. It's not the right type of behavior i'm looking for. Maybe it isn't with the ahk-while, but perhaps a way to just hold down a key?

    – fohrums
    Nov 4 '18 at 13:04



















  • Tested working, but it is really fast and replacing Send to SendInput is even faster. It isn't the same behavior as holding w. I am also not understanding the reason for the pound-sign line with the interval 10000.

    – fohrums
    Nov 3 '18 at 11:58











  • You can reduce the frequency of the send command within the loop by adding a sleep (time before repeating the send command) in it. See the edited answer.

    – user3419297
    Nov 3 '18 at 13:04











  • That does help with it being fast, but when testing it in-game I get movefoward-stop-moveforward-stop action. It's not the right type of behavior i'm looking for. Maybe it isn't with the ahk-while, but perhaps a way to just hold down a key?

    – fohrums
    Nov 4 '18 at 13:04

















Tested working, but it is really fast and replacing Send to SendInput is even faster. It isn't the same behavior as holding w. I am also not understanding the reason for the pound-sign line with the interval 10000.

– fohrums
Nov 3 '18 at 11:58





Tested working, but it is really fast and replacing Send to SendInput is even faster. It isn't the same behavior as holding w. I am also not understanding the reason for the pound-sign line with the interval 10000.

– fohrums
Nov 3 '18 at 11:58













You can reduce the frequency of the send command within the loop by adding a sleep (time before repeating the send command) in it. See the edited answer.

– user3419297
Nov 3 '18 at 13:04





You can reduce the frequency of the send command within the loop by adding a sleep (time before repeating the send command) in it. See the edited answer.

– user3419297
Nov 3 '18 at 13:04













That does help with it being fast, but when testing it in-game I get movefoward-stop-moveforward-stop action. It's not the right type of behavior i'm looking for. Maybe it isn't with the ahk-while, but perhaps a way to just hold down a key?

– fohrums
Nov 4 '18 at 13:04





That does help with it being fast, but when testing it in-game I get movefoward-stop-moveforward-stop action. It's not the right type of behavior i'm looking for. Maybe it isn't with the ahk-while, but perhaps a way to just hold down a key?

– fohrums
Nov 4 '18 at 13:04













2














Try also the remapping:



#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook

#IfWinActive Title of my game

XButton1::w

#IfWinActive


Replace Title of my game with the exact title of the game window as shown in Window Spy.



https://autohotkey.com/docs/commands/_IfWinActive.htm



EDIT:



You can use the #If- or the #IfWinActive- directive to create context-sensitive hotkeys for more than one applications/windows:



#If WinActive("Title of my game1") || WinActive("Title of my game2") ; "||" means "OR"

XButton1::w
XButton2::x

#If WinActive("Title of my game3")

XButton1::a
XButton2::b

#If ; turn off context sensitivity

; In all other applications/windows you can make XButton1 and XButton2 to do something else, e.g.:

XButton1:: Send ^c ; copy
XButton2:: Send ^v ; paste


https://autohotkey.com/docs/commands/_If.htm






share|improve this answer


























  • This works, but I wanted to avoid having to implement the title of game and create multiple same code for each (gametitle). So the lines w/ the poundsign is needed including the last line #ifwinactive?

    – fohrums
    Nov 6 '18 at 12:35






  • 1





    See EDIT in my answer.

    – user3419297
    Nov 6 '18 at 13:06











  • That helps with the redundancy, but this code doesn't work with Killing Floor 2. Do you know if it's because it uses the Unreal Engine?

    – fohrums
    Dec 7 '18 at 23:33











  • This is strange, but this all of a sudden doesn't work for csgo anymore. Not sure if it was an update or what.

    – fohrums
    Jan 1 at 8:42
















2














Try also the remapping:



#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook

#IfWinActive Title of my game

XButton1::w

#IfWinActive


Replace Title of my game with the exact title of the game window as shown in Window Spy.



https://autohotkey.com/docs/commands/_IfWinActive.htm



EDIT:



You can use the #If- or the #IfWinActive- directive to create context-sensitive hotkeys for more than one applications/windows:



#If WinActive("Title of my game1") || WinActive("Title of my game2") ; "||" means "OR"

XButton1::w
XButton2::x

#If WinActive("Title of my game3")

XButton1::a
XButton2::b

#If ; turn off context sensitivity

; In all other applications/windows you can make XButton1 and XButton2 to do something else, e.g.:

XButton1:: Send ^c ; copy
XButton2:: Send ^v ; paste


https://autohotkey.com/docs/commands/_If.htm






share|improve this answer


























  • This works, but I wanted to avoid having to implement the title of game and create multiple same code for each (gametitle). So the lines w/ the poundsign is needed including the last line #ifwinactive?

    – fohrums
    Nov 6 '18 at 12:35






  • 1





    See EDIT in my answer.

    – user3419297
    Nov 6 '18 at 13:06











  • That helps with the redundancy, but this code doesn't work with Killing Floor 2. Do you know if it's because it uses the Unreal Engine?

    – fohrums
    Dec 7 '18 at 23:33











  • This is strange, but this all of a sudden doesn't work for csgo anymore. Not sure if it was an update or what.

    – fohrums
    Jan 1 at 8:42














2












2








2







Try also the remapping:



#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook

#IfWinActive Title of my game

XButton1::w

#IfWinActive


Replace Title of my game with the exact title of the game window as shown in Window Spy.



https://autohotkey.com/docs/commands/_IfWinActive.htm



EDIT:



You can use the #If- or the #IfWinActive- directive to create context-sensitive hotkeys for more than one applications/windows:



#If WinActive("Title of my game1") || WinActive("Title of my game2") ; "||" means "OR"

XButton1::w
XButton2::x

#If WinActive("Title of my game3")

XButton1::a
XButton2::b

#If ; turn off context sensitivity

; In all other applications/windows you can make XButton1 and XButton2 to do something else, e.g.:

XButton1:: Send ^c ; copy
XButton2:: Send ^v ; paste


https://autohotkey.com/docs/commands/_If.htm






share|improve this answer















Try also the remapping:



#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook

#IfWinActive Title of my game

XButton1::w

#IfWinActive


Replace Title of my game with the exact title of the game window as shown in Window Spy.



https://autohotkey.com/docs/commands/_IfWinActive.htm



EDIT:



You can use the #If- or the #IfWinActive- directive to create context-sensitive hotkeys for more than one applications/windows:



#If WinActive("Title of my game1") || WinActive("Title of my game2") ; "||" means "OR"

XButton1::w
XButton2::x

#If WinActive("Title of my game3")

XButton1::a
XButton2::b

#If ; turn off context sensitivity

; In all other applications/windows you can make XButton1 and XButton2 to do something else, e.g.:

XButton1:: Send ^c ; copy
XButton2:: Send ^v ; paste


https://autohotkey.com/docs/commands/_If.htm







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 6 '18 at 13:13

























answered Nov 4 '18 at 13:32









user3419297user3419297

1,856267




1,856267













  • This works, but I wanted to avoid having to implement the title of game and create multiple same code for each (gametitle). So the lines w/ the poundsign is needed including the last line #ifwinactive?

    – fohrums
    Nov 6 '18 at 12:35






  • 1





    See EDIT in my answer.

    – user3419297
    Nov 6 '18 at 13:06











  • That helps with the redundancy, but this code doesn't work with Killing Floor 2. Do you know if it's because it uses the Unreal Engine?

    – fohrums
    Dec 7 '18 at 23:33











  • This is strange, but this all of a sudden doesn't work for csgo anymore. Not sure if it was an update or what.

    – fohrums
    Jan 1 at 8:42



















  • This works, but I wanted to avoid having to implement the title of game and create multiple same code for each (gametitle). So the lines w/ the poundsign is needed including the last line #ifwinactive?

    – fohrums
    Nov 6 '18 at 12:35






  • 1





    See EDIT in my answer.

    – user3419297
    Nov 6 '18 at 13:06











  • That helps with the redundancy, but this code doesn't work with Killing Floor 2. Do you know if it's because it uses the Unreal Engine?

    – fohrums
    Dec 7 '18 at 23:33











  • This is strange, but this all of a sudden doesn't work for csgo anymore. Not sure if it was an update or what.

    – fohrums
    Jan 1 at 8:42

















This works, but I wanted to avoid having to implement the title of game and create multiple same code for each (gametitle). So the lines w/ the poundsign is needed including the last line #ifwinactive?

– fohrums
Nov 6 '18 at 12:35





This works, but I wanted to avoid having to implement the title of game and create multiple same code for each (gametitle). So the lines w/ the poundsign is needed including the last line #ifwinactive?

– fohrums
Nov 6 '18 at 12:35




1




1





See EDIT in my answer.

– user3419297
Nov 6 '18 at 13:06





See EDIT in my answer.

– user3419297
Nov 6 '18 at 13:06













That helps with the redundancy, but this code doesn't work with Killing Floor 2. Do you know if it's because it uses the Unreal Engine?

– fohrums
Dec 7 '18 at 23:33





That helps with the redundancy, but this code doesn't work with Killing Floor 2. Do you know if it's because it uses the Unreal Engine?

– fohrums
Dec 7 '18 at 23:33













This is strange, but this all of a sudden doesn't work for csgo anymore. Not sure if it was an update or what.

– fohrums
Jan 1 at 8:42





This is strange, but this all of a sudden doesn't work for csgo anymore. Not sure if it was an update or what.

– fohrums
Jan 1 at 8:42


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1372164%2fautohotkeyahk-holding-a-mouse-button-to-hold-another-key%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...