age_sage

ホットキーすり抜け再現スクリプト(要管理者権限)

Apr 26th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Text := "
  2. (
  3. ■ホットキーすり抜け再現スクリプト■
  4. === すり抜け条件 ===
  5. ・修飾キーを入力(ホットキー、Send)
  6. ・高速で過剰な入力(ホイール回転など)
  7. ・PC負荷が掛かっている状態
  8.  
  9. === テスト用ホットキー ===
  10. Shift + ホイール上回転 → u (すり抜け:大文字)
  11. Shift + ホイール下回転 → d
  12. Shift + z → x
  13. Ctrl + ホイール下回転 → a (すり抜け:すべて選択)
  14.  
  15. === ホットキーすり抜け対策 ===
  16. [BlockInput Send] ※管理者権限が必要、ただし高負荷時では完全には防げない
  17.  
  18. ↓大文字+1文字でログを表示↓
  19. )"
  20.  
  21. ; === 負荷設定(多重起動)、問題が再現しない場合は増やす ===
  22. ; Startup = 0
  23. ; Startup = 1
  24. Startup = 50
  25. ; Startup = 100
  26. ; Startup = 200
  27.  
  28. #NoEnv
  29. #NoTrayIcon
  30. #SingleInstance Off
  31. #KeyHistory 500 ; Default 40
  32. #MaxHotkeysPerInterval 400 ; 70
  33. #InstallKeybdHook
  34. #InstallMouseHook
  35. SetBatchLines -1 ; 10
  36.  
  37. if !A_Args.Length() { ; メインスクリプトのみ
  38.     OnExit ExitSub
  39.     Menu, Tray, Icon
  40.     Loop %Startup% {
  41.         Run %A_ScriptFullPath% %A_Index%,,, Pid
  42.         GroupAdd, TestGroup, ahk_pid %Pid%
  43.     }
  44.     Gui, New, +AlwaysOnTop +HwndGuiHwnd
  45.     Gui, Add, Text,, %Text%
  46.     Gui, Add, Edit, w450 r10 gErrorCheck
  47.     Gui, Add, Button, w150 gBlockButton, BlockInput Send
  48.     Gui Show
  49.     KeyHistory
  50. }
  51. return
  52.  
  53. ErrorCheck: ; エラー時にログを表示
  54. GuiControlGet, Text,, Edit1
  55. if (Text ~= "^.*[A-Z].$") { ; 大文字+1文字
  56.     BlockInput On ; 過剰な入力を抑制
  57.     KeyHistory
  58.     ControlSend,, ^{End}, ahk_id %A_ScriptHwnd%
  59.     BlockInput Off
  60. }
  61. return
  62.  
  63. BlockButton:
  64. BlockInput % (BlockMode:=!BlockMode) ? "Send" : "Default" ; Send中の過剰な入力を抑制
  65. GuiControl,, Button1, % "BlockInput " (BlockMode ? "Default" : "Send")
  66. GuiControl,, Edit1
  67. GuiControl, Focus, Edit1
  68. return
  69.  
  70. ExitSub:
  71. DetectHiddenWindows On
  72. WinKill ahk_group TestGroup ; 多重起動も全終了
  73. GuiEscape:
  74. GuiClose:
  75. ExitApp
  76.  
  77. #If !A_Args.Length() && WinActive("ahk_id" GuiHwnd) ; メインスクリプト & テスト用GUIのみ
  78. +WheelUp::SendInput u
  79. +WheelDown::SendInput d
  80. +z::SendInput x
  81. ^WheelDown::SendInput a
  82. #If
Add Comment
Please, Sign In to add comment