Region(-32000,-32000,160,27) outside any screen - subsequent actions might not work as expected - sikuli

I am new to the sikuli , while running my script i found an error "[error] Region(-32000,-32000,160,27) outside any screen - subsequent actions might not work as expected" .
Please someone help me out how to over come from this issue.
My script as follows : Open an Window App if the App is not opened and if is already opened then focus on App
from __future__ import with_statement
from sikuli.Sikuli import *
class LaunchClient(object):
def __init__(self):
self.appCoordinates = (0, 0, 1024, 768)
def startApp(self):
clientApp = App("XYZ")
if not clientApp.window():
App.open(r"C:\\Program Files (x86)\\ABC \\XYZ.exe"); wait(2)
clientApp.focus(); wait(1)
def runTest(self):
self.startApp()
if __name__ == "__main__":
client = LaunchClient()
client.runTest()
The Error message "[error] Region(-32000,-32000,160,27) outside any screen - subsequent actions might not work as expected" display when the window app is already opened . Error not observed while opening the App .

It means your app is reacing the borders of your screen. For example, you can open "Notepad" and drag it off the screen so you can only see half of it. Then there is a part outside the screen.
That is what this error means.
It will also give this message when a few pixels (for the app) are outside the screen.
It is just a way from Sikuli telling you it can only click on the things that are on the screen not outside it. If you make the app full screen it mostly disapears. (Or you app is opening while touching an edge of the screen.)

Related

Libgdx, Setting the full screen resolution during runtime causes application to render at the wrong size

I am only using the desktop Application, no mobile.
I am experimenting with letting the user set the screen resolution during run time. I give him the Display Modes available and he applies one. This part actually works. The problem occurs when i save this mode and try to set this display mode the next time they launch the game.
I am using preferences to store the mode the user selected. I am unable to access preferences before the Create method in my Game class, or in the DesktopLauncher Object, where you normally set up the config file and pass it into the application. So my DesktopLauncher looks like this.
val config = Lwjgl3ApplicationConfiguration()
config.setFullscreenMode(Lwjgl3ApplicationConfiguration.getDisplayMode())
Lwjgl3Application(MainGame(), config)
I use the current screen resolution on the creation of the application. Then in my Create method in my MainGame class i get the mode they set from preferences and i set it like so...
override fun create() {
var modes = Gdx.graphics.displayModes.toList()
val mode = Gdx.graphics.displayMode
val preference: Preferences = Gdx.app.getPreferences("screenPreference")
val screenWidth = preference.getInteger("width", mode.width)
val screenHeight = preference.getInteger("height", mode.height)
val refreshRate = preference.getInteger("refreshRate", mode.refreshRate)
modes = modes.filter { it.width == screenWidth }
modes = modes.filter { it.height == screenHeight }
modes = modes.filter { it.refreshRate == refreshRate }
if (modes.isNotEmpty()) {
Gdx.graphics.setFullscreenMode(modes[0])
}
....
}
To summarize i get the list of modes, i pull from preferences what was set last, and i filter the list according to what was in preferences. This should leave one item left in the list and i apply it. If for some reason the list is empty, then i don't set it, or there is no preference set i just apply the current mode again.
This is where the weird stuff happens. I have checked all the numbers when creating my screens and cameras, and they are all correct. I do receive the correct resolution, but the application doesn't render correctly. Below are a couple examples of what happens.
In the first image you see the bounds of the application to the screen. My application only renders in the bottom corner, and the rest is black. What happened to achieve this effect is i started the application with a smaller resolution than my native resolution, so 1280x1024, then in my create method i set the application full screen mode to 1920x1080 before building the rest of my application. I have checked my cameras and my viewports, and they all have the resolution 1920x1080, but the image is not filling the entire screen.
And a second.
This one is what happens when i reverse the settings. So i start at native resolution 1920x1080, and in my create method i set it to 1280x1024, again before creating the rest of my application. This gives me black bars on both sides of the image like id expect, but the application is HUGE, and only a portion of it fits in the window, the rest goes out of bounds, as depicted by the dotted lines.
It will remain like this the entire time, unless i change the resolution while the application is running, it will then correct itself for the rest of the applications life.
I am confounded by this effect i am getting, and am looking for an answer as to why, or how to fix it.
I found the issue that was causing the image to render incorrectly. I was setting the display mode in the create() function in my main game class. This function is not run on the rendering thread, and you do not want to use Gdx.graphics on anything other than the rendering thread, as described in the libgdx wiki https://github.com/libgdx/libgdx/wiki/Threading
There is a function where you can pass in a lambda to be run on the rendering thread.
Gdx.app.postRunnable {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode(modes[0]))
}
After passing that into postRunnable the game renders correctly on launch.

Sikuli: I am not able to click on an Element present in a PopUp window

