sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #09966
Re: [Question #193849]: [EXAMPLE] XBMCFlix-o-mate Automating Netflix Silverlight Controls
Question #193849 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/193849
bengalih posted a new comment:
Revised code is below. I believe I have taken into account all your
suggestions, let me know if you think further optimization or
clarification is necessary.
The only question remaining from above is your suggested code:
screenCenter = Region(getBounds).getCenter()
You can see I have that commented out below and replaced with a simple
getCenter() because when using your suggested code I get the following:
"TypeError: org.python.proxies.sikuli.Region$Region$0(): 1st arg can't
be coerced to org.sikuli.script.Region, java.awt.Rectangle"
Perhaps I misunderstood your example...?
Thanks!
----CODE START---
#Title: XBMCFlix-o-mate
#FileName: XBMCFlix-o-mate.sikuli
#Version: 1.1beta
#Author: bengalih
#
#Summary: A Sikuli script to automate Netflix controls within
# XBMCFlix, a plugin for XBMC.
# This script must be used in conjuntion with
# XBMCFlix-o-mate.au3 AutoIT script.
#Used on first launch of Netflix to bring into full screen mode
#Also used after switching episodes
def netFlixLaunch(event):
if debug == 1:
print("debug: in netFlixLaunch (Ctrl+Alt+Shift+O)")
#Wait 8 seconds for launch of new Video, otherwist timeout to prevent CPU usage
if NextEpisodeRegion.wait("netflixlogo.png",8):
if debug == 1:
print("debug: loading movie")
#Wait up to 60 seconds for movie to buffer
if NextEpisodeRegion.waitVanish("netflixlogo.png",60):
if debug == 1:
print("debug: loaded movie")
#Set movie to full screen if not already
if not ControlBarRegion.exists("exitflag.png",1):
ControlBarRegion.click("fullscreen.png")
if debug == 1:
print("debug: full screen action!")
else:
if debug == 1:
print("debug: timed out waiting for Netflix logo to vanish")
else:
if debug == 1:
print("debug: timed out waiting for Netflix logo to appear")
#Toggles full screen
def toggleNetFlixFullScreen(event):
if debug == 1:
print("debug: in toggleNetFlixFullScreen (Ctrl+Alt+Shift+F)")
click(hoverPoint)
if ControlBarRegion.exists("fullscreen.png",1):
click(ControlBarRegion.getLastMatch())
hover(hoverPoint)
#Advances to next episode either during show or at end screen
def goNextEpisode(event):
if debug == 1:
print("debug: in goNextEpisode (Ctrl+Alt+Shift+N)")
#Check if episode is over and Next Episode prompt is on screen
if NextEpisodeRegion.exists("nextepisode.png",1):
click(NextEpisodeRegion.getLastMatch())
netFlixLaunch(None)
#If in middle of episode use skip button instead
else:
click(hoverPoint)
if ControlBarRegion.exists("skipbutton.png",1):
click(ControlBarRegion.getLastMatch())
netFlixLaunch(None)
else:
#Toggle out of full screen mode to find skip button
if ControlBarRegion.exists("fullscreen.png",1):
click(ControlBarRegion.getLastMatch())
if ControlBarRegion.exists("skipbutton.png",1):
click(ControlBarRegion.getLastMatch())
netFlixLaunch(None)
hover(hoverPoint)
#Goes back one episode
def goPreviousEpisode(event):
if debug == 1:
print("debug: in goPreviousEpisode (Ctrl+Alt+Shift+B)")
click(hoverPoint)
if ControlBarRegion.exists("prevbutton.png",1):
click(ControlBarRegion.getLastMatch())
netFlixLaunch(None)
else:
#Toggle out of full screen mode to find back button
if ControlBarRegion.exists("fullscreen.png",1):
click(ControlBarRegion.getLastMatch())
if ControlBarRegion.exists("prevbutton.png",1):
click(ControlBarRegion.getLastMatch())
netFlixLaunch(None)
hover(hoverPoint)
#Toggles English subtitles on and off
def toggleEnglishSubtitles(event):
if debug == 1:
print("debug: in toggleEnglishSubtitles (C+A+S+T)")
click(hoverPoint)
#If Subtitles exist, create smaller region for search
subtitleControl = ControlBarRegion.exists("subtitles.png",1)
if subtitleControl:
click(ControlBarRegion.getLastMatch())
subtitleOptions = subtitleControl.nearby(100)
subtitlesEnglish = subtitleOptions.find("subenglish.png")
subtitlesOff = subtitleOptions.find("suboff.png")
if not Settings.mySubtitlesOn:
click(subtitlesEnglish)
Settings.mySubtitlesOn = True
else:
click(subtitlesOff)
Settings.mySubtitlesOn = False
ControlBarRegion.click("subtitles.png")
hover(hoverPoint)
#sets the scan region to the lower 20% of the screen
def setControlBarRegion():
regionX = 0
regionY = (SCREEN.h/10)*8
regionW = SCREEN.w
regionH = SCREEN.h-regionY
global ControlBarRegion
ControlBarRegion = Region(regionX,regionY,regionW,regionH)
#sets the scan region to the middle area of the screen
def setNextEpisodeRegion():
regionX = (SCREEN.w/10)*3
regionY = (SCREEN.h/10)*3
regionW = (SCREEN.w/10)*4
regionH = (SCREEN.h/10)*4
global NextEpisodeRegion
NextEpisodeRegion = Region(regionX,regionY,regionW,regionH)
debug = 1
Settings.MoveMouseDelay = 0
Settings.mySubtitlesOn = False
#sets the hover point for the mouse to the center of the screen
#screenCenter = Region(getBounds).getCenter()
screenCenter = getCenter()
hoverPoint = screenCenter
#initializes the two scan regions
setControlBarRegion()
setNextEpisodeRegion()
#User Defined hotkeys in block below:
#If changing the netFlixLaunch key away from "O", be sure to
#also update the AutoIt script!
####################################################################
Env.addHotkey("O", KeyModifier.ALT+KeyModifier.SHIFT+KeyModifier.CTRL, netFlixLaunch)
Env.addHotkey("F", KeyModifier.ALT+KeyModifier.SHIFT+KeyModifier.CTRL, toggleNetFlixFullScreen)
Env.addHotkey("N", KeyModifier.ALT+KeyModifier.SHIFT+KeyModifier.CTRL, goNextEpisode)
Env.addHotkey("B", KeyModifier.ALT+KeyModifier.SHIFT+KeyModifier.CTRL, goPreviousEpisode)
Env.addHotkey("T", KeyModifier.ALT+KeyModifier.SHIFT+KeyModifier.CTRL, toggleEnglishSubtitles)
####################################################################
#Main subroutine
while True:
wait(1)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.