{"id":29856,"date":"2024-01-01T15:38:05","date_gmt":"2024-01-01T10:08:05","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=29856"},"modified":"2024-01-01T15:40:41","modified_gmt":"2024-01-01T10:10:41","slug":"pydirectinput","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/pydirectinput\/","title":{"rendered":"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation"},"content":{"rendered":"\n<p>Pypi provides us with a library to automate keyboard and mouse prompts. It&#8217;s pydirectinput. Earlier, users used to work with the PyAutoGUI library, but now we have a better alternative in the form of pydirectinput. Let us learn more about this library. <\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#More_about_pydirectinput\" >More about pydirectinput<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#The_syntax\" >The syntax<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#Examples\" >Examples<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#pydirectinput-rgx_210\" >pydirectinput-rgx 2.1.0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#Does_pydirectinput_work_on_Mac\" >Does pydirectinput work on Mac?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#How_to_read_keyboard_input_with_pydirectinput\" >How to read keyboard input with pydirectinput?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#Creating_scripts_with_pydirectinput\" >Creating scripts with pydirectinput<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#PyDirectInput_to_simulate_keyboard_shortcuts\" >PyDirectInput to simulate keyboard shortcuts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#pydirectinput_not_working_in_game\" >pydirectinput not working in game<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#pydirectinput_right_click\" >pydirectinput right click<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#pydirectinput_hold\" >pydirectinput hold<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#pydirectinput_moveto\" >pydirectinput moveto<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#Pydirectinput_vs_PyAutoGUI_vs_Pynput_vs_AutoHotkey\" >Pydirectinput vs. PyAutoGUI vs. Pynput vs AutoHotkey<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#FAQs\" >FAQs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#Trending_Python_Articles\" >Trending Python Articles<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-more-about-pydirectinput\"><span class=\"ez-toc-section\" id=\"More_about_pydirectinput\"><\/span>More about pydirectinput<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This library works on Win32 API functions, specifically the SendInput() function, and is more compatible with software as compared to pydirectinput. It also provides you with the tools to play games, for software testing, etc.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-syntax\"><span class=\"ez-toc-section\" id=\"The_syntax\"><\/span>The syntax <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us now see how we can install this library. Use the pip command that is mentioned below either in the command prompt or terminal.  Once you have installed it, you need to import it in order to use its functions.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\npip install pydirectinput\nimport pydirectinput\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-examples\"><span class=\"ez-toc-section\" id=\"Examples\"><\/span>Examples <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There can be several types of input events. Some examples are given in the code block. You can use these to press the B key or release the A key. Also, there&#8217;s a functionality to move the cursor to given coordinates. In the third line of code, the curse will shift to 100,100 coordinates. The click() function allows a user to click the left mouse button. There are many other functions that work for the ease of a user. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\npydirectinput.keyDown(&quot;b&quot;)\npydirectinput.keyUp(&quot;a&quot;)\npydirectinput.moveTo(100, 100)\npydirectinput.click()\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pydirectinput-rgx-2-1-0\"><span class=\"ez-toc-section\" id=\"pydirectinput-rgx_210\"><\/span>pydirectinput-rgx 2.1.0 <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This is an extension or a fork of the pydirectinput library. It has a few improvements like-<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Support for <a href=\"http:\/\/www.pythonpool.com\/remove-unicode-characters-python\/\" target=\"_blank\" rel=\"noopener\">Unicode characters<\/a><\/li>\n\n\n\n<li>Support for keyboard shortcuts<\/li>\n\n\n\n<li>Support for multiple keyboards<\/li>\n\n\n\n<li>More precise control over function behavior<\/li>\n<\/ul>\n\n\n\n<p>It is more advanced and has less bugs. If you want basic features, you can keep using the pydirectinput library only. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-does-pydirectinput-work-on-mac\"><span class=\"ez-toc-section\" id=\"Does_pydirectinput_work_on_Mac\"><\/span>Does pydirectinput work on Mac?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This library is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_Windows\" target=\"_blank\" rel=\"noreferrer noopener\">Windows<\/a>-based. Therefore,  it does not work on Mac. For Mac users, there is an alternative: pynput and keyboard libraries. pynput library works on generating keyboard listeners. The following code depicts how you can use the keyboard library.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport keyboard\n\n# Wait for a key to be pressed\nkey = keyboard.read_key()\n\n# Print the pressed key\nprint(f&quot;Pressed: {key}&quot;)\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-read-keyboard-input-with-pydirectinput\"><span class=\"ez-toc-section\" id=\"How_to_read_keyboard_input_with_pydirectinput\"><\/span>How to read keyboard input with pydirectinput?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The pydirectinput library doesn&#8217;t have a well-defined function that works solely for this purpose. However, you can use three functions for the same:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>keyDown()<\/li>\n\n\n\n<li>keyUp()<\/li>\n\n\n\n<li>waitKey()<\/li>\n<\/ul>\n\n\n\n<p> These functions help you with key presses. You should notice the return value while using the keyDown() function. If you obtain the answer as TRUE, it means that you pressed that particular key else you didn&#8217;t. Use the keyUp() function to release the key press. Now, you can check the given code to see how pydirectinput works with keyboard input using the keyUp() and keyDown() functions. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\n\n# Wait for a key to be pressed\nkey = pydirectinput.keyDown()\n\n# Print the pressed key\nprint(f&quot;Pressed: {key}&quot;)\n\n# Wait for the key to be released\npydirectinput.keyUp(key)\n<\/pre><\/div>\n\n\n<p>The <a href=\"http:\/\/www.pythonpool.com\/python-next\/\" target=\"_blank\" rel=\"noopener\">next function<\/a> that you may consider for this purpose is the waitKey() function. In this case, if you press the key, you will get the key code. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\n\n# Wait for a key to be pressed\nkey_code = pydirectinput.waitKey()\n\n# Print the key code of the pressed key\nprint(f&quot;Key code: {key_code}&quot;)\n<\/pre><\/div>\n\n\n<p>There is another way through which you can access the <a href=\"http:\/\/www.pythonpool.com\/python-user-input\/\" target=\"_blank\" rel=\"noopener\">keyboard inputs<\/a> through the waitKey() function. You may check for several keys by putting this function in a loop. Consider the example given below.  It basically uses a loop and checks the key code to note if a key has been pressed or not. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\n\n# Create a list to store the pressed keys\npressed_keys = &#x5B;]\n\n# Start a loop to listen for key presses\nwhile True:\n\n    # Wait for a key to be pressed\n    key_code = pydirectinput.waitKey()\n\n    # If the key code is not equal to `-1`, then the key is pressed\n    if key_code != -1:\n\n        # Add the pressed key to the list\n        pressed_keys.append(key_code)\n\n    # If the key code is equal to `-1`, then the loop is broken\n    else:\n        break\n\n# Print the pressed keys\nprint(f&quot;Pressed keys: {pressed_keys}&quot;)\n<\/pre><\/div>\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-foxtrot monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-creating-scripts-with-pydirectinput\"><span class=\"ez-toc-section\" id=\"Creating_scripts_with_pydirectinput\"><\/span>Creating scripts with pydirectinput <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can create Python scripts using the pydirectinput library too. In order to create the script, you should follow these steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Importing pydirectinput library <\/li>\n\n\n\n<li>Defining script code<\/li>\n\n\n\n<li>Using pydirectinput&#8217;s functions to get keyboard input<\/li>\n\n\n\n<li>Save the script as .py file<\/li>\n\n\n\n<li>Run this .py file.<\/li>\n<\/ul>\n\n\n\n<p>The following code demonstrates how you can create a Python script. The loop works for 10 iterations. It presses A ten times. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\n\n# Define a function to press the &quot;A&quot; key\ndef press_a():\n    pydirectinput.keyDown(&quot;a&quot;)\n    pydirectinput.keyUp(&quot;a&quot;)\n\n# Press the &quot;A&quot; key 10 times\nfor i in range(10):\n    press_a()\n\n# Save the script as a Python file\nwith open(&quot;example.py&quot;, &quot;w&quot;) as f:\n    f.write(code)\n\n# Run the script\nimport example\nexample.press_a()\n<\/pre><\/div>\n\n\n<p>Similarly, you can use other functions like keyDown(), keyUp(), moveTo(), click(), scroll() and type().<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pydirectinput-to-simulate-keyboard-shortcuts\"><span class=\"ez-toc-section\" id=\"PyDirectInput_to_simulate_keyboard_shortcuts\"><\/span>PyDirectInput to simulate keyboard shortcuts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can represent keyboard shortcuts with the aid of this library also. For this purpose, you can use the keyDown() function. The following example illustrates how you can create the Ctrl+C keyboard shortcut and stimulate it.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\npydirectinput.keyDown(&quot;ctrl&quot;)\npydirectinput.keyDown(&quot;c&quot;)\npydirectinput.keyUp(&quot;ctrl&quot;)\npydirectinput.keyUp(&quot;c&quot;)\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pydirectinput-not-working-in-game\"><span class=\"ez-toc-section\" id=\"pydirectinput_not_working_in_game\"><\/span>pydirectinput not working in game<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Certain games consist of anti-automation measures. These can block pydirectinput. Also, your game may be running as an administrator. You should use the <code>pydirectinput.keyDown()<\/code>&nbsp;and&nbsp;<code>pydirectinput.keyUp()<\/code>&nbsp;functions in place of <code>pydirectinput.press()<\/code>&nbsp;function. If the issue persists, you can switch to the <strong>pyautogui<\/strong> library. Also, you may use<strong>&nbsp;AutoHotkey<\/strong> to record your script and then run it with this library. Updating the library will also help. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pydirectinput-right-click\"><span class=\"ez-toc-section\" id=\"pydirectinput_right_click\"><\/span>pydirectinput right click<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There is no predefined function for right-clicking in the pydirectinput library. You can try this with the <code>click(button='right')<\/code> function. However, this may not work for all game applications. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\n\n# Move the mouse to the desired location\npydirectinput.moveTo(x, y)\n\n# Perform the right-click\npydirectinput.click(button='right')\n<\/pre><\/div>\n\n\n<p>The other method involves combining the<strong> <code>keyDown<\/code> and <code>keyUp<\/code><\/strong> functions provided by pydirectinput. Through this code, you can press and release the right mouse button.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\n\n# Move the mouse to the desired location\npydirectinput.moveTo(x, y)\n\n# Press and release the right mouse button\npydirectinput.keyDown('right')\npydirectinput.keyUp('right')\n<\/pre><\/div>\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-golf monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Popular now<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><span class=\"monsterinsights-inline-popular-posts-border-2\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\">[Fixed] nameerror: name Unicode is not defined<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pydirectinput-hold\"><span class=\"ez-toc-section\" id=\"pydirectinput_hold\"><\/span>pydirectinput hold<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This library doesn&#8217;t offer an exact hold function in order to hold a key. Still, you can achieve this using <code>keyDown<\/code> a function with an infinite loop. This will press and release the key after putting it to sleep() for a specified time.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\nimport time\n\n# Define the key to hold\nkey_to_hold = 'w'\n\n# Move the mouse to the desired location (optional)\n# pydirectinput.moveTo(x, y)\n\n# Hold the key indefinitely\nwhile True:\n    pydirectinput.keyDown(key_to_hold)\n    time.sleep(0.1)  # Adjust delay based on desired hold duration\n    pydirectinput.keyUp(key_to_hold)\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pydirectinput-moveto\"><span class=\"ez-toc-section\" id=\"pydirectinput_moveto\"><\/span>pydirectinput moveto<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The <code class=\"\">moveTo<\/code> function of the <code class=\"\">pydirectinput<\/code> library helps to move the mouse cursor to a location on the screen. It has two mandatory and two optional parameters. These are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>x_coordinate:<\/strong>&nbsp;It refers to the horizontal coordinate (X-axis) of your desired location.<\/li>\n\n\n\n<li><strong>y_coordinate:<\/strong>&nbsp;It is the vertical coordinate (Y-axis) of your desired location.<\/li>\n\n\n\n<li><strong>duration (<strong>Optional<\/strong>):<\/strong>&nbsp;It refers to the time taken to move the cursor to the target location. The&nbsp;default value is 0.<\/li>\n\n\n\n<li><b>_pause <\/b><strong style=\"font-weight: bold;\">(<strong>Optional<\/strong><\/strong><strong>):&nbsp;<\/strong>It is used to suggest whether you need to pause after movement.&nbsp;Its default value is True.<\/li>\n<\/ul>\n\n\n\n<p>The following example illustrates this. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pydirectinput\n\n# Define the target coordinates\nx_coordinate = 100\ny_coordinate = 200\n\n# Move the mouse cursor to the target coordinates\npydirectinput.moveTo(x_coordinate, y_coordinate)\n<\/pre><\/div>\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-alpha monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\">[Solved] runtimeerror: cuda error: invalid device ordinal<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pydirectinput-vs-pyautogui-vs-pynput-vs-autohotkey\"><span class=\"ez-toc-section\" id=\"Pydirectinput_vs_PyAutoGUI_vs_Pynput_vs_AutoHotkey\"><\/span><div>Pydirectinput vs. PyAutoGUI vs. Pynput vs AutoHotkey <\/div><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now, let us see how pydirectinput is different from <a href=\"http:\/\/www.pythonpool.com\/python-auto-clicker\/\" target=\"_blank\" rel=\"noreferrer noopener\">PyAutoGUI<\/a>, Pynput, and AutoHotkey. The table given below sets these libraries apart from each other on various factors like Platform, Speed, Efficiency, Features, Documentation, and Ease of use. <\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>PyDirectInput<\/th><th>PyAutoGUI<\/th><th>Pynput<\/th><th>AutoHotkey<\/th><\/tr><\/thead><tbody><tr><td><strong>Platform<\/strong><\/td><td>Windows<\/td><td>Cross-platform<\/td><td>Cross-platform<\/td><td>Windows<\/td><\/tr><tr><td><strong>Speed<\/strong><\/td><td>Fast<\/td><td>Medium<\/td><td>Medium<\/td><td>Medium<\/td><\/tr><tr><td><strong>Efficiency<\/strong><\/td><td>Efficient<\/td><td>Medium<\/td><td>Medium<\/td><td>Medium<\/td><\/tr><tr><td><strong>Features<\/strong><\/td><td>Keyboard and mouse input<\/td><td>Keyboard and mouse input, image recognition, screen capture<\/td><td>Keyboard and mouse input, joystick, and controller input<\/td><td>Keyboard, mouse, joystick, and controller input, scripting language<\/td><\/tr><tr><td><strong>Documentation<\/strong><\/td><td>Good<\/td><td>Good<\/td><td>Good<\/td><td>Good<\/td><\/tr><tr><td><strong>Ease of use<\/strong><\/td><td>Easy<\/td><td>Easy<\/td><td>Medium<\/td><td>Difficult<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faqs\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1699362653450\"><strong class=\"schema-faq-question\"><strong>Is PyDirectInput only available for Windows?<\/strong><\/strong> <p class=\"schema-faq-answer\">Yes. It works on Windows only. <\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1699549638983\"><strong class=\"schema-faq-question\"><strong>Can I use PyDirectInput to play games?<\/strong><\/strong> <p class=\"schema-faq-answer\">Yes, you can. However, some games may not support this library. <\/p> <\/div> <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>By now, you must know the basics of the pydirectinput library. This article also covers the syntax of pydirectinput along with its usage on Windows. It draws differences among some Python libraries, which are similar to pydirectinput.<\/p>\n\n\n<div class=\"monsterinsights-widget-popular-posts monsterinsights-widget-popular-posts-delta monsterinsights-popular-posts-styled monsterinsights-widget-popular-posts-columns-2\"><h2 class=\"monsterinsights-widget-popular-posts-widget-title\"><span class=\"ez-toc-section\" id=\"Trending_Python_Articles\"><\/span>Trending Python Articles<span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"monsterinsights-widget-popular-posts-list\"><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 11, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] nameerror: name Unicode is not defined<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal.webp 1200w \" alt=\"[Solved] runtimeerror: cuda error: invalid device ordinal\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Solved] runtimeerror: cuda error: invalid device ordinal<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method.webp 1200w \" alt=\"[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><\/ul><\/div><p><\/p>","protected":false},"excerpt":{"rendered":"<p>Pypi provides us with a library to automate keyboard and mouse prompts. It&#8217;s pydirectinput. Earlier, users used to work with the PyAutoGUI library, but now &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/#more-29856\" aria-label=\"More on Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation\">Read more<\/a><\/p>\n","protected":false},"author":38,"featured_media":31606,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4345],"tags":[],"class_list":["post-29856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-module","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation - Python Pool<\/title>\n<meta name=\"description\" content=\"Pypi provides us with a library to automate keyboard and mouse prompts. It&#039;s pydirectinput. Let us learn more about this.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/pydirectinput\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation\" \/>\n<meta property=\"og:description\" content=\"Pypi provides us with a library to automate keyboard and mouse prompts. It&#039;s pydirectinput. Earlier, users used to work with the PyAutoGUI library, but\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/pydirectinput\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-01T10:08:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-01T10:10:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Namrata Gulati\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Namrata Gulati\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/\"},\"author\":{\"name\":\"Namrata Gulati\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6\"},\"headline\":\"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation\",\"datePublished\":\"2024-01-01T10:08:05+00:00\",\"dateModified\":\"2024-01-01T10:10:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/\"},\"wordCount\":1064,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp\",\"articleSection\":[\"Module\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/pydirectinput\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/\",\"url\":\"https:\/\/www.pythonpool.com\/pydirectinput\/\",\"name\":\"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp\",\"datePublished\":\"2024-01-01T10:08:05+00:00\",\"dateModified\":\"2024-01-01T10:10:41+00:00\",\"description\":\"Pypi provides us with a library to automate keyboard and mouse prompts. It's pydirectinput. Let us learn more about this.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699362653450\"},{\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699549638983\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/pydirectinput\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp\",\"width\":1200,\"height\":628,\"caption\":\"pydirectinput\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6\",\"name\":\"Namrata Gulati\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g\",\"caption\":\"Namrata Gulati\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699362653450\",\"position\":1,\"url\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699362653450\",\"name\":\"Is PyDirectInput only available for Windows?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes. It works on Windows only. \",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699549638983\",\"position\":2,\"url\":\"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699549638983\",\"name\":\"Can I use PyDirectInput to play games?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes, you can. However, some games may not support this library. \",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation - Python Pool","description":"Pypi provides us with a library to automate keyboard and mouse prompts. It's pydirectinput. Let us learn more about this.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pythonpool.com\/pydirectinput\/","og_locale":"en_US","og_type":"article","og_title":"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation","og_description":"Pypi provides us with a library to automate keyboard and mouse prompts. It's pydirectinput. Earlier, users used to work with the PyAutoGUI library, but","og_url":"https:\/\/www.pythonpool.com\/pydirectinput\/","og_site_name":"Python Pool","article_published_time":"2024-01-01T10:08:05+00:00","article_modified_time":"2024-01-01T10:10:41+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp","type":"image\/webp"}],"author":"Namrata Gulati","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Namrata Gulati","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/"},"author":{"name":"Namrata Gulati","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6"},"headline":"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation","datePublished":"2024-01-01T10:08:05+00:00","dateModified":"2024-01-01T10:10:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/"},"wordCount":1064,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp","articleSection":["Module"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/pydirectinput\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/","url":"https:\/\/www.pythonpool.com\/pydirectinput\/","name":"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp","datePublished":"2024-01-01T10:08:05+00:00","dateModified":"2024-01-01T10:10:41+00:00","description":"Pypi provides us with a library to automate keyboard and mouse prompts. It's pydirectinput. Let us learn more about this.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699362653450"},{"@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699549638983"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/pydirectinput\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/pydirectinput.webp","width":1200,"height":628,"caption":"pydirectinput"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Mastering PyDirectInput: Streamlined Keyboard &amp; Mouse Automation"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6","name":"Namrata Gulati","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g","caption":"Namrata Gulati"}},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699362653450","position":1,"url":"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699362653450","name":"Is PyDirectInput only available for Windows?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Yes. It works on Windows only. ","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699549638983","position":2,"url":"https:\/\/www.pythonpool.com\/pydirectinput\/#faq-question-1699549638983","name":"Can I use PyDirectInput to play games?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Yes, you can. However, some games may not support this library. ","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/29856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=29856"}],"version-history":[{"count":97,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/29856\/revisions"}],"predecessor-version":[{"id":31611,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/29856\/revisions\/31611"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/31606"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=29856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=29856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=29856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}