I am new to the Sikuli API and I am using the Sikuli-java-jar file. I want to successfully click on a desktop element using the screen and pattern classes.
So I was trying to create an automation script to install software.
I am able to successfully launch the installer but not able to click on the Next Button present in the pop-up window.
I am not getting any error, it is just that clicking on the image fails.
appInstaller("E:\\Sikulimages\\tc.png");
appInstallers("E:\\Sikulimages\\next.png");
public static void appInstaller(String path) throws FindFailed{
s=new Screen();
img=new Pattern(path);
s.exists(path);
s.wait(img,2000);
s.doubleClick(img);
}
public static void appInstallers(String path) throws FindFailed, InterruptedException{
s=new Screen();
img=new Pattern(path);
s.click(img);
}
I think that the reason is that default Similarity (0.7) is insufficient for small buttons and text.
Sikuli has public class Settings ,
which hosts public static double MinSimilarity = 0.7;
That value is good enough for most image recognition, but it fails for small texts. To get small text clicked, you need to raise similarity for particular pattern, or, like I do, make Settings.MinSimilarity = 0.9;
Sometimes even 0.9 is not enough to recognize small text, well, then try 0.95 , it is usually what helps to pinpoint even smallest texts.
In addition to RPWheeler's answer, if there is something right next to your target image that will appear the same way every time, you can also take a bigger screen clip and then tell Sikuli which part of that bigger image to click on.
For example: if your "Next" button is part of a row of buttons, take the screen clip to include the whole row. Then, in the IDE, double click on the image, and go to the "Target Offset" tab. Here, you'll see an example of your image, and and you click on the part of the image you want Sikuli to click on. -- the default is always the center of the rectangle, but you can change it with the target offset.
You can accomplish the same thing in code like this
t = find(yourImage).targetOffset(dx,dy)
click(t)
where dx and dy are a positive or negative number of pixels away from the center point of the rectangle.
For installing application you need admin rights. So For running any task that require admin rights you need to run sikuli in admin mode. So right click on runSikulixcmd.bat and select Run as administrator for launching the Sikuli and then run the test.
If you are running the test from command prompt run it in admin command prompt.

How to prevent AIR application from jerking around while dragging?

I've created an AIR application and it seems to be working fine but when I drag the title bar to move the native window it shakes violently and have seizures while it's dragging about.
FYI It does eventually end up where I want it to be when I stop moving the mouse.
I'm using Flex 4.6 and AIR 3.6 on Mac OSX 10.10.5. It's a s:WindowedApplication I'm also using the DragManager on a list in part of the application if that matters but it is not enabled until the user clicks into the list and moves more than a certain number of pixels.
Here is my descriptor file minus name and version info:
<application xmlns="http://ns.adobe.com/air/application/3.6">
<initialWindow>
<autoOrients>false</autoOrients>
<fullScreen>false</fullScreen>
<visible>false</visible>
</initialWindow>
</application>
On initialize I run this:
protected function initializeHandler(event:FlexEvent):void {
width = Capabilities.screenResolutionX * .96;
height = Capabilities.screenResolutionY * .9;
nativeWindow.x = (Screen.mainScreen.bounds.width - width)/2;
nativeWindow.y = (Screen.mainScreen.bounds.height - height)/2;
}
UPDATE:
I removed the main view component so it is an empty application and it drags around smoothly.
UPDATE 2:
I added the main view back in and dragged around step by step along the way. It appears to start happening when I've loaded a second Application (called a sub application) into the main application. I'm not sure though.
This happens in numerous number of my applications. It is probably because I have a component inside my application file set to size to 100% of the application. But I have not verified this on all my apps.
The solution is to resize the AIR app. After I resize it it works fine. I can drag it around and it works as expected. I think this is an AIR bug.

Share Target and JumpListItemBackgroundConverter

I've added the Share Target declaration to my app for the data format WebLink and everything works as expected. However, when I add a JumpListItemBackgroundConverter or JumpListItemForegroundConverter anywhere in the app, the app hangs on the splash screen when you enter the app using the Share from IE. No exception, no crash, the debugger doesn't even stop. All I get is a cryptic error in the output window, "The program '...' has exited with code -1073741819 (0xc0000005) 'Access violation'." The documentation for those converters say they're fine with universal apps, just that they've been moved to a different namespace. Has anyone been able to get these two things to work in the same app? If so, where did I go wrong? Or is there something better than those two converters to get the LongListSelector look and feel?
Steps to reproduce:
Create a new universal app. I chose hub.
Add a share target of format WebLink to the appxmanifest declarations.
Add a new page to point the share contract to.
Add the OnShareTargetActivated code to app.xaml.cs to open the new page. See code below
Add a JumpListItemBackgroundConverter to the resources of the main page of the app. You don't need to apply it to anything, just declaring it is enough to break the sharing.
Go to IE and share a link. It should hang on the splash screen.
Code for app.xaml.cs:
protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
// Replace SharePage with the name of the share target page
var rootFrame = new Frame();
rootFrame.Navigate(typeof(SharePage), args.ShareOperation);
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
It turns out this is a bug in the emulator. It works if you test on a physical device.
MSDN Forum - JumpListItemBackgroundConverter and Share Target in Windows Phone 8.1

Xcode: iAds in 5 ViewControllers: How?

Problem: I can't get one instance of iAds to be viewed in 5 viewcontrollers.
I used the iAdSuite example from dev.apple.com to integrate iAds into my app. All is fine until one uses the back button to go back a page within the NavControllerstack. The Ad doesnt reintegrate into the view.
One logical approach seemed to me to load up one instance of the adbannerview into my main window in my AppDelegate:
[self.window addSubview:MainView];
[self.MainView addSubview:NavController.view];
[self.window makeKeyAndVisible];
MainView takes the full window but is set to stretch up when the adbanner is loaded.
I seem to be doing something wrong because the navcontroller view seems to always take up the entire screen.
Question: How can I succesfully implement iAds in my rootview? (Or succesfully migrate iads around)
Could you keep a global reference to the iAd Banner and call [adBanner.view removeFromSuperView] followed by [theViewThatYouWantToDisplayAdOn addSubview:adBanner.view]