how to automate some actions on Windows form Application? - c#

I have a working windows form desktop application that I have created. The application is doing some jobs on monthly basis. Every month I need to run the application and there is a connect button. which I click and then it loads up in a dropdown menu some lists and I choose one of them and click another button to do the job. So what I would like to do is automate this process and just let the application to do this job for me every month as a scheduled. I do not want to go inside to code and make it a console application and run the console application from tasks schedule. I am just wondering is there any way that I can create another small application and define the steps to take (similar Macros or test projects(codedUI Test)) to do the job for me?

May be you just need something like AutoHotkey? http://www.autohotkey.com/
It's already 'another small application' and you can 'define steps to take' with it :)

I recommend you Automa - Python tool/library for automating GUI applications. It's very easy to use and perfect for tasks you described:
click(Button("Connect"))
click(ComboBox("Drop Down Menu Name"), "Option 1")
press(ENTER)
You can save the commands in a text file with the .at extension and run it easily from command line whenever required:
> Automa.exe your_script.at
Disclaimer: I'm one of Automa's developers.

Related

How to automate a windows form application without windows scheduler?

I need to make an application which automatically moves files from source folder to destination folder on specified "time"(2 different times in a day). Once entered, this app should run daily. I have made a form application which moves file perfectly on button click. I need to implement this without any button click interaction.
Scheduling using Windows Task Scheduler is not an option for me.
One way I have achieved exactly that by creating a windows service project and put all the button click logic in a class library.
For scheduling the service i used Quartz.Net so that it can triggers the job/service at given interval.
You can find more about Quarts.Net here.
Please do note that you need administrative access to install and run your windows service.

Working with Multiple BackGroundWorker with Different Task or Operation

As a .NET developer i have been working 3 C# Windows applications (database updation, crawling data, and downloading an Excel file for importing to database). I have create these 3 projects separately and these 3 application run in background and show every notification on desktop only.
My questions:
How to run these 3 applications on single application?
How to run my second application in background? How to start it when i shutdown and restart the system or laptop?
My 3rd application downloads and imports. once i start it downloading and importing process is once a week or a month, so i have a date picker select today date (06/10/2018 saturday) and week option. How to continue when i shutdown and restart my system?
How to continue where it stopped after i shutdown or restart my application?
These 3 applications are running on internet. How to pause and and run when internet available only?
How to show windows form applications notification on web application?
First: Yes it is possible, do it on 3 separate threads in one process (application). More here
Second: Simply Start application on startup and i would implement in my application code to see if there is one more instance of application running and if it is i would close this one.
Third: Store next download date in some database or txt file. On application start check if(nextDownloadDate > today) //Which mean it should have been updated and if it is true update what you need and update next download date. This way if you turn off your pc (app) and you startup pc again (automatically run app) it will check if it should have been updated and if it is it will do the job
Fourth: Too broad. Try googling or thinking about way of storing data in database/txt/xmal each time you make step and again on application run check from that files where you have stopped
Google it. Not that hard. "How to check if computer have internet access".
Too broad. Think yourself.
Few items i haven't answered since this question is too broad and should be closed but since i see you are new one i made some advises up there for you.

Run a program as a process in the background

I want to create a program that won't close when you click the close button but, only when a exit function is run from within the form.I was thinking i could have it run in the background without the window needing to be open (Like the steam client and dropbox, mediafire, google drive, google chrome extension notification), and was wondering how to do that.
I was thinking of some ways to do it but i wasn't sure how to do them:
A starter program that keeps it open in the background
Running a background process that keeps information stored
I am running c# 2010 so i will need answers relating to that. I would also prefer to not use 3rd party extensions/tools except a basic text editor(Notepad++).Thank you in advance!
There are a number of possible options:
Hide the main form
Create a Tray application
Write a Windows Service

Automate a GUI Windows application with user inputs to run every week

I have a simple Windows application which has two text boxes and one button called "Run". Currently, I have to manually enter the values in text boxes and click on Run button every week. I want to automate this process, so that no user interaction should be required. Can I write a script to do this?
I assume you have the source of your Windows application as you've tagged your question with C#. If so, then it's fairly straightforward to pass your text box values on the command line via something like Windows Task Scheduler, parse the command line parameters in your application, and pass them on to whatever you call when Run is pressed.
Kicking it off at every X interval is one thing. I would suggest the Windows Task Scheduler. However, it sounds like you need to interact with the GUI application after it's been launched. For that, all I can do is point you in the right direction. The only thing that comes to mind is to use a third-party GUI testing suite. Check out this list. You can script any of these suites to interact with the GUI, that is, input some data and click on the Run button.

Run C# application as scheduled task

I have a C# application that was designed to run with a windows form but now needs to run as a scheduled task. I have had problems with this and I think it is because it needs to be "headless" in that it should have no concept of a user environment. The program has been written to run unattended in that it has an /AUTO arg which then will run from some defaults but the form is still shown which causes the problem.
I have looked around and I think there is a way to suppress the form in this situation but I can't find exactly how. Does anyone know how I can suppress the form and allow this application to run?
Take the logic required for the scheduled task out of your WinForms application and put it in a Console application. If you can reuse logic both places, move it into a shared library.
Convert your application to console mode and also check the "Hidden" checkbox in the 'General' tab of Task scheduler.
This will help you
Still if you want to use the WinForm application, then set its ShowOnTaskbar property to false.
And its very easy to convert your winform application to winform one. Just go to the project properties and change the output type to Console. But you need to do few tweaks in the code.
Check if the /AUTO parameter is set and then depending on whether or not is is. Change this in your Program.cs:
Application.Run(new Form1());
to
Application.Run();
this won't show a form and you can do whatever other things you like.
This is the best I can give you without having seen you code. Hop it helps!
You can tell the task to interact with desktop in which case a form that shows is not a problem. As long as your app will close by itself so the job finishes..
I made a form based thing and then wanted a scheduled task so wrote a commandline front end calling the form based app, and then pushed the 2 exes together with ilmerge so it cant get confused, because it was a cheap hack
If your code is properly written you can do an exe front end and use the same classes as your form (or dll) and work that way.
As far as I understood you, you do not need the Forms mode anymore, right?
If this is correct, I suggest implementing your application as service, e.g. a WCF service. It can permanently run and execute your business logic on a configured timer.
To make configuration of the timer easy and flexible, you could optionally imncorporate NCronTab. This allows you to schedule the task in a pattern as easy as 45 11 * * Friday (=> "Run every Friday at 11:45 am")

Categories