Skip to content

Instantly share code, notes, and snippets.

@ten9miq
Last active January 8, 2026 14:00
Show Gist options
  • Select an option

  • Save ten9miq/7418b982a62e7511446f258769ceb976 to your computer and use it in GitHub Desktop.

Select an option

Save ten9miq/7418b982a62e7511446f258769ceb976 to your computer and use it in GitHub Desktop.
#NoEnv
SendMode Input
#IfWinActive ahk_class CabinetWClass
^+t::Explorer_NewText_FocusedNew()
^+f::Send ^+n
#IfWinActive
#IfWinActive ahk_class ExploreWClass
^+t::Explorer_NewText_FocusedNew()
^+f::Send ^+n
#IfWinActive
Explorer_NewText_FocusedNew() {
Send, {F10}
Sleep, 80
; 「新規作成」を開く
Send, {Enter}
Sleep, 120
; 末尾へ → 少し上へ(大抵「テキスト ドキュメント」付近に来る)
Send, {Up 1}
Sleep, 30
Send, {Up 1}
Sleep, 30
Send, {Enter}
}
; RCtrl2連打でカーソルを現在のモニタの画面中央に移動
; Alt+F1でモード切替
; カーソルが存在するモニターの中央へ移動する
; 切替時のカーソルが存在するモニターの中央へ全モニターから移動する
#NoEnv
#Persistent
#InstallKeybdHook
SetBatchLines, -1
; DPI 仮想化オフ & 物理ピクセル座標をそのまま使用
DllCall("SetProcessDPIAware")
CoordMode, Mouse, Screen
; ダブルタップ閾値(ミリ秒)
doubleTapThreshold := 400
;=== 設定ファイルのパス & 起動時に読み込み ===
iniFile := A_ScriptDir "\RCtrl2連打でモニター中央に移動.ini"
IniRead, FixedMonitor, %iniFile%, Settings, FixedMonitor, 0
FixedMonitor := FixedMonitor + 0 ; 数値化
;=== Alt+F1 でモード切り替え ===
!F1::
; マウス位置取得
MouseGetPos, mx, my
SysGet, totalMon, MonitorCount
; 現在いるモニター番号を判定
currentMon := 0
, % totalMon {
SysGet, mon, Monitor, %A_Index%
if (mx >= monLeft && mx <= monRight && my >= monTop && my <= monBottom) {
currentMon := A_Index
break
}
}
; モード切替:動的→固定、固定→動的
if (FixedMonitor = 0) {
FixedMonitor := currentMon
} else {
FixedMonitor := 0
}
; 設定ファイルに保存
IniWrite, %FixedMonitor%, %iniFile%, Settings, FixedMonitor
; ツールチップ表示
modeText := FixedMonitor
? "カーソル中央モニター " FixedMonitor " 固定"
: "動的移動"
ToolTip % "モード:" modeText
SetTimer, _RemoveTip, -1000
return
;=== 右Ctrl ダブルタップでカーソル移動 ===
~SC11D::
if (A_PriorHotkey = A_ThisHotkey
&& A_TimeSincePriorHotkey < doubleTapThreshold)
{
MouseGetPos, mx, my
SysGet, totalMon, MonitorCount
dest := FixedMonitor
if (dest = 0) {
; 動的モード:現在のモニターを再判定
, % totalMon {
SysGet, mon, Monitor, %A_Index%
if (mx >= monLeft && mx <= monRight && my >= monTop && my <= monBottom) {
dest := A_Index
break
}
}
}
; 中央へ移動
if (dest >= 1 && dest <= totalMon) {
SysGet, mon, Monitor, %dest%
cx := (monLeft + monRight)//2
cy := (monTop + monBottom)//2
MouseMove, %cx%, %cy%, 0
}
}
return
;=== ツールチップを消すタイマー ===
_RemoveTip:
ToolTip
return
#NoEnv
#Persistent
#InstallKeybdHook
SetBatchLines, -1
; ① DPI 仮想化をオフにして物理ピクセル座標をそのまま使う
DllCall("SetProcessDPIAware")
; ② マウスはスクリーン(物理ピクセル)基準
CoordMode, Mouse, Screen
; 2度押し判定の閾値 (ミリ秒)
doubleTapThreshold := 400
; 右Ctrl (scancode 11D) を物理押下のみでフック
$SC11D::
if (A_PriorHotkey = A_ThisHotkey
&& A_TimeSincePriorHotkey < doubleTapThreshold)
{
; カーソル現在位置
MouseGetPos, mx, my
; モニター数取得
SysGet, totalMon, MonitorCount
, %totalMon%
{
idx := A_Index
; ←ここで一度に左上/右下を取得
SysGet, mon, Monitor, %idx%
l := monLeft
t := monTop
r := monRight
b := monBottom
if (mx >= l && mx <= r && my >= t && my <= b)
{
cx := (l + r)//2
cy := (t + b)//2
; (デバッグ用)移動先を確認
; ToolTip, % "Mon#: " idx "`n"
; . "Bounds: " l "," t " - " r "," b "`n"
; . "Center: " cx "," cy
; SetTimer, _RemoveTip, -600
MouseMove, %cx%, %cy%, 0
Break
}
}
}
Return
_RemoveTip:
ToolTip
Return
#NoEnv
#Persistent
SetBatchLines, -1
check_interval_ms := 60000 ; 監視間隔:60秒
idle_threshold_ms := 300000 ; アイドル判定:5分
send_interval_ms := 180000 ; Ctrl送信間隔:3分(ここを好みで変更)
is_sending := false
SetTimer, CheckIdle, %check_interval_ms%
return
CheckIdle:
; 物理操作があったら送信停止
if (A_TimeIdlePhysical < idle_threshold_ms) {
if (is_sending) {
SetTimer, SendCtrl, Off
is_sending := false
}
return
}
; 5分以上アイドルなら送信開始
if (!is_sending) {
SetTimer, SendCtrl, %send_interval_ms%
is_sending := true
}
return
SendCtrl:
; 念のため、送信直前にも再チェック
if (A_TimeIdlePhysical < idle_threshold_ms) {
SetTimer, SendCtrl, Off
is_sending := false
return
}
Send, {Ctrl}
return
@ten9miq
Copy link
Author

ten9miq commented Jan 7, 2026

日本語混じりのものはUTF-8 with BOMで保存すること

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment