SikuliX IDE wait for object to be displayed - sikuli

I use this code to wait for an object in SikulixIDE 1.1.4-SNAPSHOT: wait(Pattern("1548143854795.png").similar(0.7),35).
After 15-20 seconds object is present on screen, but it doesn't wait for it. Next type() methods are executed without waiting for object.

This usually happens if something else is visible on the screen that matches also with a similarity >0.7.
You can check this in the IDE with the Preview feature (click the image).
Programmatically you can highlight the found match:
wait(Pattern("1548143854795.png").similar(0.7),35).highlight(3)
If something else is found you might try with a higher similarity like 0.95 or even 0.99 (exact match).
read how SikuliX works

Related

How can I fix all my area2D functions in Godot to not run on startup?

Ok, I've been using Godot for a while now, and haven't really had any issues. But, after I added an area2D to detect the player and teleport them as shown below that I run into issues. Every time I start the game, the console shows that both of the functions have already been run, even though the starting location is nowhere near the area2Ds. In addition, because they run in enter -> exit order, it spawns me at the exit of the tunnel, instead of the start of the map.
func _on_Tunnel_body_entered(_body):
print("entered_tunnel")
global_position.x = 952.5
global_position.y = 487
func _on_TunnelBack_body_entered(_body):
print("exited_tunnel")
global_position.x = 920
global_position.y = 635
Any help would be appreciated!
Are you, by chance, instancing the player character, adding it to the scene, and then setting its position (in that order)?
That is a common reason for this problem. What happens is that it collides with the areas once you add it to the scene but before you set its position.
To solve it set the global position before adding it to the scene.
You could temporarily disable the behavior by any of these means:
Temporarily changing the layers and mask to avoid the collision (you can do it with set_collision_layer_bit and set_collision_mask_bit).
Temporarily disabling collision shapes (by setting disabled to true. However, use set_deferred to avoid disabling it while Godot is still doing physics computations)
Temporarily adding collision exceptions (by calling add_collision_exception_with and remove_collision_exception_with).
Having a flag that you can check in the function that takes the signal to decide if it should take effect or not.
Connecting the signals from code once, so they are not connected beforehand.

How to access text in UI element with JXA?

When you open a Terminal or iTerm window, you are shown a string like
Last login: Fri Jul 10 00:00:00 on ttys000
(base) my_username#my_hostname ~ %
I would like to be able to read this string into a variable in JXA.
This is how far I got until now.
1. Accessibility Inspector
With Accessibility Inspector I have discovered the hierarchy of UI elements which lead to the string I am looking for.
2. UI Browser
I have used UI Browser to navigate trough the hierarchy and obtain an Apple Script code to access the element; but I need JXA code.
3. Translating into code
In order to try to access the above UI hierarchy with JXA I have first enabled the Safari JavaScript debugger as explained here
and then I have written this code to invoke the debugger:
i_term = Application('iTerm')
i_term.quit()
i_term.activate()
delay(0.2)
debugger
Now, within the console of the debugger, I have tried to access the object by using the same variable naming shown in the first code snippet from this answer, that is
i_term.windows()[0].groups()[0].splitterGroups()[0].scrollAreas()[0]
At this point I have two problems:
I actually don't know if the object that I am trying accessing exists, because in the console I get uninformative output. I just know that i_term.windows()[0] is correct since if I type i_term.windows()[0].name() I get the string "zsh", which is the title of the window.
I don't know what's the name of the method/variable for the text UI element.
More generally, how I am describing in this other question (link coming in a edit I will soon make), I have tried printing in many ways the "content" of the variables I am working with, but I can't see the methods/values they contain. For instance: I would like to be able to see the list of methods/variables of i_term, in particular to know that it contains the method windows(), but I have found no way of getting this information. Being able to get this information would make possible to write the code much more easily, even with the current lack of documentation.
How can I obtain the string value of that text?
Why are you wanting to achieve your goal through UI scripting ? It's the most difficult kind of script to implement well, and the most likely to break.
I don't know whether you're aware, but the contents of a terminal window in both Terminal.app and iTerm.app can be retrieved through their AppleScript properties.
iTerm:
Application('com.googlecode.iterm2').windows[0].tabs[0].sessions[0].contents()
// OR: .currentWindow.currentSession.contents()
Terminal:
Application('com.apple.Terminal').windows[0].tabs[0].contents()
// OR: .windows[0].selectedTab.contents()
Side-bar:
To obtain an object reference—if one exists—to any given UI element on your screen, you need:
A definitive, unobstructed pixel belonging solely to the UI element in question, for which you can discern its (x, y) coordinates relative to the top-left of your screen. The "l" of "login" seems good:
Access privileges granted for Script Editor and System Events.
Then, when you run the command:
tell application id "com.apple.systemevents" to click at {x, y}
and, provided that the pixel you identified at coordinates (x, y) remains in view when the command executes, then the return value of the command will be the object reference to the UI element occupying the pixel at those coordinates.
If it returns missing value, the element isn't accessible.

