Skip to content

Instantly share code, notes, and snippets.



Last active Dec 14, 2019
What would you like to do?
;; SandS for AutoHotkey
;; ===初期設定==========================================================
;; 多重起動の制御をforceに指定
#SingleInstance force
;; 環境変数を無視する
;; キーボードフックを有効にする
;; タスクトレイアイコンを表示しない (コメントアウト)
;; #Notrayicon
;; SendModeをInputに指定
SendMode Input
;; Inputでキャッチするキーのリスト
EndKeys := "{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}"
EndKeys .= "{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}"
EndKeys .= "{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}"
EndKeys .= "{BS}{Capslock}{Numlock}{PrintScreen}{Pause}"
;; ===Space Down========================================================
;; SpaceDownホットキーの実行可能スレッド数を2にする
#MaxThreadsPerHotkey 2
;; SpaceDown時の動作
;; Spaceキーの状態が既にOnの時はSpaceキーを送信 (キーリピート用)
if SandS_KeyState
Send, {Space}
SandS_AnyKeyDown := True
;; Spaceキーの状態判定をOnにする
SandS_KeyState := True
;; キー入力判定を初期化
SandS_AnyKeyDown := False
;; 1打目の入力を拾うまで待機
Input, SandS_InputKey, L1, %EndKeys%
;; 何も押さずにSpaceキーを上げた場合は終了
if (ErrorLevel == "NewInput")
;; クリティカル開始
;; ShiftキーDown
Send, {LShift Down}
;; 入力されたキー、特殊キーを送信する
if SandS_InputKey
Send, %SandS_InputKey%
else ifInString, ErrorLevel, Endkey:
;; EndKeysでキャッチしたキーを送信
SandS_InputKey := substr(ErrorLevel, 8)
Send, {%SandS_InputKey% Down}
;; キー入力判定をOnにする
SandS_AnyKeyDown := True
;; クリティカル終了
Critical, Off
;; ===Space Up==========================================================
;; SpaceUpホットキーの実行可能スレッド数を1にする
#MaxThreadsPerHotkey 1
;; Space Up時の動作
Space Up::
;; Inputの待機を終了させる
;; キー先行入力対策 一時的に入力を保持する
Input, SandS_InputTemp, T0.002, %EndKeys%
;; キー入力がない場合はスペースを送信
if !SandS_AnyKeyDown
Send, {Space}
;; Spaceキーの状態判定をOffにする
SandS_KeyState := False
;; ShiftキーUp
Send, {LShift Up}
;; 保持したキーデータを送信
if SandS_InputTemp
Send, %SandS_InputTemp%
else ifInString, ErrorLevel, Endkey:
SandS_InputTemp := substr(ErrorLevel, 8)
Send, {%SandS_InputTemp% Down}
;; ===Backslash-Underline置換===========================================
;; Inputで取得したsc073とsc07Dの区別がつかないため
;; {sc073}('\')を+{sc073}('_')に置き換える
;; {LShift}はSpaceと同時に押された時にInputに食わせるためのダミー
sc073:: SendEvent, {LShift Down}_{LShift Up}

This comment has been minimized.

Copy link

@savorocks savorocks commented Jun 24, 2016

Cool script, really useful. There is one small thing that I would like to change, but I don't know how. Perhaps You can help me, I would be very thankful.

When I press & hold the space bar (now acting as a shift key) after about one second (maybe it's less?) it switches to behave like normal space bar again. I want to increase that time so that, for example, when i press & hold the space bar (so that it acts as shift) it won't switch to behaving like normal space bar for another 5-6 seconds. I hope that I explained what I need clear enough.

Can You help me find that line of code where I can change that 'switch time' between shift & space when no other key is pressed with it?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.