I'm completely new to auto hotkey and its insanely confusing but I believe its the best bet at trying to accomplish my goal. I'm trying to get a RMB toggle that lets me have keys like say R, shift, space, Q, or basically anything I want untoggle if the toggle is enabled.
Trying to do this since some shooter games completely forget to add toggle aim and its really frustrating to play without. So far I've used mouse-x to toggle aim but I cant make it so other keys disable the toggle if its enabled. Having keys like R and space disable the toggle would make gameplay soooo much smoother. Any help is massively appreciated!
Need help trying to make a RMB toggle with buttons that disable the toggle Topic is solved
Re: Need help trying to make a RMB toggle with buttons that disable the toggle Topic is solved
Try the script below. Basically, press RMB to toggle it down, then press any key or RMB again to un-toggle it. Mouse buttons other than RMB don't un-toggle RMB hold down.
Code: Select all
#SingleInstance Force
SetBatchLines, -1
KeyList := ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "``", "-", "=", "[", "]", "`;", "'", "\", "`,", ".", "/", "CapsLock", "Space", "Tab", "Enter", "Escape", "Backspace", "Up", "Down", "Right", "Left", "ScrollLock", "Delete", "Insert", "Home", "End", "PgUp", "PgDn", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadDot", "NumLock", "NumpadDiv", "NumpadMult", "NumpadAdd", "NumpadSub", "NumpadEnter", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "LWin", "RWin", "LControl", "RControl", "LShift", "RShift", "LAlt", "RAlt", "Browser_Back", "Browser_Forward", "Browser_Refresh", "Browser_Stop", "Browser_Search", "Browser_Favorites", "Browser_Home", "Volume_Mute", "Volume_Down", "Volume_Up", "Media_Next", "Media_Prev", "Media_Stop", "Media_Play_Pause", "Launch_Mail", "Launch_Media", "Launch_App1", "Launch_App2", "AppsKey", "PrintScreen", "CtrlBreak", "Pause", "Help", "Sleep"]
;delete any key names in the above list that you don't want to untoggle rmb hold down (also delete the attached quotes, space, and comma)
Loop, % KeyList.Maxindex() ;make every key inside the key list untoggle rmb hold down when pressed
Hotkey, % "~*" Keylist[A_Index], Release_RButton_If_RButton_Is_Down, On
*$RButton:: ;when rmb is pressed, keep holding it down.
if (GetKeyState("RButton"))
SendInput, {RButton Up}
else
SendInput, {RButton Down}
return
*$RButton Up:: ;do nothing when rmb is released
return
Release_RButton_If_RButton_Is_Down:
if (GetKeyState("RButton"))
SendInput, {RButton Up}
return
Re: Need help trying to make a RMB toggle with buttons that disable the toggle
Thanks for the speedy answer @Ianizer! I tried what was posted above to the best of my understanding, the toggle RMB works but I cant seem to get it to untoggle with any other key. Below is what I tried, I'm sure I made a mistake somewhere and would love it if someone could point out what I did wrong.
Code: Select all
#SingleInstance Force
SetBatchLines, -1
KeyList := [r,LShift]
Loop, % KeyList.Maxindex()
Hotkey, % "~*" Keylist[A_Index], Release_RButton_If_RButton_Is_Down, On
*$RButton::
if (GetKeyState("RButton"))
SendInput, {RButton Up}
else
SendInput, {RButton Down}
return
*$RButton Up::
return
Release_RButton_If_RButton_Is_Down:
if (GetKeyState("RButton"))
SendInput, {RButton Up}
return
Re: Need help trying to make a RMB toggle with buttons that disable the toggle
You need to add quotation marks like so (on line 3):
Code: Select all
#SingleInstance Force
SetBatchLines, -1
KeyList := ["r", "LShift"] ;----- here is where the quotes were needed
Loop, % KeyList.Maxindex()
Hotkey, % "~*" Keylist[A_Index], Release_RButton_If_RButton_Is_Down, On
*$RButton::
if (GetKeyState("RButton"))
SendInput, {RButton Up}
else
SendInput, {RButton Down}
return
*$RButton Up::
return
Release_RButton_If_RButton_Is_Down:
if (GetKeyState("RButton"))
SendInput, {RButton Up}
return
Re: Need help trying to make a RMB toggle with buttons that disable the toggle
Thanks @Ianizer! I took your delete quotes a little overboard. It works perfectly in my tests, really appreciate the help!
Re: Need help trying to make a RMB toggle with buttons that disable the toggle
No problem @MUTO! I should've been clearer on how exactly to delete the quotes. My bad. Anyways, always happy to help!
Who is online
Users browsing this forum: Pumpk11nnn and 60 guests