PyAutoGUI Click on Item that could be on any monitorFinding the index of an item given a list containing it in PythonHow to randomly select an item from a list?Is there any way to kill a Thread?How to remove items from a list while iterating?How can I count the occurrences of a list item?pyautogui crashes whenever it clicksInstalling Pygame through Pycharm or System TerminalMouse not clicking during GUI automation with pythonWhy pyautogui click not actually clickingCould not import backend 'Glfw'

Are devices supposed to automatically be removed from iCloud when all content and settings are erased?

Creating specific options in `Manipulate[]`

Why does it seem the best way to make a living is to invest in real estate?

Do my potential customers need to understand the "meaning" of a logo, or just recognize it?

Duck, duck, gone!

Windows 10 deletes lots of tiny files super slowly. Anything that can be done to speed it up?

Implementation of a Thread Pool in C++

To what degree did the Supreme Court limit Boris Johnson's ability to prorogue?

If a spaceship ran out of fuel somewhere in space between Earth and Mars, does it slowly drift off to the Sun?

Verb ending in -ん with positive meaning?

What is the logical distinction between “the same” and “equal to?”

How to compare integers in TeX?

Did Tolkien ever write about a Heaven or Hell for Men?

Why would an airline put 15 passengers at once on standby?

How deep is the liquid in a half-full hemisphere?

What is the goal of the Shiva Purana?

Can you cure a Gorgon's Petrifying Breath before it finishes turning a target to stone?

Can the President of the US limit First Amendment rights?

How to translate "it's right to leave this world better than you found it"?

Sci-fi movie with one survivor and an organism(?) recreating his memories

Earliest time frog can jump to the other side of a river in C#. Codility's task

Is it possible to take a database offline when doing a backup using an SQL job?

Why isn't there armor to protect from spells in the Potterverse?

Would a 737 pilot use flaps in nose dive?



PyAutoGUI Click on Item that could be on any monitor


Finding the index of an item given a list containing it in PythonHow to randomly select an item from a list?Is there any way to kill a Thread?How to remove items from a list while iterating?How can I count the occurrences of a list item?pyautogui crashes whenever it clicksInstalling Pygame through Pycharm or System TerminalMouse not clicking during GUI automation with pythonWhy pyautogui click not actually clickingCould not import backend 'Glfw'






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have an extra monitor plugged into my laptop many times (but not all the time) and I recently noticed that the following code:



import pyautogui
change_intense_to_calm = pyautogui.locateOnScreen('Intense.png', confidence = 0.9)
run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
pyautogui.click(run_script_button_x, run_script_button_y)


doesn't work when the 'Intense.png" item appears on the second monitor! It does move the mouse to the position and click if it appears on the primary monitor (the laptop screen), but if the window containing that item is on the secondary monitor, it fails, giving me this error:



Traceback (most recent call last):
File "E:Installation3_IncludePK2_ScriptsAutoHotkeyfoobarFacetsSwitcherdoit.py", line 18, in <module>
run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
File "C:Program FilesPythonPython37libsite-packagespyscreeze__init__.py", line 407, in center
return (coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))
TypeError: 'NoneType' object is not subscriptable


presumably because it's not finding it.



How can I modify my code so that it will find the item and click it regardless of which monitor the window containing it is located on? For reference, I am on Windows 10 64bit build 14393.










share|improve this question
































    1















    I have an extra monitor plugged into my laptop many times (but not all the time) and I recently noticed that the following code:



    import pyautogui
    change_intense_to_calm = pyautogui.locateOnScreen('Intense.png', confidence = 0.9)
    run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
    pyautogui.click(run_script_button_x, run_script_button_y)


    doesn't work when the 'Intense.png" item appears on the second monitor! It does move the mouse to the position and click if it appears on the primary monitor (the laptop screen), but if the window containing that item is on the secondary monitor, it fails, giving me this error:



    Traceback (most recent call last):
    File "E:Installation3_IncludePK2_ScriptsAutoHotkeyfoobarFacetsSwitcherdoit.py", line 18, in <module>
    run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
    File "C:Program FilesPythonPython37libsite-packagespyscreeze__init__.py", line 407, in center
    return (coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))
    TypeError: 'NoneType' object is not subscriptable


    presumably because it's not finding it.



    How can I modify my code so that it will find the item and click it regardless of which monitor the window containing it is located on? For reference, I am on Windows 10 64bit build 14393.










    share|improve this question




























      1












      1








      1








      I have an extra monitor plugged into my laptop many times (but not all the time) and I recently noticed that the following code:



      import pyautogui
      change_intense_to_calm = pyautogui.locateOnScreen('Intense.png', confidence = 0.9)
      run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
      pyautogui.click(run_script_button_x, run_script_button_y)


      doesn't work when the 'Intense.png" item appears on the second monitor! It does move the mouse to the position and click if it appears on the primary monitor (the laptop screen), but if the window containing that item is on the secondary monitor, it fails, giving me this error:



      Traceback (most recent call last):
      File "E:Installation3_IncludePK2_ScriptsAutoHotkeyfoobarFacetsSwitcherdoit.py", line 18, in <module>
      run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
      File "C:Program FilesPythonPython37libsite-packagespyscreeze__init__.py", line 407, in center
      return (coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))
      TypeError: 'NoneType' object is not subscriptable


      presumably because it's not finding it.



      How can I modify my code so that it will find the item and click it regardless of which monitor the window containing it is located on? For reference, I am on Windows 10 64bit build 14393.










      share|improve this question
















      I have an extra monitor plugged into my laptop many times (but not all the time) and I recently noticed that the following code:



      import pyautogui
      change_intense_to_calm = pyautogui.locateOnScreen('Intense.png', confidence = 0.9)
      run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
      pyautogui.click(run_script_button_x, run_script_button_y)


      doesn't work when the 'Intense.png" item appears on the second monitor! It does move the mouse to the position and click if it appears on the primary monitor (the laptop screen), but if the window containing that item is on the secondary monitor, it fails, giving me this error:



      Traceback (most recent call last):
      File "E:Installation3_IncludePK2_ScriptsAutoHotkeyfoobarFacetsSwitcherdoit.py", line 18, in <module>
      run_script_button_x, run_script_button_y = pyautogui.center(change_intense_to_calm)
      File "C:Program FilesPythonPython37libsite-packagespyscreeze__init__.py", line 407, in center
      return (coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))
      TypeError: 'NoneType' object is not subscriptable


      presumably because it's not finding it.



      How can I modify my code so that it will find the item and click it regardless of which monitor the window containing it is located on? For reference, I am on Windows 10 64bit build 14393.







      python python-3.x automation pyautogui






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 30 at 16:43







      jippyjoe4

















      asked Mar 28 at 19:44









      jippyjoe4jippyjoe4

      2941 silver badge9 bronze badges




      2941 silver badge9 bronze badges

























          0






          active

          oldest

          votes














          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405728%2fpyautogui-click-on-item-that-could-be-on-any-monitor%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405728%2fpyautogui-click-on-item-that-could-be-on-any-monitor%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?