{"id":118,"date":"2022-03-19T22:00:41","date_gmt":"2022-03-19T13:00:41","guid":{"rendered":"http:\/\/192.168.0.16:3005\/?p=118"},"modified":"2022-03-19T22:04:06","modified_gmt":"2022-03-19T13:04:06","slug":"%e5%ad%90%e4%be%9b%e3%81%ae%e3%83%95%e3%82%a9%e3%83%bc%e3%83%88%e3%83%8a%e3%82%a4%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e7%9a%84%e3%81%ab%e8%90%bd%e3%81%a8%e3%81%99python%e3%82%b9%e3%82%af%e3%83%aa","status":"publish","type":"post","link":"https:\/\/blog.solong.jp\/?p=118","title":{"rendered":"\u5b50\u4f9b\u306e\u30d5\u30a9\u30fc\u30c8\u30ca\u30a4\u30c8\u3092\u81ea\u52d5\u7684\u306b\u843d\u3068\u3059python\u30b9\u30af\u30ea\u30d7\u30c8(PC)"},"content":{"rendered":"\n<p>\u5b50\u4f9b\u304cPC\u3067\u30d5\u30a9\u30fc\u30c8\u30ca\u30a4\u30c8\u306e\u6642\u9593\u3092\u5b88\u3089\u306a\u304b\u3063\u305f\u308a\u3001\u3084\u3081\u306a\u3055\u3044\u3068\u8a00\u3063\u3066\u3082\u306a\u304b\u306a\u304b\u805e\u304b\u306a\u304b\u3063\u305f\u308a\u3057\u3066\u3001\u59bb\u306e\u30a4\u30e9\u30a4\u30e9\u3001\u5b50\u4f9b\u3082\u30a4\u30e9\u30a4\u30e9\u3001\u3042\u307e\u308a\u826f\u304f\u306a\u3044\u72b6\u614b\u3060\u3063\u305f\u306e\u3067\u3001\u3082\u3046\u89aa\u5b50\u3067\u3042\u308c\u3053\u308c\u8a00\u3044\u5408\u308f\u306a\u304f\u3066\u3044\u3044\u3088\u3046\u306b\u4e00\u5b9a\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3057\u305f\u3089\u30d5\u30a9\u30fc\u30c8\u30ca\u30a4\u30c8\u304c\u5f37\u5236\u7684\u306b\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u898b\u305f\u3002<\/p>\n\n\n\n<p>\u65b9\u6cd5\u306f\u8272\u3005\u3042\u308b\u3068\u601d\u3046\u3051\u3069\u3001python\u3092\u9078\u3093\u3060\u3002<\/p>\n\n\n\n<p>Windows\u4e0a\u3067python\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u5b9f\u884c\u3057\u3001Fortnite\u3092\u8d77\u52d5\u3057\u305f\u77ac\u9593\u306b\u30d7\u30ed\u30bb\u30b9\u76e3\u8996\u3067\u958b\u59cb\u3057\u305f\u3053\u3068\u3092\u691c\u77e5\u3057\u305f\u308a\u3001\u81ea\u5206\u3067\u30b2\u30fc\u30e0\u3092\u3084\u3081\u305f\u3053\u3068\u3082\u691c\u77e5\u3059\u308b\u3002\u304b\u3064\u3001\u4e00\u5b9a\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u30921\u5206\u306b1\u56de\u5224\u5b9a\u3057\u3066\u3001\u5834\u5408\u306b\u3088\u3063\u3066\u306fFortnite\u3092\u5f37\u5236\u7d42\u4e86\u3055\u305b\u308b\u3002\u81ea\u5206\u3067\u3082\u8a66\u3057\u3066\u307f\u305f\u3051\u3069\u3001\u307b\u3093\u3068\u306b\u4e00\u77ac\u3067\u30a2\u30d7\u30ea\u304c\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3055\u308c\u3066\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u623b\u3055\u308c\u308b\u3002<\/p>\n\n\n\n<p>\u4f5c\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u4ee5\u4e0b\u3002\u9069\u5f53\u306a\u540d\u524d.py\u3067\u4fdd\u5b58<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import sys\nimport time\nimport wmi\nimport win32serviceutil\nimport logging\nimport psutil\nfrom plyer import notification\n\nlogging.basicConfig(\n    filename = 'C:\\\\Users\\\\xxxxxxxxx\\\\xxxxxx\\\\gamemonitorscript.log',\n    level = logging.DEBUG, \n    format=\"%(asctime)s:LINE&#91;%(lineno)s] %(levelname)s %(message)s\"\n)\n\nclass GameMonitorService(win32serviceutil.ServiceFramework):\n    _svc_name_ = 'FNMoniter'\n    _svc_display_name_ = 'Monitor Game'\n    _svc_description_ = 'Saving over playing'\n\n    def SvcDoRun(self):\n        self.run = True\n        \n        loopcount = 0\n        c=wmi.WMI()\n        cre_process_watcher=c.Win32_Process.watch_for(\"creation\")\n        del_process_watcher=c.Win32_Process.watch_for(\"deletion\")\n\n       \n        while self.run:\n            new_cre_process=cre_process_watcher()\n            new_del_process=del_process_watcher()\n            \n            if(\"FortniteClient\" in new_cre_process.Caption):\n                # \u3053\u3053\u3067\u3001\u304a\u3001\u30b2\u30fc\u30e0\u3084\u308a\u59cb\u3081\u305f\u306a\u3068\u3044\u3046\u3068\u304d\u306e\u51e6\u7406\n\n            if(\"FortniteClient\" in new_del_process.Caption):\n                # \u3053\u3053\u3067\u3001\u30b2\u30fc\u30e0\u3092\u3084\u3081\u305f\u3068\u3068\u304d\u306e\u51e6\u7406\n                    \n            time.sleep(1)\n            loopcount += 1\n            \n            if loopcount == 60:\n                \n                # \u3044\u3044\u52a0\u6e1b\u306b\u3057\u306a\u3055\u3044\u3001\u30b2\u30fc\u30e0\u5f37\u5236\u7d42\u4e86\u3067\u3059\u3088\u3001\u3068\u3044\u3046\u5224\u5b9a\u3092\u3059\u308b\n                if &lt;&lt;&lt;\u4f55\u304b\u3057\u3089\u306e\u3084\u308a\u3059\u304e\u5224\u5b9a&gt;&gt;&gt;:\n                    logging.debug('\u5f37\u5236\u7d42\u4e86')\n                    for proc in psutil.process_iter():\n                        n = proc.name()\n                        if \"FortniteClient\" in n:\n                            p = psutil.Process(proc.pid)\n                            proc.kill()\n\n                loopcount = 0\n                \n    def SvcStop(self):\n        self.run = False\n\nif __name__ == '__main__':\n    win32serviceutil.HandleCommandLine(SampleService)\n<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3092\u7ba1\u7406\u8005\u30e6\u30fc\u30b6\u3067\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002\u5f53\u7136\u3001python\u306f\u4e8b\u524d\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001pip\u3067pywin32\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3051\u3069\u3001\u305d\u306e\u8fba\u306f\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u898b\u3066\u53c2\u8003\u306b\u3055\u305b\u3066\u3044\u305f\u3060\u3044\u305f\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/qiita.com\/Bashi50\/items\/1d98f80ccaa8746bff38\">https:\/\/qiita.com\/Bashi50\/items\/1d98f80ccaa8746bff38<\/a><\/p>\n\n\n\n<p>\u6b63\u76f4\u3001WMI\u3068\u304b\u306a\u3093\u3068\u304b\u3001\u4f7f\u3044\u65b9\u304c\u3042\u3093\u307e\u308a\u826f\u304f\u308f\u304b\u3063\u3066\u306a\u304f\u3066\u3001\u9069\u5f53\u306b\u3084\u3063\u3066\u3066\u3053\u308c\u3067\u52d5\u3044\u305f\u304b\u3089\u3001\u307e\u3042\u3044\u3044\u304b\u3001\u3068\u3044\u3046\u611f\u3058\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b50\u4f9b\u304cPC\u3067\u30d5\u30a9\u30fc\u30c8\u30ca\u30a4\u30c8\u306e\u6642\u9593\u3092\u5b88\u3089\u306a\u304b\u3063\u305f\u308a\u3001\u3084\u3081\u306a\u3055\u3044\u3068\u8a00\u3063\u3066\u3082\u306a\u304b\u306a\u304b\u805e\u304b\u306a\u304b\u3063\u305f\u308a\u3057\u3066\u3001\u59bb\u306e\u30a4\u30e9\u30a4\u30e9\u3001\u5b50\u4f9b\u3082\u30a4\u30e9\u30a4\u30e9\u3001\u3042\u307e\u308a\u826f\u304f\u306a\u3044\u72b6\u614b\u3060\u3063\u305f\u306e\u3067\u3001\u3082\u3046\u89aa\u5b50\u3067\u3042\u308c\u3053\u308c\u8a00\u3044\u5408\u308f\u306a\u304f\u3066\u3044\u3044\u3088\u3046\u306b\u4e00\u5b9a\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3057\u305f\u3089\u30d5\u30a9\u30fc\u30c8\u30ca\u30a4\u30c8\u304c\u5f37\u5236\u7684\u306b\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u898b\u305f\u3002 \u65b9\u6cd5\u306f\u8272\u3005\u3042\u308b\u3068\u601d\u3046\u3051\u3069\u3001python\u3092\u9078\u3093\u3060\u3002 Windows\u4e0a\u3067python\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u5b9f\u884c\u3057\u3001Fortnite\u3092\u8d77\u52d5\u3057\u305f\u77ac\u9593\u306b\u30d7\u30ed\u30bb\u30b9\u76e3\u8996\u3067\u958b\u59cb\u3057\u305f\u3053\u3068\u3092\u691c\u77e5\u3057\u305f\u308a\u3001\u81ea\u5206\u3067\u30b2\u30fc\u30e0\u3092\u3084\u3081\u305f\u3053\u3068\u3082\u691c\u77e5\u3059\u308b\u3002\u304b\u3064\u3001\u4e00\u5b9a\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u30921\u5206\u306b1\u56de\u5224\u5b9a\u3057\u3066\u3001\u5834\u5408\u306b\u3088\u3063\u3066\u306fFortnite\u3092\u5f37\u5236\u7d42\u4e86\u3055\u305b\u308b\u3002\u81ea\u5206\u3067\u3082\u8a66\u3057\u3066\u307f\u305f\u3051\u3069\u3001\u307b\u3093\u3068\u306b\u4e00\u77ac\u3067\u30a2\u30d7\u30ea\u304c\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3055\u308c\u3066\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u623b\u3055\u308c\u308b\u3002 \u4f5c\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u4ee5\u4e0b\u3002\u9069\u5f53\u306a\u540d\u524d.py\u3067\u4fdd\u5b58 \u3053\u308c\u3092\u7ba1\u7406\u8005\u30e6\u30fc\u30b6\u3067\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002\u5f53\u7136\u3001python\u306f\u4e8b\u524d\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001pip\u3067pywin32\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3051\u3069\u3001\u305d\u306e\u8fba\u306f\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u898b\u3066\u53c2\u8003\u306b\u3055\u305b\u3066\u3044\u305f\u3060\u3044\u305f\u3002 https:\/\/qiita.com\/Bashi50\/items\/1d98f80ccaa8746bff38 \u6b63\u76f4\u3001WMI\u3068\u304b\u306a\u3093\u3068\u304b\u3001\u4f7f\u3044\u65b9\u304c\u3042\u3093\u307e\u308a\u826f\u304f\u308f\u304b\u3063\u3066\u306a\u304f\u3066\u3001\u9069\u5f53\u306b\u3084\u3063\u3066\u3066\u3053\u308c\u3067\u52d5\u3044\u305f\u304b\u3089\u3001\u307e\u3042\u3044\u3044\u304b\u3001\u3068\u3044\u3046\u611f\u3058\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/blog.solong.jp\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.solong.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.solong.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.solong.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.solong.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":2,"href":"https:\/\/blog.solong.jp\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/blog.solong.jp\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/blog.solong.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.solong.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.solong.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}