{"id":1063,"date":"2026-02-06T16:49:36","date_gmt":"2026-02-06T07:49:36","guid":{"rendered":"https:\/\/tamura.jp\/?p=1063"},"modified":"2026-02-06T20:24:15","modified_gmt":"2026-02-06T11:24:15","slug":"1063","status":"publish","type":"post","link":"https:\/\/tamura.jp\/?p=1063","title":{"rendered":"PowerShell"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># 1. \u51fa\u529b\u306e\u6587\u5b57\u5316\u3051\u5bfe\u7b56\n$OutputEncoding = &#91;System.Text.Encoding]::UTF8\n&#91;Console]::OutputEncoding = &#91;System.Text.Encoding]::UTF8\n\nAdd-Type -AssemblyName Microsoft.VisualBasic\n$wsh = New-Object -ComObject WScript.Shell\n\n$endTime = \"23:00\"\n\nWrite-Host \"--- Monitoring Started (Target: $endTime) ---\"\n\nwhile($true) {\n    if ((Get-Date -Format \"HH:mm\") -ge $endTime) {\n        Write-Host \"Time reached. Exiting...\"\n        break\n    }\n\n    # \u3010\u91cd\u8981\u3011\u65e5\u672c\u8a9e\u3092\u76f4\u63a5\u66f8\u304b\u305a\u3001\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u3067\u5224\u5b9a (\u6587\u5b57\u5316\u3051\u5bfe\u7b56)\n    # \u300c\u30a2\u30a4\u30c9\u30eb\u300d\u3068\u3044\u3046\u6587\u5b57\u304c\u542b\u307e\u308c\u308b\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u63a2\u3059\n    $target = Get-Process | Where-Object { $_.MainWindowTitle -like \"*\u30a2\u30a4\u30c9\u30eb*\" } -ErrorAction SilentlyContinue\n    \n    if ($target) {\n        $now = Get-Date -Format \"HH:mm:ss\"\n        Write-Host \"$now : Dialog detected. Sending Enter...\"\n        try {\n            &#91;Microsoft.VisualBasic.Interaction]::AppActivate($target.Id)\n            Start-Sleep -Milliseconds 500\n            $wsh.SendKeys('~') # Enter\u30ad\u30fc\n        } catch {\n            # \u65e2\u306b\u9589\u3058\u3066\u3044\u308b\u5834\u5408\u306f\u7121\u8996\n        }\n    }\n\n    # \u30a2\u30a4\u30c9\u30eb\u9632\u6b62 (ScrollLock)\n    $wsh.SendKeys('{SCROLLLOCK}')\n    \n    # 10\u79d2\u5f85\u6a5f\n    Start-Sleep -Seconds 10\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1063","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tamura.jp\/index.php?rest_route=\/wp\/v2\/posts\/1063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tamura.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tamura.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tamura.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tamura.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1063"}],"version-history":[{"count":6,"href":"https:\/\/tamura.jp\/index.php?rest_route=\/wp\/v2\/posts\/1063\/revisions"}],"predecessor-version":[{"id":1067,"href":"https:\/\/tamura.jp\/index.php?rest_route=\/wp\/v2\/posts\/1063\/revisions\/1067"}],"wp:attachment":[{"href":"https:\/\/tamura.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tamura.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tamura.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}