Can I change the input (GetKeyState) and output (Send,) keys based on user input (preferably InputBox)?

StackOverflow https://stackoverflow.com/questions/17712975

  •  03-06-2022
  •  | 
  •  

Frage

I want to make a script that will temporarily create a Turbo button, with the input/output customizable per run. Ideally, something like

InputBox, TriggerKey, Input Trigger Here    ; Custom turbo trigger
InputBox, TurboKey, Input Turbo Button Here ; and custom turbo key
while NOT GetKeyState("F12", "P") { ; Just so the loop would close if you ran this
  while GetKeyState(%TriggerKey%, "P") { ; when the inputted trigger is held...
    Send, %TurboKey%                     ; rapid-fire the inputted turbo
    Sleep 50
  }
}

The above code hasn't worked, and I'm not sure if it's a GetKeyState/InputBox formatting issue, a user input issue (I haven't been putting in the right strings), or I just can't make a customized turbo like this.

The most recent idea I've had for this was just to write and run another .ahk file with the inputted keys, but if this is possible without having to manage multiple files, that would be great.

War es hilfreich?

Lösung

This would be better accomplished with the Hotkey command. This way whatever is entered in your input box as the TriggerKey will fire whatever code is under the label.

InputBox, TriggerKey, Input Trigger Here    ; Custom turbo trigger
InputBox, TurboKey, Input Turbo Button Here ; and custom turbo key

Hotkey, % TriggerKey, TriggerKey
Return

TriggerKey:
    While ! GetKeyState("F12", "P") 
    {
        Send, %TurboKey%
        Sleep 50
    }
Return
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top