Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- StringCaseSense, On
- AnyKeyPressedOtherThanSpace(mode = "P") {
- keys = 1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
- Loop, Parse, keys
- {
- isDown := GetKeyState(A_LoopField, mode)
- if(isDown)
- return True
- }
- return False
- }
- supressed := False
- RestoreInput(){
- BlockInput, Off
- Global supressed
- supressed := False
- }
- SupressInput(){
- Global supressed
- supressed := True
- BlockInput, On
- SetTimer, RestoreInput, -180
- }
- ModifierStates := ""
- UpdateModifierStates(){
- Global ModifierStates
- if (supressed){
- return
- }
- ModifierStates := ""
- if GetKeyState("LWin", "P") || GetKeyState("RWin", "P") {
- ModifierStates .= "#"
- }
- if GetKeyState("Ctrl", "P"){
- ModifierStates .= "^"
- }
- if GetKeyState("Alt", "P"){
- ModifierStates .= "!"
- }
- if GetKeyState("Shift", "P"){
- ModifierStates .= "+"
- }
- }
- SendKey(Key, num=1){
- Global ModifierStates
- Loop, %num%{
- Send, %ModifierStates%%Key%
- }
- }
- ReleaseModifier(){
- global space_up
- if (not space_up){
- space_up := true
- }
- Send, {RShift}
- }
- Space Up::
- Send {Blind}{Space up}
- space_up := true
- SendEvent, {RShift}
- return
- Space::
- if AnyKeyPressedOtherThanSpace(){
- SendInput, {Blind}{Space}
- Return
- }
- if (GetKeyState(LShift, mode)){
- SendInput ^{Space}
- Return
- }
- inputed := False
- space_up := False
- input, UserInput, L1 T0.05, {RShift}
- if (space_up) {
- Send, {Blind}{Space}
- return
- }else if (StrLen(UserInput) == 1){
- Send, {Space}%UserInput%
- return
- }
- SetTimer, ReleaseModifier, -18000
- while true{
- input, UserInput, L1, {RShift}
- if (space_up) {
- if (!inputed){
- Send, {Blind}{Space}
- }
- break
- }else{
- inputed := True
- StringLower, UserInput, UserInput
- UpdateModifierStates()
- SupressInput()
- if (UserInput == "b")
- SendKey("{Left}")
- else
- {
- ModifierStates .= "^"
- SendKey(UserInput)
- }
- }
- }
- RestoreInput()
- return
Add Comment
Please, Sign In to add comment