2015-03-23 17:18:05 |
RaiMan |
description |
Sikuli version: 1.1.0-Beta2
I want to capture each screen separately every 2 seconds and wrote the following code to achieve it:
import os
import shutil
import datetime
screenshotsDir = r"C:\Users\Sikuli\Temp\Exceptions"
screens = [Screen(id) for id in range(Screen().getNumberScreens())]
print screens # Prints [S(0)[0,0 1920x1080] E:Y, T:3.0, S(1)[-1920,0 1920x1080] E:Y, T:3.0]
print Screen().getNumberScreens() # Prints 2
while True:
for _dx, screen in enumerate(screens):
print screen.getBounds() # Prints java.awt.Rectangle[x=0,y=0,width=1920,height=1080] and java.awt.Rectangle[x=-1920,y=0,width=1920,height=1080] respectively
img = screen.capture(screen.getBounds())
time_now = datetime.datetime.now().strftime("%H%M%S")
img_target = "{}.S{}.png".format(time_now, _dx)
target = os.path.join(screenshotsDir, img_target)
shutil.move(img, target)
time.sleep(2)
Unfortunately, when I go and check the screenshots, I see that Sikuli only grabbed S(0) for both monitors although the code print output gives all the right information! |
************ this works with version 1.1.0
scrs = []
dir = getBundlePath()
for n in range(getNumberScreens()):
scrs.append(Screen(n).getScreen()) # to get the Java level object
for scr in scrs:
filename = "screen%d" % scr.getID()
scr.capture().getFile(dir, filename)
captures of the screens are saved to the bundle as screenN.png
-------------------------------------------
Sikuli version: 1.1.0-Beta2
I want to capture each screen separately every 2 seconds and wrote the following code to achieve it:
import os
import shutil
import datetime
screenshotsDir = r"C:\Users\Sikuli\Temp\Exceptions"
screens = [Screen(id) for id in range(Screen().getNumberScreens())]
print screens # Prints [S(0)[0,0 1920x1080] E:Y, T:3.0, S(1)[-1920,0 1920x1080] E:Y, T:3.0]
print Screen().getNumberScreens() # Prints 2
while True:
for _dx, screen in enumerate(screens):
print screen.getBounds() # Prints java.awt.Rectangle[x=0,y=0,width=1920,height=1080] and java.awt.Rectangle[x=-1920,y=0,width=1920,height=1080] respectively
img = screen.capture(screen.getBounds())
time_now = datetime.datetime.now().strftime("%H%M%S")
img_target = "{}.S{}.png".format(time_now, _dx)
target = os.path.join(screenshotsDir, img_target)
shutil.move(img, target)
time.sleep(2)
Unfortunately, when I go and check the screenshots, I see that Sikuli only grabbed S(0) for both monitors although the code print output gives all the right information! |
|