{ "info": { "author": "Zuzu_Typ", "author_email": "zuzu.typ@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: zlib/libpng License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Topic :: Games/Entertainment", "Topic :: Software Development :: Libraries" ], "description": "# winput \n## Capture and send keyboard and mouse input on Windows \n**winput** is a small **extension** that gives you the ability to **capture** and **send** any **keyboard and mouse input**\\. \nIt does this by providing a **simple interface** to **user32\\.dll** \n \n## Tiny documentation \n### About winput \n**winput must not be used to record the user's input without their consent\\!** \n**winput** is supposed to **replace** the outdated extension [PyHook](https://pypi.org/project/pyHook/)\\. \n \n### Using winput \nTo install winput you can use the [PyPI](https://packaging.python.org/tutorials/installing-packages/): \n\n pip install winput\n \nTo use winput in a script, you have to import the package `winput` using \n\n import winput\n \nor a wildcard import: \n\n from winput import *\n \n \n \n#### Capturing mouse input \nThere are two ways you can get input from the mouse\\. \n1\\. You can get the current position of the mouse cursor using \n\n get_mouse_pos() -> (x, y)\n \n \n2\\. You can hook onto the Windows message system to receive an Event every time \nthe state of the mouse changes: \n\n hook_mouse( callback_function )\n \nThe function will be supplied with a **MouseEvent** as it's only argument\\. \n\n class MouseEvent:\n position # [length-2-tuple] the screen coordinates at which the event occured\n action # [int] which type of event occured - can be any of the mouse-wParams (see below)\n time # [int] time in ms since system startup\n additional_data # [int] information for specific mouse events (which X-Button, amount of mouse-wheel-movement)\n type # [string] = \"MouseEvent\"\n \nYou **have to run a message loop** to use a hook\\! \\(see **\\[Running a message loop\\]** below\\) \n \nRemember to unhook when you're done capturing by using: \n\n unhook_mouse()\n \n \nThe following mouse\\-wParams exist: \n\n \n WM_MOUSEMOVE = 0x0200 # the mouse has been moved\n \n WM_LBUTTONDOWN = 0x0201 # left mouse button pressed\n WM_LBTTONUP = 0x0202 # left mouse button released\n \n WM_RBUTTONDOWN = 0x0204 # right mouse button pressed\n WM_RBUTTONUP = 0x0205 # right mouse button released\n \n WM_MBUTTONDOWN = 0x0207 # middle mouse button pressed\n WM_MBUTTONUP = 0x0208 # middle mouse button released\n \n WM_MOUSEWHEEL = 0x020A # mouse wheel moved\n WM_MOUSEHWHEEL = 0x020E # mouse wheel moved (horizontal)\n \n WM_XBUTTONDOWN = 0x020B # extra button pressed\n WM_XBUTTONUP = 0x020C # extra button released\n \n \n \n \n#### Capturing keyboard input \nIf you want to monitor keyboard input you also have to hook onto the Windows message system\\. \n\n hook_keyboard( callback_function )\n \nThe function will be supplied with a **KeyboardEvent** as it's only argument\\. \n\n class KeyboardEvent:\n action # [int] which type of event occured - can be any of the keyboard-wParams\n vkCode # [int] virtual key code -- which key has been pressed\n time # [int] time in ms since system startup\n type # [string] = \"KeyboardEvent\"\n \nYou **have to run a message loop** to use a hook\\! \\(see *Running a message loop* below\\) \n \nAgain, remember to unhook when you're done capturing by using: \n\n unhook_keyboard()\n \n \nThe following keyboard\\-wParams exist: \n\n \n WM_KEYDOWN = 0x0100 # key pressed\n WM_KEYUP = 0x0101 # key released\n \n WM_SYSKEYDOWN = 0x0104 # system-key pressed\n WM_SYSKEYUP = 0x0105 # system-key released\n \n \n \n \n#### Running a message loop \nIf you're using a hook, you have to keep updating the Windows messages\\. \nYou can either do this by using \n\n wait_messages()\n \nto enter an infinite message loop, which you can stop by calling \n\n stop()\n \n \nOr you can have your own loop that repeatedly \\(at least 100x per second\\) calls \n\n get_message()\n \n \n \n#### Virtual Key Codes \\(VK codes\\) \nVirtual key codes or vk\\_codes are numerical representations of given keys\\. \nTo get a list of all virtual key codes, take a look over [here](https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes)\\. \nAll VK codes are members of the main `winput` module and the submodule `winput.vk_codes`\\. \nIf you want to import all the VK codes without performing a package\\-wide wildcard import, you can use \n\n from winput.vk_codes import *\n \n \nYou can also convert the virtual key codes to a literal representation using a predefined dict\\. \n\n vk_code_dict.get(vk_code, \"VK_UNKNOWN\") -> string\n \n \n \n#### Sending mouse input \nTo set the position of the mouse cursor, you can use \n\n set_mouse_pos(x, y)\n \n \nTo make sure this also works with high DPI values, please use the DPI awareness functions below\\. \n \nTo move the mouse cursor by a given amount, you can use \n\n move_mouse(dx, dy)\n \n \nA mouse button can be pressed using \n\n press_mouse_button(mouse_button)\n \nand released using \n\n release_mouse_button(mouse_button)\n \nor pressed and released using \n\n click_mouse_button(mouse_button)\n \n \nThe following mouse buttons exist: \n\n \n LEFT_MOUSE_BUTTON = LMB = 1\n RIGHT_MOUSE_BUTTON = RMB = 2\n MIDDLE_MOUSE_BUTTON = MMB = 4\n EXTRA_MOUSE_BUTTON1 = XMB1 = 8\n EXTRA_MOUSE_BUTTON2 = XMB2 = 16\n \n \nThe mousewheel can be moved using \n`move_mousewheel(amount[, horizontal = False])` \n \n#### Sending keyboard input \nTo press a key, you can use \n\n press_key(vk_code)\n \nto release it, you can use \n\n release_key(vk_code)\n \nand to press and release it, you can use \n\n click_key(vk_code)\n \n \n \n#### DPI awareness \nTo make the process running winput DPI aware, use the following function: \n\n set_DPI_aware(per_monitor=True)\n \n \nTo get the DPI scaling factor for a given window handle \\(HWND\\), use \n\n get_window_scaling_factor(hwnd)\n \n \n### Example \n#### Capturing the mouse and keyboard \n\n \n import winput\n \n def mouse_callback( event ):\n if event.action == winput.WM_LBUTTONDOWN:\n print(\"Left mouse button press at {}\".format( event.position ))\n \n def keyboard_callback( event ):\n if event.vkCode == winput.VK_ESCAPE: # quit on pressing escape\n winput.stop()\n \n print(\"Press escape to quit\")\n \n # hook input \n winput.hook_mouse( mouse_callback )\n winput.hook_keyboard( keyboard_callback )\n \n # enter message loop\n winput.wait_messages()\n \n # remove input hook\n winput.unhook_mouse()\n winput.unhook_keyboard()\n \n \n#### Sending input \n\n \n import winput\n from winput.vk_codes import *\n \n import time\n \n def slow_click(vk_code): # delay each keypress by 1/10 of a second\n time.sleep(0.1)\n winput.click_key(vk_code)\n \n # open the RUN menu (WIN + R)\n winput.press_key(VK_LWIN)\n winput.click_key(VK_R)\n winput.release_key(VK_LWIN)\n \n time.sleep(0.5)\n \n # enter \"notepad.exe\"\n slow_click(VK_N)\n slow_click(VK_O)\n slow_click(VK_T)\n slow_click(VK_E)\n slow_click(VK_P)\n slow_click(VK_A)\n slow_click(VK_D)\n slow_click(VK_OEM_PERIOD)\n slow_click(VK_E)\n slow_click(VK_X)\n slow_click(VK_E)\n slow_click(VK_RETURN)\n \n time.sleep(1)\n \n # enter \"hello world\"\n slow_click(VK_H)\n slow_click(VK_E)\n slow_click(VK_L)\n slow_click(VK_L)\n slow_click(VK_O)\n slow_click(VK_SPACE)\n slow_click(VK_W)\n slow_click(VK_O)\n slow_click(VK_R)\n slow_click(VK_L)\n slow_click(VK_D)\n \n \n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Zuzu-Typ/winput", "keywords": "record send input cursor mouse keyboard keys hook hooks pyhook windows user32.dll user32", "license": "zlib/libpng license", "maintainer": "", "maintainer_email": "", "name": "winput", "package_url": "https://pypi.org/project/winput/", "platform": null, "project_url": "https://pypi.org/project/winput/", "project_urls": { "Homepage": "https://github.com/Zuzu-Typ/winput" }, "release_url": "https://pypi.org/project/winput/1.4.0/", "requires_dist": null, "requires_python": "", "summary": "Capture and send keyboard and mouse input", "version": "1.4.0", "yanked": false, "yanked_reason": null }, "last_serial": 13187221, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "6b40b499aa954baf9e7653748f724923", "sha256": "60a6f6e23083da8844321d77da0ca87957ddb01e516f3e85640921868c11dd58" }, "downloads": -1, "filename": "winput-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6b40b499aa954baf9e7653748f724923", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7641, "upload_time": "2019-07-28T19:12:04", "upload_time_iso_8601": "2019-07-28T19:12:04.160696Z", "url": "https://files.pythonhosted.org/packages/86/d8/b82d20a4943f69c7dc5519fe0e6b1250d1c909b51933c235c3dde4a50aca/winput-1.0.0-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "40fac0d36836b7bbd5459aeaeb3b4efa", "sha256": "a0a4948600bbfe5e4351fa45bf81dc41f910c1f38fd968d0093ca00e02684229" }, "downloads": -1, "filename": "winput-1.0.0.tar.gz", "has_sig": false, "md5_digest": "40fac0d36836b7bbd5459aeaeb3b4efa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8263, "upload_time": "2019-07-28T19:12:06", "upload_time_iso_8601": "2019-07-28T19:12:06.868253Z", "url": "https://files.pythonhosted.org/packages/61/4d/c46cbf0c8b925022ab394a04f424d3529c914a3b31764a99442a8cc31937/winput-1.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "cb6db868db049a6ca342b37168b63104", "sha256": "1dbe2cc8587482c80f3a2b68e662c0d341318604560394042c99cf8c81da775e" }, "downloads": -1, "filename": "winput-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cb6db868db049a6ca342b37168b63104", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9885, "upload_time": "2019-08-27T17:23:58", "upload_time_iso_8601": "2019-08-27T17:23:58.755094Z", "url": "https://files.pythonhosted.org/packages/3f/b2/b842ca9a91948b707cdf3f729f288a5a2fc767b5553b42d12030c80c4f1d/winput-1.1.0-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "30ddb84a50af64c7f60bd541312e328c", "sha256": "7c8c6a436a6f97571b4df14c879a010a33ae5ac534768ce048e47c5b4e852970" }, "downloads": -1, "filename": "winput-1.1.0.tar.gz", "has_sig": false, "md5_digest": "30ddb84a50af64c7f60bd541312e328c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12051, "upload_time": "2019-08-27T17:24:00", "upload_time_iso_8601": "2019-08-27T17:24:00.354261Z", "url": "https://files.pythonhosted.org/packages/3e/b0/4ee9108538b90d2a1a907cfcadb7fdc1a58139f441af6d242431bd275d07/winput-1.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "f8df6dcf14fecfd7d7138fc12a5feea8", "sha256": "0e4431ecec1c2c0f704246558762d710e806383104efb7cfe93cef0cf33d3fcb" }, "downloads": -1, "filename": "winput-1.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f8df6dcf14fecfd7d7138fc12a5feea8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9416, "upload_time": "2019-08-28T07:45:25", "upload_time_iso_8601": "2019-08-28T07:45:25.677714Z", "url": "https://files.pythonhosted.org/packages/0d/ea/259bd99fc35e3bad5a6ff7bb6d8dfaa289a3284a01720d27284304b2da7d/winput-1.2.0-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3f6f8b4b9683d6ca02330b921a51cf45", "sha256": "bcf021bad6b7cd44de47c31a3420b28468ca4649c302aa15a3b2ddad808cc234" }, "downloads": -1, "filename": "winput-1.2.0.tar.gz", "has_sig": false, "md5_digest": "3f6f8b4b9683d6ca02330b921a51cf45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12740, "upload_time": "2019-08-28T07:45:27", "upload_time_iso_8601": "2019-08-28T07:45:27.321269Z", "url": "https://files.pythonhosted.org/packages/0a/d0/cdcb297af3e6802c165ab9dce92498aac48073a11d424c585f3cceea2ac9/winput-1.2.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "e31e913bd7072dac5930480f97c392cf", "sha256": "bb386ff73fd4c2c3d71aea2125c34e85bc170c1d6c7a3a4c5afe54adc5eca43e" }, "downloads": -1, "filename": "winput-1.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e31e913bd7072dac5930480f97c392cf", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9990, "upload_time": "2019-10-22T18:51:54", "upload_time_iso_8601": "2019-10-22T18:51:54.852371Z", "url": "https://files.pythonhosted.org/packages/72/d4/ffd3696f0acac0292daeeb82b23ab8eb4146b3d0232ec7b4a7c40e19dea8/winput-1.2.1-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "9adfa104357700cf5babf5e1cb0d6180", "sha256": "681b9ee2124a89457e2aa707e014d0d0b12f58d927a572ac81762ed31ba194f4" }, "downloads": -1, "filename": "winput-1.2.1.tar.gz", "has_sig": false, "md5_digest": "9adfa104357700cf5babf5e1cb0d6180", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13665, "upload_time": "2019-10-22T18:31:26", "upload_time_iso_8601": "2019-10-22T18:31:26.754268Z", "url": "https://files.pythonhosted.org/packages/2f/1a/0396b161f15253e178d1fa14c884bfe3bbefa67579ab68c5104c3958a8bd/winput-1.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "f462b03c5f7713de6422ba968f3acc1c", "sha256": "5cbc44b1fa18ed2922aaf9559e0f1ce67d768e49a560a70dbd3a43e110d25156" }, "downloads": -1, "filename": "winput-1.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f462b03c5f7713de6422ba968f3acc1c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10025, "upload_time": "2020-08-28T13:30:07", "upload_time_iso_8601": "2020-08-28T13:30:07.664442Z", "url": "https://files.pythonhosted.org/packages/ac/2a/480045e0a2fc1c7e897a6cf6529d371043e88c36565776244e178c499ac6/winput-1.2.2-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "9fa867cbf75ab0efe87dba000cfc6bc2", "sha256": "6fe8041559139702dfd37eae5063e1d48e2636f0cf58d60c1e69a5e61cba4459" }, "downloads": -1, "filename": "winput-1.2.2.tar.gz", "has_sig": false, "md5_digest": "9fa867cbf75ab0efe87dba000cfc6bc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13752, "upload_time": "2020-08-28T13:30:09", "upload_time_iso_8601": "2020-08-28T13:30:09.036854Z", "url": "https://files.pythonhosted.org/packages/6d/fd/5bcaa13d8097f507eace91d9c545954d25b4a1fe47bd069af88e60341977/winput-1.2.2.tar.gz", "yanked": false, "yanked_reason": null } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "095c9fe3c3e7c513df83896f2d41f258", "sha256": "655fddd1d5bffc2da50da833de2460a9bf0adec9ce08d30513d3497dee53bdf3" }, "downloads": -1, "filename": "winput-1.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "095c9fe3c3e7c513df83896f2d41f258", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10075, "upload_time": "2022-03-11T09:11:24", "upload_time_iso_8601": "2022-03-11T09:11:24.795271Z", "url": "https://files.pythonhosted.org/packages/7e/93/ea7eeaa991496a66ebc17bbcf5bc27f0cc97ef14a4c21827941dc7c5759c/winput-1.3.0-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "674c60e2fe0b937342192bff16711b75", "sha256": "c407b15c66d166e230989ad5a44028588e178465d9d6221e040ab6d9b02194aa" }, "downloads": -1, "filename": "winput-1.3.0.tar.gz", "has_sig": false, "md5_digest": "674c60e2fe0b937342192bff16711b75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13085, "upload_time": "2022-03-11T09:11:27", "upload_time_iso_8601": "2022-03-11T09:11:27.030555Z", "url": "https://files.pythonhosted.org/packages/34/71/6d9ce824ea789062e33662efd6c9206706759aad553584cb0e11cf619c52/winput-1.3.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "a9789b597b92a17b254089fdb687485d", "sha256": "d82c70bc7306f676555273d03201bb3b073cbbf331482284d840874d220cbf1e" }, "downloads": -1, "filename": "winput-1.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a9789b597b92a17b254089fdb687485d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10696, "upload_time": "2022-03-15T22:14:23", "upload_time_iso_8601": "2022-03-15T22:14:23.892413Z", "url": "https://files.pythonhosted.org/packages/86/2d/0de229ee800b62ff8c706c286527a762e38bd577b1b1ad029520f1f10051/winput-1.4.0-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "21089ca123a8f1a6ca238b8bd4a25d9d", "sha256": "8b4635e89e56fb52ca5511132d5cc8580bef945b5a3c00d49ce3bfe9f7c70f22" }, "downloads": -1, "filename": "winput-1.4.0.tar.gz", "has_sig": false, "md5_digest": "21089ca123a8f1a6ca238b8bd4a25d9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13970, "upload_time": "2022-03-15T22:14:25", "upload_time_iso_8601": "2022-03-15T22:14:25.183184Z", "url": "https://files.pythonhosted.org/packages/f8/9b/62b950183c7c3c00addb59548a949b85fb31344ed071c18453f085791672/winput-1.4.0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a9789b597b92a17b254089fdb687485d", "sha256": "d82c70bc7306f676555273d03201bb3b073cbbf331482284d840874d220cbf1e" }, "downloads": -1, "filename": "winput-1.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a9789b597b92a17b254089fdb687485d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10696, "upload_time": "2022-03-15T22:14:23", "upload_time_iso_8601": "2022-03-15T22:14:23.892413Z", "url": "https://files.pythonhosted.org/packages/86/2d/0de229ee800b62ff8c706c286527a762e38bd577b1b1ad029520f1f10051/winput-1.4.0-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "21089ca123a8f1a6ca238b8bd4a25d9d", "sha256": "8b4635e89e56fb52ca5511132d5cc8580bef945b5a3c00d49ce3bfe9f7c70f22" }, "downloads": -1, "filename": "winput-1.4.0.tar.gz", "has_sig": false, "md5_digest": "21089ca123a8f1a6ca238b8bd4a25d9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13970, "upload_time": "2022-03-15T22:14:25", "upload_time_iso_8601": "2022-03-15T22:14:25.183184Z", "url": "https://files.pythonhosted.org/packages/f8/9b/62b950183c7c3c00addb59548a949b85fb31344ed071c18453f085791672/winput-1.4.0.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }