After launching app, it takes 30+ seconds before able to access elements through pywinauto - ui-automation

I'm testing a custom WPF application using pywinauto.
When connecting with win32, I don't get any dependents, so I'm connecting with uia.
After I launch the application, I can immediately connect with pywinauto, but it takes 30s+ before I'm able to access any elements. After the initial delay, interacting and searching for controls is quick.
I call windows() as a way to wait until the application lets me interact with it.
main_app = Application(backend="uia").connect(path=APP_PATH)
main_app.windows()
On investigation, the hanging seems to occur during: "application.py" > "windows" > "findwindows.find_elements(...)" > "element.children(...).
If I open the application, and wait for 1 minute, and then run the script, then it occurs almost immediately. And finding subsequent controls is quick.
I appear to see this same behaviour when using inspect.exe to view the hierarchy. If I refresh immediately after opening the application, it takes 30s+ to show anything. But If I wait a minute before refreshing, it updates immediately.
I was wondering if someone else had experienced this before, and what might be the cause/solution.
I am running:
Windows 10, python 3.8.3, pywinauto 0.6.8

Sometimes setting an application as an firewall exceptions helps them boot/open faster.
Granting Firewall exception on Windows 10 for an application:
Go to Control Panel.
Click Windows Firewall or Windows Defender Firewall option.
Choose option "Allow an app or feature through Windows Firewall" (on left side).
Select your application in the list or click on Add Another App to find it and add it to list.

After debugging some more, I have resolved the issue, although it's not clear to me what the root cause actually was.
The custom application I'm testing launches a background application as a non-visible console. Testing showed that not running this background application allowed me to conenct immediately. Running the background application by itself would cause the same delay in inspect.exe loading.
The application was a dotnet framework application, that in theory was a console only application, but had code supporting a WPF interface (which was not displayed). By removing the WPF aspects of the project, I was able to build the application as a purely console application, and I no longer experienced the earlier delays.

Related

Service fabric debugging - reliablecollection persisted?

I can't seem to find any information on whether a ReliableCollection, specifically ReliableQueue is persisted between debugging sessions in visual studio. It does not seem like it is. I think it's because the application is removed and then re-added during debugging. Can anyone confirm this?
Yes, the default behavior is to remove the deployed application after the debugger stops.
Fortunately, you can change this.
There are two ways this can be done: Launch your app from VS without
the debugger attached (Debug -> Start Without Debugging [Ctrl+F5]).
Obviously, this would require you to manually attach VS to your
service processes in order to debug them. When you detach VS from the
processes, VS will not remove the application in this scenario.
With
your Application (.sfproj) project selected in Solution Explorer, go
to the Properties window and change Application Debug Mode from
"Remove" to "Auto Upgrade". This prevents VS from removing the
application after debugging. However, it also causes another change in
behavior in that it will automatically upgrade your application each
time you launch it from VS. The added benefit of auto upgrade is that
your application state will be maintained across multiple launches
from VS. This may be desired or not. There is not a setting that
allows you to both prevent application removal and not do an auto
upgrade.

Start an application at system start without login

We have a new server running and we got some new programs doing import routines. So far so good... But there is one program that is put into autostart folder. So it doesn't run until admin logs in and it stops if we logout.
I'd like to put this one into a seperate session so it may work without any interaction by simply starting it with the task scheduler at startup. Is this the right way to do this? Is it safe if I log in later and log out?
Many thanks!
Edit: The applications shows as a symbol in the task bar if running, it can be configured by this. Anything I must know about this if I change?
Edit: It is not my application, I cannot rewrite it as a service.
I successfully added the application by using task schelduler on startup. Login and logout will not quit the application but no symbol is shown. Please add details to my side questions and I'll mark your answer as the accepted one.
Edit: Ended up using this one. If I have to configure, I stop the application in task manager and start it again by link. After that I quit the application and restart it by task scheduler manual start.
You need to run your program as a Windows Service. One way of doing it is using the sc.exe program:
> sc create <new_service_name> binPath= "c:\myapp\myapp.exe"
You can read about it here.
You need to separate your application in two.
To allow it to run without a user session, you need a windows service. That should handle all the background stuff. You can then register the service and set it to start when the system starts.
To allow it to have a UI, and show up in the notification area, you need a windows application. This will be in autostart as usual, and will communicate with the service - for example, over named pipes.
While it is still (barely) possible to run an UI application without a user session, it's only maintained for backwards compatibility, and already shows a lot of problems. It will likely be removed altogether in the future, because it breaks quite a few contracts. Do not rely on hacks like this.
I also used the task scheduler to create the application at system startup. It should be noted that if you want to use for mining, you have to disable an option in "settings" where it says that if the application lasts more than three days in a row it will end.
It really works wonderfully!
it is a old question but I recently solved in another way...
(before I was using a scheduled-task for startup but this gave me diverse problems with lots software...)
Some programs also for diverse reasons must be run at a user level... or even inside a specific user session...
So the best way I found was to use a tool like Sysinternal/Autoruns to program the auto-logon to a specific user (it is a registry setting)... and in the startup-folder of that user (or any other "autorun/autolaunch" task)... run a script that first locks the screen... and next runs the other intended programs... that will run under that user profile...
so you can choose a standard user or a administrator... or even launch programs from a standard user in adminsitrator mode...
I hope will help...
This "hack" solved me many problems with startup apps...
I could not get the "sc create" command to work. Instead I manually edited the registry using regedit. I added a new key in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services.
I used the following page to figure out required parameters and their values. Note that the names do not map.
https://learn.microsoft.com/en-us/windows-hardware/drivers/install/inf-addservice-directive
Old question, but for anyone that stumbles here. Use srvany to set the program as a custom service.
Note that when you do this with for example dropbox, googledrive, etc., you will need stop the service, then open the program normally to make changes like password, updates, etc.
below is a well enough intro.
https://www.iceflatline.com/2015/12/run-a-windows-application-as-a-service-with-srvany/
Download the tool kit here
https://www.microsoft.com/en-us/download/details.aspx?id=17657
Convert user application to Service and Register it using Regsvr32 or installutil.exe. It will start the service using SYSTEM user account. Which is a high privilege account.
Note : You can`t run any Window based application. Even a Message only window.

GWT development with Eclipse

I am developing a GWT app using eclipse and I was wondering if there is a way to hot swap client code changes I make without having to do a full Google Compile each time. Currently when I modify my code, I do a Google compile and then click the Reload server button, then I refresh my browser to pick up the changes. This is starting to get a bit painful as it takes 10 - 20 sec to do a full compile when I may have only modified a UI string so was wondered is there a quicker way.
If you want to see your changes in client code, hit the refresh button in your browser.
If you need debug functions, use Debug As => Web Application. It may be a little (or a lot) slower to start depending on a browser.
If you don't need debug functionality, use Run As => Web Application. It starts faster. You will still see all errors in Development Mode and Console tabs.
If you make changes to server-side code, you have to reload the web server, using the dedicated button of the dedicated Development Mode view in Eclipse.
You never need to recompile unless the plugin tells you to do it.
See https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#DevGuideDevMode
To add to Andrei's answer Assuming we are changing functionality invoked on button click.
1) We usually change lines of code in the function invoked and click the button again in the UI. No need of reloaing the entire application using refresh button.
2) If the change involves code that cannot be hotswapped - example class changes like adding new a class variable, then you need to refresh browser. You can sometimes ignore the eclipse warning complaining that it cannot hot-swap.
3) If you run out of memory then you need to close and relaunch dev mode.
4) If your server side is hogging memory then it might be better idea to use external server rather than jetty to avoid time consumed on server restart for every dev mode launch.

How to auto terminate instances of Java application in eclipse?

I was doing a small project and everytime I run the program, I can feel more lag and delay, until it is completely not working anymore.
I checked with the task managers and found many "Javaw.exe" Instances. Then I opened the debug field and realize that it runs a new instance everytime I run the same project.
here is the link to image of the instances in debug area.
http://i50.tinypic.com/2hz4spu.png
The temporary solution for me is to terminate them from the debug area. Is there any way to prevent the same project from creating a new instance everytime it is run ? I only need one instance that can be reused everytime I run again and again.
Thanks for any response in advance.
No, I'm sure that's not what you want. If you restart an application, it's probably that you want to test some changes you've just made in the code. So Eclipse needs to start a new instance of your application. You could also want to start two instances of an app because they need to talk to each other.
If you want previously launched applications to stop, then stop them. Your app seems to be a GUI app. Use the close button on the main frame of the app to close it. As simple as that.
It's often not desired to kill an application, because it might need to properly close resources, or tell the server it's leaving before exiting, or whatever. Having Eclipse kill apps without a conscious request from the user would not be wise.

How to keep prism application in the system tray?

I need following things:
Show my application in system tray
A popup menu on System tray for options like "Exit" or disable "Notifications"
The application should stay opened in startup even if user restarts her system
Prism SHOULD do this, though behavior might be ify, as PRISM was abandoned (as it were), turned into Webrunner, and abandoned again. All more than a year ago.
This would only be enabled if Mozilla actually put those features in place prior to ceasing their work on it.
Applications cannot stay in 'startup' if the user restarts the system. Can you please clarify?