Windows store app automating testing, run and detect when the application is stopped (suspended) c++ - c++

Im using this guide "automating the testing of windows 8 apps" to test my windows store app
http://blogs.msdn.com/b/windowsappdev/archive/2012/09/04/automating-the-testing-of-windows-8-apps.aspx
Unfortunaltely Ive run into a problem, I need to know when my app closes (crashes) or when it goes into suspended mode, to log that info, and I want the launcher to be able to know the application has stopped , unfortunately iApplicationActionManager, does not have that method. And IPackageDebugSettings which is used to change the application suspend and resume states does not have a readable current state property (afaik)
Is there any way to do this?

Related

AllocConsole() doesnt show up

I'm trying to inject a dll into a testprogam and use AllocConsole() for debugging.
AllocConsole();
However, the console wont show up and I realized that the program I was trying to inject is running under SYSTEM and I was using an administrator account so the console wont show up on my desktop. Only the conhost process was created.
So... How to make a console from AllocConsole() show up on every accounts desktop?
The program is running as SYSTEM so likely it's a service running in the services session (session 0). It's not possible to allocate a console and show it in another session (e.g. the console session). It's not possible for a process to have a window (or console) that is visible in all sessions or even on multiple desktops.
If you don't know what Session Isolation is best start reading here: Application Compatibility - Session 0 Isolation
If you want to output simple debugging, an easy method is using OutputDebugString (and use a tool like DbgView to read the output) or writing to the eventlog. For more detailed output you could setup a named pipe or some other inter processs communication.

How to detect if Qt Application(WIN & MAC) is hung

I have a desktop Qt application(For Windows and MAC) written in C++. We receive reports and feedbacks that the application has hung, and must be forcefully terminated.
How to detect if the Application is hung ?
so that we can at-least gather additional metric about the number of times the Application hangs.
Is it possible to achieve within the application ?
Or Can we create a separate executable process which polls the Application periodically and reports the metric if the Application hangs?
Note: For windows i came to know about "SendMessageTimeout()" API can this be used by the process to poll the Application ?
Also any similar available for MAC ?

Add macOS Console Application to Accessibility

I've developed an Accessibility API console application in C++ for High Sierra (and lower) - uses AXUIElementCopyAttributeValue etc.
I've disabled SIP to give me a chance here to write to the Accessibility database using tccutil.
So, the application runs as expected in Xcode, given that I've enabled 'Xcode' in System Preferences->Security & Privacy->Privacy->Accessibility.
I've wrapped my console application into a .app so I can drag and drop into this Accessibility panel.
If I run the application outside of Xcode in a Terminal window, I have to also give Terminal.app Accessibility rights for the application to use the API otherwise nothing is extracted. This then seems that you must give the calling application the rights.
I'm trying to launch the application on startup via a LaunchAgent with root privileges, /usr/bin/sudo being the calling application. Launching a script instead to run the application seemed the better method. The application launches fine, infact the console application inside the .app is also added now to the Accessibility panel.
Unfortunately, the Accessibility side of things is still not working and I've run out of ideas?
Any help will be appreciated.
Many thanks in advance.

Background Application in Windows IoT Core stops responding

I created a Background Application for Windows IoT Core on a Raspberry Pi 3. It is to become a hub application for a "smart home remote" (Nuimo) which uses BLE GATT to communicate.
The odd thing is that after a short time of running, the application simply stops responding and also drags Visual Studio along. VS then responds very slowly, has trouble detaching from the debugging process, shows "waiting for a background task to complete" dialog. However, no exceptions seem to be thrown (I enabled breaking on all exceptions). This makes it very difficult to find the cause of the problem.
I tried:
removing parts of the application
enabling breaking on all exceptions
combining multiple events coming from the BLE device to prevent flooding the application with events.
Unfortunately none of this helped.
Relevant documentation I read:
https://developer.microsoft.com/en-us/windows/iot/docs/backgroundapplications
https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/bluetooth-dev-faq
https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/access-sensors-and-devices-from-a-background-task
Therefore I'm wondering whether anybody could share experience and hints where to look for the issue.
The code is at https://github.com/wind-rider/nuimo-hub and https://github.com/wind-rider/nuimo-windows (too much to post here since I don't know what part the issue is in)
Update: in the process explorer (via Windows Device Portal) I see that suddenly the memory used by the app drops when it stops responding, but its process (backgroundTaskHost.exe) is not immediately gone. It seems that somehow the Background App is unloaded, and that Visual Studio doesn't notice it since the host process is not shut down?
Now - how to know why the task is unloaded?
I assume that a Windows IoT Core background app is a special kind of background task that is not limited by the resource constraints applying to background tasks for "normal UWP apps"? Quote: "Background Applications are applications that have no direct UI. Once deployed and configured, these applications launch at machine startup and run continuously without any process lifetime management resource use limitations." (from https://developer.microsoft.com/en-us/windows/iot/docs/backgroundapplications)

Windows Service with GUI monitor?

I have a C++ Win32 application that was written as a Windows GUI project, and now I'm trying to figure out to make it into a Service / GUI hybrid. I understand that a Windows Service cannot / should not have a user interface. But allow me to explain what I have so far and what I'm shooting for.
WHAT I HAVE NOW is a windows application. When it is run it places an icon in the system tray that you can double-click on to open up the GUI. The purpose of this application is to process files located in a specified directory on a nightly schedule. The GUI consists of the following:
A button to start an unscheduled scan/process manually.
A button to open a dialog for modifying settings.
A List Box for displaying status messages sent from the processing thread.
A custom drawn window for displaying image data (the file processing includes the creation and saving of images).
A status bar - while a process is not running, it shows a countdown to the next scheduled scan. During a scan it also provides some status feedback, including a progress bar.
WHAT I'M SHOOTING FOR is a service that will run on boot-up and not require a user to login. This would consist of the scheduled file processing. However, when a user logs in I would still like the tray icon to be loaded and allow them to open up a GUI as I described above to monitor the current state of the service, change settings, start a scan manually, and monitor the progress of a scan.
I'm sure that I have seen applications like this - that function as a service even when I'm not logged in, but still give me a user interface to work with once I do log in.
I'm thinking that instead of having a single multi-threaded application that sends messages to the GUI thread from the processing thread, I need two applications - a Service to perform the processing and a GUI application to provide visual feedback from the Service and also send messages to the Service (for example, to start a scan manually). But I am new to Windows Services and have no idea how this is done.
It is also possible that I'm completely off base and a Service is not what I'm looking for at all.
Any help / ideas / suggestions would be greatly appreciated! Thank you.
You can't do this as a service.
You'll need to make your Windows Service as a normal service application. This will startup on system startup, and run the entire time the system is up.
You'd then make a completely separate GUI application, which "talks" to the service. This can be set to run when a user logs in, in the user's account.
In order to make them "talk" to each other, you'll need to use some form of IPC. Since these run on the same system (but in different accounts, typically), named pipes or sockets both work quite well.
There is a simple way of doing it.
You can’t have the service access any user’s session (session 1,2,3..) since services are isolated and can access session 0 only. This is a change from 2011.
You should write a win32 program to be launched by your service per each user who logs in using https://msdn.microsoft.com/en-us/library/windows/desktop/ms682429(v=vs.85).aspx
The service can continue performing any task that isn’t user specific.