C++/CLI Main arguments call buttonclick

Hello, how can i call button_name->PerformClick(); when for example i start winform program from cmd with argument callbutton(nameOfExe.exe callButton).

This is code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "MyForm.h"

using namespace System;
using namespace System::Windows::Forms;

[STAThread]

int main(array<System::String ^> ^args)
{
	if (args->Length > 0)
	{
		if (args[0] == "callButton")
		{
			//button_backup->PerformClick(); or other function, for example void backupFiles();
		}
		return 0;
	}

	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false);
	MSSQLTest::MyForm myForm;
	Application::Run(%myForm);
	return 0;
}


Thanks :)
I am afraid there is no way to do it. You can access a button or function only after you have created the form - an exception would be a static function.
What do you actually want to do ?
Why not using the FormLoad event in the form or override the form constructor ?
for example i have button_backup when i press this, then i backup folder specified in string and i want call this from cmd, for example from batch file in Scheduled jobs in windows, because without this i cant call this. FOr this i need specified console application when in form it not works :/
or how can i make timed actions on my program? for example run my program as service, minimize in tray area and for example when time is 20:00 then program start function. time action can be done via DateTime or timestamp and check every second via while cycle i think and service i must learn with tray too. or better solution? if yes, please tell me :) thanks
Do you use the task scheduler in windows?

As I understand you can specify the time and program Windows will start so the program can do the backup - it doesn't matter if console or form app , no need for batch file.

Creating a tray app or windows service would be an other option. Create a timer and check the time periodically. When it is time do the backup and shut down the app.
Yea, thanks, i go look how to use timers.
Topic archived. No new replies allowed.