I want to launch my AHK script like described here. I will need to do two different things, A and B. I can either put them in one script, or two separate scripts. But B needs some data from A, which is where my problem lies.
Solution one: Put A and B into one script, and somehow notify it when it's time for part B, but without restarting it. But how?
Solution two: Put them into separate scripts, and somehow pass the values between them. But again, how? The value does not fit into the exit code, and I also don't know how to get the exit code and now to launch multiple executables from and UWP app.
Related
I have a console application that converts .txt files into .xml files. I made a WinForms application to make a menu and select a Console Application and run it. The user can choose the paths of the input files through a browse button, and it insert the paths as string into some textboxes. Now I want the Console App to read what they say so it can locate the input files.
Is there any way to do this?
It is pretty easy to launch a console app from a WinForms app by simply using a process. Example:
Process.Start("myConsoleApp.exe", "some arguments");
However, the only time this makes sense is when the console app is not your own code. Or if it is your own code, but it is a generic app that is called from different UIs or methods.
If none of the above is the case (which seems to be your case), it makes more sense to merge the UI and functionality in one app. You wanted the menu to be a generic app that calls different apps, so simply remove the UI related to the console app, make it a separate WinForms app, and add the code from the console app to it. Now your menu app will simply call a WinForms app that has the UI and functionality all in one. You will use the same method above, but likely you don't need to pass any arguments:
Process.Start("myWinformsApp.exe");
From your winform application you can launch another process (probably by passing exe path of console app you talking about and relevant i/p parameter of type string which is basically path of your text file provided by user)
This link might help you do that.
I want my project to have two executable windows. Whether that results in two executable files, or if both windows are launched when the exe is double clicked doesn't matter.
I want to be able to close the first window and have the second window continue to run. opening up a new instance of the first window shouldn't effect the second window, and no more than 1 instance of the second window should be allowed to run at once.
Ideally I would like my project to have two executable files, but I'm not sure how to implement this. I don't want to make them separate projects, because they share a lot of the same methods and variables, as well as user settings, but I may have to if that's the only way.
What is the best way to go about this?
Becuase they share so much I would suggest making 3 projects
1 for each of the windows
1 for the shared functionality.
This way, the shared functionality can be compiled into a separate DLL and can be used by both exe's
I was wondering if it is possible to open a second project (in the same solution as the first one) by code in the first project.
For example i have one form application project and another console application project.
The form application starts and when the user clicks a button i want the console application to run and the form application to stop.
Or could someone tell me how to delete my application .exe file?
The projects don't need to be in the same solution to do that. Just use Process.Start to start the executable for another application, and then close the main form to end the current application.
If you don't want to run the code as an entirely different process then it may also make sense to have a 3rd project that is a "class library" that the other two projects could add a reference to. This would allow you to define common code used in either application, using classes that are generalized to be helpful in either project.
I'm not sure what you're trying to do; but Process class has Start and Kill methods that will let you launch / exit processes.
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
I've got a console application and I want to run it from another application. But when I invoke it from code--to call program I use ActiveXObject--it shows the console. How do I get it to not show the console? I mean, the program works but console is shown.
If you make the application a Windows Application instead of a Console Application it will not show or open (or use) a Console. Your code can stay the same - and the application will still function (without ever creating a Form or Window).
That being said, if you control the "other" application, you may want to consider making a class library instead of a separate Application. This would allow you to just include and run code within the library without starting a separate process.
You can create it as a Windows Forms application with a hidden window. That's just one possibility like Reed Copsey pointed out, i used it once because i needed to process some specific Window Messages.
I have a C# Console app than runs a pre-build step (to get NuGet Packages).
When I am debugging this, I want to pass in a parameter and show the console. When I am not debugging it I don't want to see it. I don't even want it to flash up there for a second.
I have found ways to hide it, after it has shown. But I can't find a way to never make it show unless I am willing to change it from a console app to a Windows app. (Which I would do if I could then find a way to show the Console when needed.)
Build as a Windows application and show the console when you need it. To show the console when needed use P/Invoke to call AllocConsole (pinvoke.net has the declaration you need).
(Console sub-system processes always get a console, their parent process's if there was one, otherwise a new one. This is the way Windows works at a deep level.)
Use FreeConsole WINAPI function:
http://pinvoke.net/default.aspx/kernel32/FreeConsole.html
Another solution is to simply switch to a WinForms application as project type. No console will be allocated then (and you do not need to show a form).