IMobileServiceSyncTable PullAsync doesn't return

I currently use Azure Mobile Services with Offline Sync and I it has been working fine. However I now have come to a problem I can't seem to debug. On the PullAsync it never returns, never goes to the Web API, it never errors, it just seems to be stuck somewhere and I don't know where.
IMobileServiceSyncTable<ResponseType> responseTypeTable = MobileService.GetSyncTable<ResponseType>();
await responseTypeTable.PullAsync(responseTypeTable.Where(c => c.CompanyId == companyId));
I use identical code elsewhere with a different type and it works well.
The only thing that happens is the Windows Phone emulator UI locks up, I can press buttons on the keyboard but the input or buttons are all frozen.
I get this on the Debug Output
The thread 0xb80 has exited with code 259 (0x103).
After a 5 seconds and that's about it. Breakpoints everywhere, nothing happening.
The method was in a Command (I'm using MVVMLight). When I call the function on the class initialization and just hold the value it works fine. There is obviously some bug that occurs when calling PullAsync on an event, in an async RelayCommand but getting the call out of there solves the issue.
I'll leave it at that unless anyone comes back with why it is actually happening. This is just a workaround at the moment.

Event that fires when a url is confirmed as valid

Alright dudes... I have a problem that is looking for an answer more specific than the seemingly obvious solution.
I have a block of code that I want to execute directly after a url is known to be valid. What I mean by 'valid' is that the program has checked to see if that filepath actually exists. This could be accomplished by a COMPLETE listener, because after all, a loader couldn't finish loading its content if the referenced file didn't exist, but I want it to happen before any of the bytes begin to get sucked in. I have also tried the HTTPS_STATUS event, with a conditional saying "if the status is this [some non-error status number], then run this block of code." This would have worked great, except that different environments produce different network codes, and some even can't distinguish between errors and non-errors, just returning 0's no matter what. Because of this, I can't write a conditional that works no matter what browser....
So, anyone got any ideas?!?!?!?!
If this doesn't work post your code.
myUrlLoader.addEventListener(Event.OPEN, openHandler);
//Dispatched when the download operation commences following a call to the URLLoader.load() method.

Is it possible to know whether Windows widget totally covered by other windows?

We want to create a Windows desktop version of our weather widget
There are 2 special things about the widget.
It consumes a lot of processor time
while active - it displays an
animated picture (Flash without GPU acceleration, unfortunately).
It updates the weather from our
server (frequent server requests from all widget users).
When the user does not look at the widget there is no need for animation and weather loading.
So I have an idea of putting my widget to sleep when it is not visible and hense not used.
Is it possible to detect whether the widget is used or not.
Speaking precisely I need to know whether the widget is covered by other windows?
I mostly interested in Vista/7 gadgets engine, however I also would like to know if this problem is solved in these widget engines
Yahoo widgets
Google desktop
Hope to find some desktop widget guru here.
Pasha
If you InvalidateRect and don't get a subsequent WM_PAINT message, than your window is hidden. You can call UpdateWindow after InvalidateRect to force the WM_PAINT message to happen (or not happen) right away.
So you could do something like this
request server data (and cancel request timer if any)
when data arrives InvalidateRect
when WM_PAINT message arrives, draw the data and set a timer for next request
when timer arrives, goto 1
When you stop getting WM_PAINT messages, you stop re-setting your timer, and you therefor stop requesting updates from the server. When the WM_PAINT message happens (because you are no longer covered). You start requesting data again.