WP8.1 Voice Recognition without rendering app - c#

I have implemented voice commands in my Windows Phone 8.1 app, but I have run into 2 problems. The first problem, is that I would like to have the command execute without the app opening. I know it has to load the app to execute, but I'd like it to not be visible, or at least disappear when it is done. The voice command just causes a REST call to be executed and has no UI updating in the process. How can I make it not open/render the view?

Like you stated, it is not really possible.
You could instantly close the app and handle your request in the Suspension event handler using the referral.
But: You will still get the splash screen and is will probably be confusing for the user (why does that thing pop up?). Also, you cannot be sure how much time your suspension gets and if you are on a bad network connection, your rest call may fail.
It might be better to just show a confirmation/progress screen and have the user tab out himself.
Also: Be careful with sayings like just a REST call. If you are on a bad 2G connection or have some other network activity running, even a few kilobytes can take up some time.

Related

How can I close Cortana's Confirmation Screen after issuing a voice command?

I think I've successfully figured out how to utilize cortana, send commands, and work asynchronously between an app and a service.
But I can't figure out if it's possible to manually close Cortana's Confirmation Screen. I do my voice command, send my ReportSuccessAsync, but the Confirmation Screen stays open.
I wanted to utilize voice commands to not obsctruct what the user was currently doing. So if the cortana window had to be open, I wanted to show it only as minimal as possible.
Is there a command that may be sent to manually close the screen and return to normal app state?
I was experimenting. The answer may already be posted here, but I found that after the Cortana window pops up (and stays onscreen), that saying, "Hey Cortana, close Cortana" makes the window go away. Simple, and annoying that the window stays up, but effective.
It sounds like what you want to do is sort of "my app has voice commands," but the Cortana paradigm is more designed around "I am using Cortana to interact with an app." There's not really a need to close that window if the interactions are working through Cortana. That said, if you use deep linking to launch as a foreground app, Cortana should terminate. It will still pass the information to your app. https://msdn.microsoft.com/en-us/library/windows/apps/mt445538.aspx
Voice Command to close Cortana's Active or Static Window
Try this. Say "Hey Cortana", wait for listening response. Then say "Please Close". This Usually works for me. It seems that the word "Please" at the beginning of a Cortana communication or preceding a command tends to give the following text a more centralized, isolated, or dare say personalized context, generating an altered response to the following given command. The P word doesn't seem to have a very broad effect on Cortana's Cognitive Library that I have noticed just yet, but I haven't focused much effort on researching responses across the English Literary Spectrum. But I encourage you to please throw at her anything you feel like and if possible, shoot back the pertinent info here so that we all can learn from, benefit from, and possibly discover new tools to make this thing work more cooperatively, to share with us so that we all can benefit and prosper from making our electronics equipment work more for us and not us working hard at making them function properly. Besides, I myself still wants to know how to make her lean toward performing a real action rather than simply defaulting by pulling up a webpage In response to a Stated Command. ~~ P.S. Since the last Quality Update, she has occasionally pulled up the browser search after this command sequence. It would seem that MS believes that all of our commands, inquiries, and statements belong in a Bing Box, and that the proper response lies in the resulting pages. So, GOOD LUCK !
Seems like if you say "Cancel" it works!
You can use it to:
Cancel your search while you are speaking.
Close whatever window that Cortana opens like alarms or metric conversions, does
not work with bing explorer. Sometimes you need to say again "Hey
Cortana" before "Cancel" to get the windows close.

Windows Phone 8 - Event on application killed / exited (closing background audio agent)

Current scenario stands like this:
User opens my app
Background audio agent starts playing
User goes back to start screen
Audio keeps playing from the background audio agent
User kills the application from the "task bar" (the closing button in upper right corner)
Background audio agent keeps playing.
I need to achieve following:
Close the audio background agent when the user kills the application (I know that I can use the close method on the backgroundaudioplayer but I need to call this when the application is killed/exited).
Questions:
Is there any event besides: Application_Deactivated / Application_Closing when the user truly exits/kills the application?
If there is no event like mentioned above - can I tell from Application_Deactivated / Application_Closing when the user really exits/kills the application?
Thank you
there is no way to detect when an app got closed by the task switcher or system. Usually apps keep tombstoned until they get either reactivated or killed. You have to do all the clean-up work in the Application_Closing and Application_Deactivated events.
This has one simple reason: When an application lies in the background it is freezed and cannot execute code. Whenever the user or the system kills it (to get more memory for example) the app and all its data get completely wiped out of the memory. Without notifying your app and without giving it the chance to gain performance (which would be counterproductive).
So you just have the chance to use the Application_Deactivated event when the user tap the start button or another app is launched or the Application_Closing event when the user closes the app via back button.
Read this if you need additional information about the Windows Phone 8 Application lifecycle.
Beside this a user would expect that the background audio is still running after he closes the application. A podcast for example should also play when I closed the podcast app. What kind of audio are you talking about? Maybe we can find a smart solution...
The only events you can react to are Closing and Deactivated.
So here,you can call BackgroundAudioPlayer.Instance.Close() in "Application_Closing" event only.

How do I create a WinForms application that locks/freezes every other application and can't be closed?

I am writing an application in c# to lock or freeze all programs untill user enters a value in the app's textbox and clicks ok.
The purpose of the app would be to get people to enter their time.
As far as I know you can set it to top most but they can end the app with task manager so am stuck here..
formName.TopMost = true;
Any help would be appreciated
Yes, that's correct. The Windows operating system allows multiple programs to run at one time. What you're experiencing is entirely by design.
If I remember correctly, the TopMost property applies only to windows in your process, and as you mention, it's all quite irrelevant: the user can still kill your application using the Task Manager.
There's no legitimate way of getting around that. It's not a "limitation", it's a feature. Any app that prevents itself from being closed by the Task Manager is treading dangerously closely on the category of software that we call malware. Nothing good can come out of pursuits like this.
Relevant reading: The arms race between programs and users
Perhaps a good compromise solution is to make your window/form actually top-most and disable the Close button so that the user knows they shouldn't try and close it. This is almost always enough to stop a user that is not determined to end your application by any means necessary, and that's about all you should ever be concerned with.
See the sample code here for how to make your window/form always appear on top of other running applications by setting the WS_EX_TOPMOST flag or toggling HWND_TOPMOST.
I've also already written a detailed answer here about disabling the Close button the correct way by setting the CS_NOCLOSE class style.

C# Windows Form Killed By Task Manager...Is There a Way to Run Shutdown Function?

I doubt this is even possible. So your app is running and user decides to End Process via Task Manager. Is there a method/action to save data during process.kill? I doubt there is but I had to ask.
Also, if a user shuts down/restarts PC (as in windows update/manual restart), what action would the app execute? Window_Unloaded? On this second question, I would like to find a way to ensure my app does not show up as a 'if you want to restart, kill this app' situation and want to save needed data.
Your two cents is greatly appreciated!
It's not possible to do what you want unless you have two processes; one monitoring the other one's status and do some stuff upon its termination. The watchdog process might be a Windows Service Application without GUI.
Windows sends a quit message to every opened application when normal shutdown occurs. You can run some code (usually housekeeping stuff) upon receiving the message and exit the application. It shouldn't take long or Windows will automatically ask user if they want to kill the application.
Force shutdown kills all processes immediately (in no particular/predictable order). So you can't (easily) detect it.
I suggest you to save everything needed as soon as possible to prevent data loss when the application process gets killed.
If something terminates your running app, then you don't get an opportunity to do anything, just die. You modify your app such that all data is always saved to some persistent location, so if the app dies, the persisted data remains. Obviously you have to design for this. Then if the user does a "save", you commit to the "real" datastore.
If Windows is going to reboot, it should send a message to your app, which you can handle. Not sure if this works for all GUI/console/service -type apps however.

calling the user attention outside of app

I want to create an alarm app for myself. On certain conditions (i need to poll websites) i want my app to inform me and make it HARD TO MISS. So i can take appropriate action or ignore it if i need to do something else.
I wrote a test app and using a BalloonTip (ShowBalloonTip with notifyIcon) isnt great. One of my previous apps brings the window in front of you and does a MessageBox however that doesnt always work or work well (if i somehow miss it or accidentally forget to click ok no futher messages will occur).
What are your suggestions?
You could also make it a system tray application and change the icon out if there is something which requires attention, a la a messenger application. That may not be "hard to miss" but I am trained (for better or worse) to look down at the icon tray when I see something blinking.
Where I work, we have a TimeTracker application (built in house) with which developers are supposed to log what we worked on and when. I am notorious for not using it. So, I wrote my own (Windows Forms) version for my own use which, every hour opens up and takes over my screen:
It is a frameless dialog which consumes the entire screen.
TopMost = True.
On resize, it sets WindowsState = Normal and resizes to fill the screen.
While it is open, it polls for taskmgr.exe and procexp.exe and kills them if found.
It disables the start menu to prevent cmd.exe commands from the menu in Windows 7.
The only way to close it is to enter a log, only then is the OK button shown!
So far, it's working out well - no one has been able to break it!
My less drastic suggestion would be to have a notification which pops up momentarily above the system tray. After a second or two, fade it out. Keep showing the notification every 30 seconds or so until it is dismissed.
Always-on-top window in the corner of the screen?
You could always set your window to be a top most window, make it full screen, and activate it. It would be very, very hard to miss...
Granted, it would also be very annoying, and not something I'd do to other users...
My "real" suggestion would be to use sound along with standard notification methods if this is going to be used by other people, as that's an easy way to grab attention without necessarily killing their workflow. A modeless window that appears in a corner of the screen, especially if combined with sound and color, can be very effective to grab attention.
The industry has been adopting these ambient orb devices and variations of it when such a hard-to-miss notification is required. It is used for tracking the stock-market and for broken-daily-builds.
http://www.ambientdevices.com/cat/orb/MAN_Ambient%20Orb_3-23-03.pdf
Regards

Categories