LoginSignup
4
2

More than 1 year has passed since last update.

LoLを起動したらAutoHotkeyを終了するPowerShellスクリプト

Last updated at Posted at 2023-02-04

概要

AutoHotkey (alt-ime-ahk) を起動したまま League of Legends をプレイすると、不正スクリプト扱いとなるようで、約10分経過後に強制切断されます。
また、切断後はPCを再起動してもそのマッチには復帰できなくなります。
この犯罪を複数回犯し、LeaverBuster1 ペナルティ を受けたので、反省と謝罪を兼ねて常駐スクリプトを作成しました。

本体

$autoHotkeyProcessName = "alt-ime-ahk" の部分は使っている AutoHotkey ソフトのプロセス名に変更してください。
保存の際のエンコードはBOM付きUTF-8でお願いします。

ahk_killer.ps1
$interval = 30 # 秒
$autoHotkeyProcessName = "alt-ime-ahk" # 適宜変更
$leagueClientProcessName = "LeagueClient"

while ($True) {
    $autoHotkeyProcess = Get-Process -Name $autoHotkeyProcessName -ErrorAction SilentlyContinue
    $leagueClientProcess = Get-Process -Name $leagueClientProcessName -ErrorAction SilentlyContinue

    if($autoHotkeyProcess -And $leagueClientProcess){
        # 停止処理
        Stop-Process -Name $autoHotkeyProcessName

        # 通知表示
        $headlineText = 'AutoHotkey Killer'
        $bodyText = 'LeagueClientの起動を確認したため、AutoHotkeyを終了しました。'

        $ToastText02 = [Windows.UI.Notifications.ToastTemplateType, Windows.UI.Notifications, ContentType = WindowsRuntime]::ToastText02
        $TemplateContent = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]::GetTemplateContent($ToastText02)
        $TemplateContent.SelectSingleNode('//text[@id="1"]').InnerText = $headlineText
        $TemplateContent.SelectSingleNode('//text[@id="2"]').InnerText = $bodyText
        $AppId = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
        [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Show($TemplateContent)
    }
    Start-Sleep $interval
}

確認

右クリック > PowerShell で実行 で起動します。

image.png
LeagueClientAutoHotkey を同時起動している状態で、AutoHotkey の終了が確認できたら、動作確認は完了です。

スタートアップ化

image.png
image.png
ショートカットを作成して、プロパティ>リンク先をpowershell -WindowStyle Hidden -command <上記スクリプトのファイル>になるように変更します。

image.png
Win+Rからshell:startupを入力してOK、作成したショートカットを開いたディレクトリに移動してください。

参考記事

  1. LoLの切断行為への処罰のこと。切断を繰り返すとゲームのマッチング時間が制限される。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2