Thursday, 1 October 2020

Execute PyAutoGUI code on second MacBook Pro desktop

I have the following code, which matches a screenshot of the "Tech" header/button from the Wall Street Journal's front page, and then clicks on it -

import pyautogui as pya
import time

# timing start
start = time.time()

# center of screen
pya.moveTo(840, 525, 1)

# navigate to "Tech" button
p = pya.locateOnScreen('wsj-tech.png', confidence = 0.8, grayscale=False)
print(p)
x, y = pya.center(p)
x, y = x/2, y/2
d = pya.moveTo(x, y, 1)
pya.doubleClick(d)

# end timer
end = time.time()
print(end - start)

To execute the code, I have to set the IDE (spyder) above (below also works) the browser:

enter image description here

Is there any way I can leave the browser on another desktop? E.g. execute the script in spyder (on "Desktop 2"), and then swipe over to "Desktop 1" to see the autoclicker work on the WSJ page?

FYI the computer is not connected to any external desktops.

enter image description here



from Execute PyAutoGUI code on second MacBook Pro desktop

No comments:

Post a Comment