Question #193849 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/193849
RaiMan posted a new comment: --- screenCenter = Region(getBounds).getCenter() Sorry, a typo :-( screenCenter = Region(getBounds()).getCenter() In your case this is not needed any more. In cases where you work with setROI(), this is the way to reference the whole screen for Region methods, that otherwise would use the current ROI --- one more thing These settings are typical usage of functions with return values, so you do not need any globals for that. #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 return 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 return Region(regionX,regionY,regionW,regionH) .... and then #initializes the two scan regions ControlBarRegion = setControlBarRegion() NextEpisodeRegion = setNextEpisodeRegion() and since both functions share similar code, one should make one out of it: (the DRY design pattern: Don't repeat yourself ;-) # Set a region on the screen by relative margins ignoring ROI def setRegion(top=0, bottom=0, left=0, right=0): scr = Region(getBounds()) regionX = int(scr.w*left) regionY = int(scr.h*top) regionW = scr.w - int(scr.w*left) - int(scr.w*right) regionH = scr.h - int(scr.h*top) - int(scr.h*bottom) return Region(regionX,regionY,regionW,regionH) .... and then #initializes the two scan regions ControlBarRegion = setRegion(0.8) NextEpisodeRegion = setRegion(0.3, 0.3, 0.3, 0.3) --- one more thing more ;-) # in toggleEnglishSubtitles subtitleControl = ControlBarRegion.exists("subtitles.png",1) if subtitleControl: ... could be if ControlBarRegion.exists("subtitles.png",1): Your version only makes sense, if you could use subtitleControl again later in your code, e.g. instead of ControlBarRegion.click("subtitles.png") use click(subtitleControl) if the search would evaluate to the same match as with the exists() already --- one last thing: multi monitor I do not know, wether this is relevant: multi monitor configurations. Is the XBMC window always on the primary screen? Or can you run it on other monitors of you have them? You might evaluate the app window and use Region.getScreen(), to know the monitor, it is running on. -- You received this question notification because you are a member of Sikuli Drivers, which is an answer contact for Sikuli. _______________________________________________ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp