Create a windows like screen saver to open an application - c#

I want to open an url in a browser after no activity in windows , and that using windows services
Any idea how that will be in c#

You would need thread that checks for activity, Make a class with a method in it, Make a timespan that checks time since the last key was pressed and use an if statement to launch a browser if the time passes a certain amount.

Related

Adding a Schedule Task Module for WPF Window Application

I have a small program which converts doc file from specified folder to pdf and XPS format using the printer driver available in the local PC.
Now I need to add a scheduler to this program which runs as per scheduled by the user taking parameters like folder_where_doc_files, Destination_Folder, Date_Time to schedule, whether daily, etc, etc.. in the background.
It's a WPF C# window application. The user is requesting to use the command line to schedule the task.
I am unable to analyze how to proceed further.
I checked a few links where "schtaks" command can be used to create a task. How to send my desired parameters to it.
even if I do then my application will start in the background. How to initiate a conversion process like any events on form load, etc, etc..
I am really confused, Please clarify this confusion
One of the possible design would be
1- Create a console application which takes input from the user and store it either locally or on the server
2- Create a windows service that will check through your storage (Local/Server) periodically for the next run.
3- After each run save the last run time in local / server to calculate the next schedule.
The scheduled task requires a user/pwd to be stored in the scheduled task itself and needs to be updated each time the user changes the system password.

Web and windows forms application using same db issues

We have got a web application and a windows forms application. The web application contains a download link to download this forms application.
This forms application will check the client machine privileges and drive space etc. and will update the values to a global database using some webservice calls.
So the web application will continuously checking the global database for the status ie how much checking has been completed by the forms application.
So as soon as the download popup appears for the forms application to download, the web application will start to check the status. But if a user cancels the download or if a user close the forms application, then in these cases how the web application can stop checking for status.
But in my case the web application will always check for the status change , even if the client cancels the download or closes the forms application. So how to avoid this?
I think a timeout is your only real option here. Basically the web side will only check for a certain amount of time before giving up. Your status table in your database should include a "last update timestamp" field. If the status is not "complete", and the current time is greater than that timestamp by X seconds, the webserver assumes the process has timed out.
You could try to have some thing like a switch as part of a record or some thing in the Database, so the very next time your web app tries to read lets say the bit field it would know that it should stop checking. You could control this bit field as ON & OFF via your forms application. Then your web application you can setup a polling mechnism that checks the db every so often before timing itself off all together based on the bit field or if not been done then aftera period of time.
Having said that your forms application would need to be able to call the outside world where your db is some where located and update it, it can be done many ways, web service call, http, ect...
Update:
I apologies for the delay in replying but did you understand what I said? If your winforms application can call your web service then it can tell it to store a flag field some where like a record in the db for example that your web-application is polling and checking and then by setting that flag field your web-application would know to stop doing any thing with that record, item.
As you mentioned you are worried about:
User clicking cancel on download:
In this scenario you would not set the checking of your record by your web-application unless the user has downloaded and run your win-forms application for the first time, so dont start checking upon dowload of the win-forms application but start checking once for the first time the user has opened it, you can do this upon start of the winforms application by setting the flag field from your winforms app by calling your web-service. You will need a polling mechanism on top of this every so often, like a service.
When the user closes the winforms application
In this case you would upon termination/close of your winforms app call your web service and set the flag field not to check that record, item any more.
You will need polling in any case as I am thinking you will have many users and hence you will need to monitor the db for incoming messages from your winforms app. Also please be aware as some users are behind firewalls, limited security permissions on their machines and on private networks and your winforms app may not always be able to call your web service.
Hope that helped.

Running a program when Windows Boots (before Login)

I wonder is it possible to run my application before login on windows.? Its actually a WinForm application(Preferably other than Windows service).
I mean my application must be running even before log in and it should sit on System Tray from which I can "show" or open Interface for user.
To have:
Something happen between system startup and user login
An icon in the notification area for users to interact with
You must break your application up into two separate components. One of these will be a WinForms/WPF application which provides the notification area icon and allows the user to interact with it. The other will be a Windows Service, or possibly a scheduled task.
Once you've done this, the windows service can focus on doing whatever needs to be done prior to logon and the notification area application can assume responsibility for showing the results, or whatever else to the end user.
To answer the question you posed in comments regarding reading data from the Event Log, yes this is possible. There are other questions on here which will give you that particular answer:
read the windows event log by particular Source
Read event log in C#
This MS article might help but it is a bit old:
http://support.microsoft.com/kb/142905
Hopefully it'll put you on the right tracks though.
I think, it doesn't make sense, to acquire user input before a user has logged into the system. So, if the application needs input from a user, why start it before the use has logged in? If the application just starts some background work, than you should use a windows service, as this is the prefered way in windows.
Type in run gpedit.msc, for Group Policy,
There you can set start up script.
Application will launch before Windows Login,
Step to produce :-
Start --> Run --> gpedit.msc --> Local Computer Policy --> Windows Settings --> Script (Startup/ShutDown),
Add you .exe
It will launch Before login.
Do not try more in Group Policy, it may happen harmful for System
By Programmatic logic,
Try with registry key
this value is updating in registry,
by our program we can update directly registry then we can call application
You can schedule any application to be run when computer is powered on using Windows Task Scheduler. There is a corresponding option there.
But why would you need this? You should use a service for this.

Desktop notifier with no visible form to user

I want to make a application that runs with no form interaction with user and only specific person can run a form and change config setting. The application is desktop reminder which runs every 4 months and shows up a notification.
I don't have any idea how to start it. Please guide me with some good suggestions.
If you have an application that needs to notify the user once every 4 months, its a bit overhead to have it running all the time.
Use the Task Scheduler in Windows, to schedule this command to run (once per day, or every week) check if the condition is met. If not silently exit.
You can effectively create a windows Service and then configure it to allow it interact with the desktop through the Services administration console.
However, for security reasons in W2008 Server (and I assume that more or less it will be the same with W7 or even Vista, you'll have to try it) this behaves differently, and services that interact with the desktop are not allowed. Actually, I remember that when I created and showed a Window I got a notification and when clicking on it the desktop switched to another one with my window. Still, no issue with XP, I've done it.

Session variable in C# desktop application?

I am developing a C# a stand alone single user desktop application that requires the user to login to the application. I want to ensure that when there is no activity for 5 minutes or so the application will prompt the user to login again. I have several solution in mind to do this but there do not seem efficient. Previously while doing web programming i was able to do this kind of feature using session variable are there are similiar kind of features in C# that can be used for desktop application.
One way to do this is to set a 5-minute timer that is always running, and logs the user out when it ticks. Then you can have any activity restart the timer from the beginning.
If this is a WinForms app, you can have your top-level forms implement IMessageFilter. In your PreFilterMessage function you would restart the timer and return false for messages that indicate activity (WM_KEYDOWN, WM_MOUSEMOVE, etc.) to let everything get processed normally.
You can always add a trigger to auto-logout within a Windows Forms Application. Here is a link with examples with an accepted answer
How can I trigger an auto-logout within a Windows Forms Application?
To monitor user activity, you could create a custom Form-based class
from which your application forms will inherit. There you can
subscribe to the MouseMove and KeyDown events (setting the KeyPreview
property to true), either of which will be raised whenever the user is
active. You can then create a System.Threading.Timer, with the due
time set to 30 minutes, and postpone it using the Change() method
whenever user activity is detected.
No, but session state is just a list of variables to help overcome the stateless nature of web applications. Since desktop applications are not stateless, there's no need. I'd just use a simple timer or something similar and log the user out after 5 minutes of inactivity.

Categories

Resources