{"id":135949,"date":"2020-07-21T17:27:38","date_gmt":"2020-07-21T09:27:38","guid":{"rendered":"http:\/\/4563.org\/?p=135949"},"modified":"2020-07-21T17:27:38","modified_gmt":"2020-07-21T09:27:38","slug":"%e6%b1%82%e5%8a%a9-python-%e7%9b%91%e5%90%ac%e5%a4%a7%e5%86%99%e9%94%81%e5%ae%9a%e9%94%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=135949","title":{"rendered":"\u6c42\u52a9 Python \u76d1\u542c\u5927\u5199\u9501\u5b9a\u952e"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u52a9 Python \u76d1\u542c\u5927\u5199\u9501\u5b9a\u952e               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JackalZhao <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u9700\u6c42\uff1a<\/p>\n<p>\u6301\u7eed\u76d1\u542c\u5927\u5199\u9501\u5b9a\u952e\uff0c\u5f53\u6309\u4e0b\u540e\uff0c\u4fdd\u6301\u6309\u4e0b\u72b6\u6001\u8d85\u8fc7 0.5 \u79d2\u65f6\uff0c\u7acb\u5373 print(&#8216;\u8d85\u8fc7 0.5 \u79d2&#8217;)<\/p>\n<p>\uff08\u4e00\u65e6\u5728\u6301\u7eed 0.5 \u79d2\u4e4b\u524d\u677e\u5f00\u4e86\uff0c\u90a3\u5c31\u5565\u90fd\u4e0d\u505a\uff09<\/p>\n<p>\u5f53\u6309\u4e0b\u8d85\u8fc7 0.5 \u79d2\u540e\uff0c\u677e\u5f00\u8fd9\u4e2a\u6309\u952e\u65f6\uff0cprint(&#8216;\u677e\u5f00\u4e86&#8217;)\u3002<\/p>\n<p>\u5c3d\u53ef\u80fd\u7b80\u6d01\u3001\u5360\u7528\u8d44\u6e90\u5c3d\u53ef\u80fd\u5c11\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2423885\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : singerll <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5148\u62a5\u4ef7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423886\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : loading <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             caps lck \u952e\u6709\u6309\u4e0b\u91ca\u653e\u4e8b\u4ef6\u5417\uff1f\u5bb9\u6211\u6709\u7a7a\u7684\u65f6\u5019\u53bb\u770b\u770b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423887\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : manning <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             keyboard hook windows api                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423888\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hakono <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e0d\u662f Python \u7f16\u7a0b\u77e5\u8bc6\uff0c\u800c\u662f win32 \u5f00\u53d1\u77e5\u8bc6\uff0c\u8bf7\u7528 c \u6216 c++\u6765\u5199<br \/>\u8fd9\u91cc\u6d89\u53ca\u5230 Windows \u7684\u5168\u5c40 hook \u76f8\u5173\u7684 api \u4ee5\u53ca Windows \u7684\u6d88\u606f\u4e8b\u4ef6<br \/>\u8fd9\u4e2a\u57fa\u7840\u9700\u8981\u53bb\u5b66\u4e00\u4e0b\u7684<br \/>https:\/\/zhuanlan.zhihu.com\/p\/31962703<br \/>\u4ee5\u53ca\uff0c\u5168\u5c40 hook \u5fc5\u987b\u9700\u8981\u4f60\u7f16\u8bd1\u4e00\u4e2a dll \u7528\u6765\u6ce8\u5165\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u8ba9\u4f60\u7528 c \u6216 c++\u6765\u5199\uff0c\u4e86\u89e3\u4e4b\u540e\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\u975e\u5e38\u7b80\u5355\u51e0\u5341\u884c\u4ee3\u7801\u5c31\u884c\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423889\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rming <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u63a8\u8350 2 \u4e2a\u5e93 pynput keyboard                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423890\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tabris17 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528\u5e95\u5c42\u952e\u76d8\u6d88\u606f\u94a9\u5b50\u5c31\u53ef\u4ee5\u4e86<\/p>\n<p>\u7ed9 LZ \u4e24\u4e2a\u5173\u952e\u8bcd<br \/>SetWindowsHookEx<br \/>\u548c<br \/>WH_KEYBOARD_LL<\/p>\n<p>\u81ea\u5df1\u641c\u53bb\u5427                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423891\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JackalZhao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 keyboard \u548c thread \u89e3\u51b3\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423892\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mutalisk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             pyhook                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423893\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ysc3839 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hakono \u201c\u5168\u5c40 hook \u5fc5\u987b\u9700\u8981\u4f60\u7f16\u8bd1\u4e00\u4e2a dll \u7528\u6765\u6ce8\u5165\u201d\u662f\u9519\u7684\u3002\u6bd4\u5982 WH_KEYBOARD_LL \u548c WH_MOUSE_LL \u662f\u5168\u5c40\u7684\u4f46\u4e0d\u9700\u8981\uff0c\u5fae\u8f6f\u6587\u6863\u91cc\u6709\u5199\uff1a<br \/>https:\/\/docs.microsoft.com\/en-us\/previous-versions\/windows\/desktop\/legacy\/ms644985(v=vs.85)<br \/>However, the WH_KEYBOARD_LL hook is not injected into another process. Instead, the context switches back to the process that installed the hook and it is called in its original context.<\/p>\n<p>The Old New Thing \u91cc\u9762\u4e5f\u6709\u4e00\u7bc7\u6587\u7ae0\u63d0\u5230\u4e86\u8fd9\u4e2a\uff1a<br \/>https:\/\/devblogs.microsoft.com\/oldnewthing\/20050425-41\/?p=35803<br \/>The WH_KEYBOARD_LL and WH_MOUSE_LL hooks are exceptions to this rule. These two are non-injecting hooks, as explained in their respective documentation pages. Rather, the hook function is called in its original thread context.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2423894\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hakono <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ysc3839 \u539f\u6765\u5982\u6b64\uff0c\u8fd9\u4e24\u662f\u4f8b\u5916\u554a\u3002\u4e00\u76f4\u90fd\u662f\u641e\u4e2a dll \u5199\u7684\u3002\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u52a9 Python \u76d1\u542c\u5927\u5199\u9501\u5b9a\u952e&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/135949"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=135949"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/135949\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=135949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=135949"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=135949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}