is there a way to use 'space' as a hotkey without affecting hotstrings?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
davebrny
Posts: 85
Joined: 05 Dec 2016, 06:26

is there a way to use 'space' as a hotkey without affecting hotstrings?

22 Nov 2017, 13:20

this is a script i mainly use to turn the mButton into a modifier. mButton is the scroll button on thinkpad keyboards but im trying to make it work with the spacebar so i can use these hotkeys when im using other computers that have regular keyboards.
(script example: hold down the space bar and press the ijkl keys to move the cursor around instead of having to reach for the arrow keys)

the problem im having is that the hotstrings in my main script stop working once mim.ahk (this script, (middle modifier) is loaded or reloaded.
ive sort of worked around this by reloading my main script at the end of mim's auto-execute section which makes the hotstrings work as expected

the problem then is that once any of mim's hotkeys are used, if i try to use a hotstring it wont work the first time, but the second time and every time after that it will work.
(so the hotstrings work as long as space is pressed once after using any of mim's hotkeys)


if anyone has a solution to either or both of these problems i would be grateful.

Code: Select all

#noEnv
#singleInstance force
sendMode input

hotkey, mButton,    mButton_down
hotkey, mButton up, mButton_up

loop, parse, % "abcdefghijklmnopqrstuvwxyz0123456789"
    hotkey, ~*%a_loopfield%, prior_hotkey
hotkey, $space,   space_down
hotkey, space up, space_up

; run, %a_ahkPath% "C:\path_to_script_with_hostrings.ahk" /restart

return ; end of auto-execute ------------





mButton_down:
mim := true
return

mButton_up:
mim := false
send {mButton up}{ctrl up}{shift up}{alt up}    ; in case keys are stuck
return



space_down:
if (a_priorHotkey) and (a_timeSincePriorHotkey < 150)
     send {space}    ; (if typing fast and space is used)
else
    {
    mim := true
    keyWait, space
    }
return

space_up:
if (mim = true) and (a_priorHotkey = "$space") and (a_timeSincePriorHotkey < 400)
    send {space}
mim := false ; reset
send {space up}{ctrl up}{shift up}{alt up}
return

prior_hotkey:
return





#if mim

j::      send {left}      ; move caret
k::      send {down}
i::      send {up}
l::      send {right}

+j::     send +{left}     ; select text
+k::     send +{down}
+i::     send +{up}
+l::     send +{right}

^j::     send ^{left}     ; move to start of word
^l::     send ^{right}
^+j::    send ^+{left}    ; select to start of word
^+l::    send ^+{right}

u::      send {home}             ; move to start of line
o::      send {end}
+u::     send +{home}            ; select to start of line
+o::     send +{end}
!u::     send +{home}{backspace} ; delete to start of line
!o::     send +{end}{delete}

enter::  send {end}{enter}       ; new line after
+enter:: send {home}{enter}{up}  ; new line before

n::      send {backspace}
m::      send {delete}

,::      send {esc}
.::      send {enter}
8::      send {esc}
9::      send {enter}

*b::     send {alt down}{tab}    ; alt tab
*+b::    send {alt down}+{tab}   ; alt tab reverse

6::      send ^#{left}           ; previous virtual desktop
7::      send ^#{right}          ; next virtual desktop

#if

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 216 guests